SciPost Code Repository

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

move nomination vote bootstrap classes to model

parent 0fcb57b8
No related branches found
No related tags found
1 merge request!58[Fellowship Nominations] Rework the fellowship nomination system and UI
...@@ -312,6 +312,12 @@ class FellowshipNominationVote(models.Model): ...@@ -312,6 +312,12 @@ class FellowshipNominationVote(models.Model):
(VOTE_DISAGREE, "Disagree"), (VOTE_DISAGREE, "Disagree"),
(VOTE_VETO, "Veto"), (VOTE_VETO, "Veto"),
) )
VOTE_BS_CLASSES = {
VOTE_AGREE: "success",
VOTE_ABSTAIN: "warning",
VOTE_DISAGREE: "danger",
VOTE_VETO: "black",
}
voting_round = models.ForeignKey( voting_round = models.ForeignKey(
"colleges.FellowshipNominationVotingRound", "colleges.FellowshipNominationVotingRound",
...@@ -331,6 +337,10 @@ class FellowshipNominationVote(models.Model): ...@@ -331,6 +337,10 @@ class FellowshipNominationVote(models.Model):
objects = FellowshipNominationVoteQuerySet.as_manager() objects = FellowshipNominationVoteQuerySet.as_manager()
@property
def get_vote_bs_class(self):
return self.VOTE_BS_CLASSES[self.vote]
class Meta: class Meta:
constraints = [ constraints = [
models.UniqueConstraint( models.UniqueConstraint(
......
<h3>Cast your vote:</h3> <h3>Cast your vote:</h3>
{% for vote_option, color in vote_options %} {% for vote_option, color in VOTE_BS_CLASSES.items %}
<form hx-post="{% url 'colleges:_hx_nomination_vote' round_id=voting_round.id %}" <form hx-post="{% url 'colleges:_hx_nomination_vote' round_id=voting_round.id %}"
hx-target="#nomination-{{ voting_round.nomination.id }}-vote"> hx-target="#nomination-{{ voting_round.nomination.id }}-vote">
......
...@@ -41,16 +41,8 @@ ...@@ -41,16 +41,8 @@
{% if not round.is_unscheduled %} {% if not round.is_unscheduled %}
{% if voter.vote.vote == "agree" %} {% if voter.vote %}
<td class="text-success">{{ voter.vote.get_vote_display }}</td> <td class="text-{{ voter.vote.get_vote_bs_class }}">{{ voter.vote.get_vote_display }}</td>
{% elif voter.vote.vote == "abstain" %}
<td class="text-warning">{{ voter.vote.get_vote_display }}</td>
{% elif voter.vote.vote == "disagree" %}
<td class="text-danger">{{ voter.vote.get_vote_display }}</td>
{% elif voter.vote.vote == "veto" %}
<td>
<span class="badge bg-dark">{{ voter.vote.get_vote_display }}</span>
</td>
{% else %} {% else %}
<td class="text-muted">No vote</td> <td class="text-muted">No vote</td>
{% endif %} {% endif %}
......
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