-
-
Notifications
You must be signed in to change notification settings - Fork 662
Add Candidate Page and Claim Highlights Feature #5371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
rudransh-shrivastava
wants to merge
21
commits into
OWASP:feature/bod-candidate-transparency
Choose a base branch
from
rudransh-shrivastava:feature/bod-candidate-improvements
base: feature/bod-candidate-transparency
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 10 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
821663b
add BoardCandidateProfile model and update code
rudransh-shrivastava 2a7a638
add candidate profile page with annotations
rudransh-shrivastava c1cf6e8
integrate claim highlights and candidate page with other components
rudransh-shrivastava 4d64d9f
backend: apply bot comments
rudransh-shrivastava 3930de5
apply frontend bot comments
rudransh-shrivastava 126da9a
refactor frontend to use markdown-to-jsx
rudransh-shrivastava 1d0de2d
frontend cleanup
rudransh-shrivastava 9e9c30d
remove AnnotatedProfile
rudransh-shrivastava 5e390c8
rewrite AnnotatedProfile with better quality code
rudransh-shrivastava b5a000a
generate graphql types
rudransh-shrivastava 59a0bb5
bot comments, hide popup when overlapping existing highlight
rudransh-shrivastava c4a83e6
don't show create claim button when highlighted text is not in raw ma…
rudransh-shrivastava 5c200da
remove unused isReviewer
rudransh-shrivastava 2d456a9
display all matched claims instead of first
rudransh-shrivastava 0694855
Merge branch 'feature/bod-candidate-transparency' into feature/bod-ca…
rudransh-shrivastava b3981fb
post merge, fix generate command to include source text
rudransh-shrivastava c64d77a
validate source text in backend
rudransh-shrivastava 4767af9
cleanup frontend code
rudransh-shrivastava 162a9a1
Merge branch 'feature/bod-candidate-transparency' into feature/bod-ca…
rudransh-shrivastava d2b7ee6
update claim status RBAC, show submitted claims, change colors
rudransh-shrivastava b15e9ee
fix breadcrumbs
rudransh-shrivastava File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| """Django admin configuration for BoardCandidateProfile model.""" | ||
|
|
||
| from django.contrib import admin | ||
| from django.db import models | ||
|
|
||
| from apps.owasp.models.board_candidate_profile import BoardCandidateProfile | ||
|
|
||
|
|
||
| class BoardCandidateProfileAdmin(admin.ModelAdmin): | ||
| """Admin for BoardCandidateProfile model.""" | ||
|
|
||
| autocomplete_fields = ("candidate",) | ||
| list_display = ( | ||
| "__str__", | ||
| "nest_created_at", | ||
| "nest_updated_at", | ||
| ) | ||
| search_fields = ( | ||
| "candidate__member_name", | ||
| "candidate__member__login", | ||
| "raw_markdown", | ||
| ) | ||
| readonly_fields = ( | ||
| "nest_created_at", | ||
| "nest_updated_at", | ||
| ) | ||
|
|
||
| def get_queryset(self, request) -> models.QuerySet: | ||
| """Retrieve optimized queryset with related candidate. | ||
|
|
||
| Args: | ||
| request: The HTTP request object. | ||
|
|
||
| Returns: | ||
| QuerySet: BoardCandidateProfile queryset with prefetched candidate. | ||
|
|
||
| """ | ||
| return super().get_queryset(request).select_related("candidate__member") | ||
|
|
||
|
|
||
| admin.site.register(BoardCandidateProfile, BoardCandidateProfileAdmin) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| "key", | ||
| "name", | ||
| "order", | ||
| "source_text", | ||
| "withdrawn_at", | ||
| "withdrawn_reason", | ||
| ], | ||
|
|
||
34 changes: 34 additions & 0 deletions
34
backend/src/apps/owasp/api/internal/nodes/board_candidate_profile.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| """OWASP Board Candidate Profile GraphQL node.""" | ||
|
|
||
| from datetime import datetime | ||
|
|
||
| import strawberry | ||
| import strawberry_django | ||
|
|
||
| from apps.owasp.api.internal.nodes.entity_member import EntityMemberNode | ||
| from apps.owasp.models.board_candidate_profile import BoardCandidateProfile | ||
|
|
||
|
|
||
| @strawberry_django.type( | ||
| BoardCandidateProfile, | ||
| fields=[ | ||
| "raw_markdown", | ||
| ], | ||
| ) | ||
| class BoardCandidateProfileNode(strawberry.relay.Node): | ||
| """Board Candidate Profile node.""" | ||
|
|
||
| @strawberry_django.field | ||
| def candidate(self, root: BoardCandidateProfile) -> EntityMemberNode: | ||
| """Resolve candidate.""" | ||
| return root.candidate | ||
|
|
||
| @strawberry_django.field | ||
| def created_at(self, root: BoardCandidateProfile) -> datetime: | ||
| """Resolve profile creation date.""" | ||
| return root.nest_created_at | ||
|
|
||
| @strawberry_django.field | ||
| def updated_at(self, root: BoardCandidateProfile) -> datetime: | ||
| """Resolve profile last update date.""" | ||
| return root.nest_updated_at |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
backend/src/apps/owasp/api/internal/queries/board_candidate_profile.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| """OWASP Board Candidate Profile GraphQL queries.""" | ||
|
|
||
| import strawberry | ||
| import strawberry_django | ||
| from django.contrib.contenttypes.models import ContentType | ||
|
|
||
| from apps.owasp.api.internal.nodes.board_candidate_profile import BoardCandidateProfileNode | ||
| from apps.owasp.models.board_candidate_profile import BoardCandidateProfile | ||
| from apps.owasp.models.board_of_directors import BoardOfDirectors | ||
| from apps.owasp.models.entity_member import EntityMember | ||
|
|
||
|
|
||
| @strawberry.type | ||
| class BoardCandidateProfileQuery: | ||
| """GraphQL queries for Board Candidate Profile model.""" | ||
|
|
||
| @strawberry_django.field | ||
| def board_candidate_profile( | ||
| self, info: strawberry.Info, login: str, year: int | ||
| ) -> BoardCandidateProfileNode | None: | ||
| """Resolve Board Candidate Profile. | ||
|
|
||
| Args: | ||
| info (Info): Strawberry Info. | ||
| login (str): The login of the candidate. | ||
| year (int): The year of the election. | ||
|
|
||
| Returns: | ||
| BoardCandidateProfileNode object if found, None otherwise. | ||
|
|
||
| """ | ||
| try: | ||
| board = BoardOfDirectors.objects.get(year=year) | ||
| content_type = ContentType.objects.get_for_model(BoardOfDirectors) | ||
| return BoardCandidateProfile.objects.select_related("candidate__member").get( | ||
| candidate__member__login=login, | ||
| candidate__entity_type=content_type, | ||
| candidate__entity_id=board.id, | ||
|
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
|
||
| candidate__role=EntityMember.Role.CANDIDATE, | ||
| candidate__is_active=True, | ||
| candidate__is_reviewed=True, | ||
| ) | ||
| except (BoardOfDirectors.DoesNotExist, BoardCandidateProfile.DoesNotExist): | ||
| return None | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.