SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
6f5731d0
Commit
6f5731d0
authored
1 year ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
add default vote outcome to nomination decision
parent
804eae5a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!58
[Fellowship Nominations] Rework the fellowship nomination system and UI
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
scipost_django/colleges/forms.py
+4
-0
4 additions, 0 deletions
scipost_django/colleges/forms.py
scipost_django/colleges/models/nomination.py
+22
-0
22 additions, 0 deletions
scipost_django/colleges/models/nomination.py
scipost_django/colleges/views.py
+3
-3
3 additions, 3 deletions
scipost_django/colleges/views.py
with
29 additions
and
3 deletions
scipost_django/colleges/forms.py
+
4
−
0
View file @
6f5731d0
...
...
@@ -552,6 +552,7 @@ class FellowshipNominationDecisionForm(forms.ModelForm):
]
def
__init__
(
self
,
*
args
,
**
kwargs
):
voting_round
=
kwargs
.
pop
(
"
voting_round
"
,
None
)
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
helper
=
FormHelper
()
self
.
helper
.
layout
=
Layout
(
...
...
@@ -568,6 +569,9 @@ class FellowshipNominationDecisionForm(forms.ModelForm):
),
)
if
voting_round
:
self
.
fields
[
"
outcome
"
].
initial
=
voting_round
.
vote_outcome
class
FellowshipInvitationResponseForm
(
forms
.
ModelForm
):
class
Meta
:
...
...
This diff is collapsed.
Click to expand it.
scipost_django/colleges/models/nomination.py
+
22
−
0
View file @
6f5731d0
...
...
@@ -218,6 +218,28 @@ class FellowshipNominationVotingRound(models.Model):
def
is_open
(
self
):
return
self
.
voting_opens
<=
timezone
.
now
()
<=
self
.
voting_deadline
@property
def
vote_outcome
(
self
):
"""
The outcome as determined by the votes.
"""
if
self
.
votes
.
veto
():
return
FellowshipNominationDecision
.
OUTCOME_NOT_ELECTED
nr_votes_agree
=
self
.
votes
.
agree
().
count
()
nr_votes_disagree
=
self
.
votes
.
disagree
().
count
()
nr_non_abstaining_votes
=
nr_votes_agree
+
nr_votes_disagree
# Guard division by zero
if
nr_non_abstaining_votes
==
0
:
return
FellowshipNominationDecision
.
OUTCOME_NOT_ELECTED
# By-laws 1.3.4 grand fellowship if there is a majority of non-abstaining votes.
# Agree is counted as +1, disagree as -1
agree_ratio
=
(
nr_votes_agree
-
nr_votes_disagree
)
/
nr_non_abstaining_votes
if
agree_ratio
>=
0.5
:
return
FellowshipNominationDecision
.
OUTCOME_ELECTED
else
:
return
FellowshipNominationDecision
.
OUTCOME_NOT_ELECTED
class
FellowshipNominationVote
(
models
.
Model
):
VOTE_AGREE
=
"
agree
"
...
...
This diff is collapsed.
Click to expand it.
scipost_django/colleges/views.py
+
3
−
3
View file @
6f5731d0
...
...
@@ -961,7 +961,9 @@ def _hx_nomination_vote(request, voting_round_id):
def
_hx_nomination_decision_form
(
request
,
round_id
):
voting_round
=
get_object_or_404
(
FellowshipNominationVotingRound
,
pk
=
round_id
)
nomination
=
voting_round
.
nomination
decision_form
=
FellowshipNominationDecisionForm
(
request
.
POST
or
None
)
decision_form
=
FellowshipNominationDecisionForm
(
request
.
POST
or
None
,
voting_round
=
voting_round
)
if
decision_form
.
is_valid
():
decision
=
decision_form
.
save
()
nomination
.
add_event
(
description
=
"
Decision fixed
"
,
by
=
request
.
user
.
contributor
)
...
...
@@ -974,8 +976,6 @@ def _hx_nomination_decision_form(request, round_id):
nomination
.
add_event
(
description
=
"
Invitation created
"
,
by
=
request
.
user
.
contributor
)
else
:
decision_form
.
fields
[
"
voting_round
"
].
initial
=
voting_round
context
=
{
"
voting_round
"
:
voting_round
,
"
decision_form
"
:
decision_form
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment