SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit fb71dfaa authored by George Katsikas's avatar George Katsikas :goat:
Browse files

filter voting fellows in nomination vote admin

parent 6f5731d0
No related branches found
No related tags found
1 merge request!58[Fellowship Nominations] Rework the fellowship nomination system and UI
...@@ -116,6 +116,14 @@ class FellowshipNominationVoteInline(admin.TabularInline): ...@@ -116,6 +116,14 @@ class FellowshipNominationVoteInline(admin.TabularInline):
model = FellowshipNominationVote model = FellowshipNominationVote
extra = 0 extra = 0
# Filter "fellow" field to only those who are eligible to vote
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "fellow":
kwargs["queryset"] = FellowshipNominationVotingRound.objects.get(
pk=request.resolver_match.kwargs["object_id"]
).eligible_to_vote.all()
return super().formfield_for_foreignkey(db_field, request, **kwargs)
class FellowshipNominationVotingRoundAdmin(admin.ModelAdmin): class FellowshipNominationVotingRoundAdmin(admin.ModelAdmin):
model = FellowshipNominationVotingRound model = FellowshipNominationVotingRound
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment