diff --git a/core/static/election/election.scss b/core/static/election/election.scss new file mode 100644 index 00000000..0af2286d --- /dev/null +++ b/core/static/election/election.scss @@ -0,0 +1,281 @@ +$padding: 1.5rem; +$padding_smaller: .5rem; +$gap: .25rem; +$border: .01rem solid black; +$min_col_width: 100px; + +.error { + color: red !important; +} + +.radio-btn { + display: flex; + flex-direction: row; + gap: $gap; + + > input, + > label { + margin: 0; + } + + &:hover { + cursor: pointer; + } +} + +.election_vote { + overflow-x: scroll !important; +} + +.election_table { + width: 100%; + + >.lists { + display: flex; + flex-direction: row; + + >tr { + display: flex; + flex-direction: row; + width: 100%; + + >.column { + display: flex; + flex-direction: column-reverse; + align-items: center; + justify-content: center; + padding: $padding; + border: $border; + border-collapse: collapse; + position: relative; + min-width: $min_col_width; + + >a{ + margin-left: $padding; + width: 20px; + height: 20px; + text-align: center; + padding: 5px; + border-radius: 25%; + margin: 0; + display: flex; + align-items: center; + justify-content: center; + position: absolute; + right: $gap; + top: $gap; + + &:hover { + background-color: #ddd; + } + } + } + } + } + + >.role { + display: flex; + flex-direction: column; + + >tr { + display: flex; + flex-direction: row; + background-color: lightgrey; + + &:hover { + background-color: lightgrey; + } + + >.role_title { + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-between; + margin: 0; + padding: $padding; + width: 100%; + + + >.role_text { + >h4 { + margin: 0; + } + >p { + margin-top: .5em; + } + } + + >.role_buttons { + display: flex; + flex-direction: row; + align-items: center; + gap: $gap; + + > button, + > button > i, + > a { + width: 20px; + height: 20px; + background-color: #e9e9e9; + text-align: center; + padding: 5px; + border-radius: 25%; + margin: 0; + display: flex; + align-items: center; + justify-content: center; + + &:hover, + &:hover > i { + background-color: #fff; + } + } + + > button { + width: 30px; + height: 30px; + } + + > button[disabled] { + background-color: #eee; + cursor: not-allowed; + + >i, + &:hover, + &:hover > i { + background-color: #eee; + } + } + } + } + + >.list_per_role { + display: flex; + flex-direction: row; + justify-content: center; + border: $border; + border-collapse: collapse; + background-color: #fff; + padding: $padding_smaller; + margin: 0; + min-width: $min_col_width; + + >.candidates { + margin: 0; + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: center; + gap: $gap; + + >.candidate { + display: flex; + flex-direction: column; + align-items: center; + + list-style-type: none; + gap: $gap; + + >input[type="radio"]:checked + label, + >input[type="checkbox"]:checked + label { + background-color: lightgray; + border-radius: 10px; + + >figure>.edit_btns>a:hover{ + background-color: #fff; + } + } + + >label>figure, + >figure { + position: relative; + display: flex; + flex-direction: column; + align-items: center; + gap: $gap; + padding: 10px; + + >img { + max-width: 100%; + } + + >figcaption { + h5 { + margin: 0; + text-align: center; + } + q { + margin: 5px 0; + } + } + + >.edit_btns { + position: absolute; + display: flex; + flex-direction: column; + top: $gap; + right: $gap; + gap: $gap; + + > a { + width: 20px; + height: 20px; + background-color: #e9e9e9; + text-align: center; + padding: 5px; + border-radius: 25%; + margin: 0; + display: flex; + align-items: center; + justify-content: center; + + &:hover { + background-color: #d8d8d8; + } + } + } + } + } + } + } + } + } +} + +.election_details { + margin: .5em 0; +} + +.buttons { + display: flex; + flex-direction: row; + flex-wrap: wrap; + align-items: center; + justify-content: center; + gap: $gap; +} + +.button { + border: none; + color: black; + text-decoration: none; + background-color: #f2f2f2; + padding: 0.4em; + margin: 0.1em; + font-size: 1.18em; + border-radius: 5px; + box-shadow: #dfdfdf 0px 0px 1px; + cursor: pointer; + + &:hover { + color: black; + background: #d4d4d4; + } + + &_send { + background-color: #59aee2; + &:hover { + background-color: rgb(130, 186, 235); + } + } +} \ No newline at end of file diff --git a/election/templates/election/election_detail.jinja b/election/templates/election/election_detail.jinja index cf79003f..853fab78 100644 --- a/election/templates/election/election_detail.jinja +++ b/election/templates/election/election_detail.jinja @@ -6,232 +6,14 @@ {% block head %} {{ super() -}} - + {%- endblock %} {% block content %}

{{ election.title }}

{{ election.description }}


-
+

{%- if election.is_vote_active %} {% trans %}Polls close {% endtrans %} @@ -256,35 +38,49 @@ th {

{%- endif %}
-
+
{% csrf_token %} - +
{%- set election_lists = election.election_lists.all() -%} - - - {%- for election_list in election_lists %} - - {%- endfor %} + + + + {%- for election_list in election_lists %} + + {%- endfor %} + {%- set role_list = election.roles.order_by('order').all() %} {%- for role in role_list %} {%- set count = [0] %} {%- set role_data = election_form.data.getlist(role.title) if role.title in election_form.data else [] %} - - + - {%- for election_list in election_lists %} -
{% trans %}Blank vote{% endtrans %} - {{ election_list.title }} - {% if user.can_edit(election_list) and election.is_vote_editable -%} - - {% trans %}Delete{% endtrans %} - {% endif %} -
{% trans %}Blank vote{% endtrans %} + {{ election_list.title }} + {% if user.can_edit(election_list) and election.is_vote_editable -%} + + {% endif %} +
- {{ role.title }} +
+
+

{{ role.title }}

+

{{ role.description }}

+ {%- if role.max_choice > 1 and not election.has_voted(user) and election.can_vote(user) %} + {% trans %}You may choose up to{% endtrans %} {{ role.max_choice }} {% trans %}people.{% endtrans %} + {%- endif %} + + {%- if election_form.errors[role.title] is defined %} + {%- for error in election_form.errors.as_data()[role.title] %} + {{ error.message }} + {%- endfor %} + {%- endif %} +
{% if user.can_edit(role) and election.is_vote_editable -%} - {% trans %}Edit{% endtrans %} - {% trans %}Delete{% endtrans %} - +
+ ✏️ + {%- if role == role_list.last() %} @@ -299,27 +95,19 @@ th { {% endif %} - +
{%- endif -%} -

{{ role.description }}

- {%- if role.max_choice > 1 and not election.has_voted(user) and election.can_vote(user) %} -
- {% trans %}You may choose up to{% endtrans %} {{ role.max_choice }} {% trans %}people.{% endtrans %} - {%- endif %} - {%- if election_form.errors[role.title] is defined %} - {%- for error in election_form.errors.as_data()[role.title] %} - {{ error.message }} - {%- endfor %} - {%- endif %}
+ {%- if role.max_choice == 1 and election.can_vote(user) %} - - +
+ + +
{%- set _ = count.append(count.pop() + 1) %} {%- endif %} {%- if election.is_vote_finished %} @@ -330,36 +118,39 @@ th { {%- endif %}
-
    +
+
    {%- for candidature in election_list.candidatures.filter(role=role) %} -
  • -
    -
    - {%- if candidature.user.profile_pict and user.is_subscriber_viewable %} - {% trans %}Profile{% endtrans %} - {%- endif %} -
    -
    - {{ candidature.user.first_name }} {{candidature.user.nick_name or ''}} {{ candidature.user.last_name }} - {%- if user.can_edit(candidature) -%} - {% if election.is_vote_editable %} - {% trans %}Edit{% endtrans %} - {% endif %} - {% if election.is_vote_editable -%} - {% trans %}Delete{% endtrans %} - {%- endif -%} - {%- endif -%} - {%- if not election.is_vote_finished %} - {{ candidature.program | markdown or '' }} - {%- endif %} -
    -
    +
  • {%- if election.can_vote(user) %} - - + + {%- set _ = count.append(count.pop() + 1) %} {%- endif %} {%- if election.is_vote_finished %} @@ -379,39 +170,40 @@ th {
- {%- if not election.has_voted(user) and election.can_vote(user) %} -
- -
- {%- endif %} -
+
{%- if (election.can_candidate(user) and election.is_candidature_active) or (user.can_edit(election) and election.is_vote_editable) %} - {% trans %}Candidate{% endtrans %} + {% trans %}Candidate{% endtrans %} {%- endif %} {%- if election.is_vote_editable %} - {% trans %}Add a new list{% endtrans %} + {% trans %}Add a new list{% endtrans %} {%- endif %} {%- if user.can_edit(election) %} {% if election.is_vote_editable %} - {% trans %}Add a new role{% endtrans %} + {% trans %}Add a new role{% endtrans %} {% endif %} - {% trans %}Edit{% endtrans %} + {% trans %}Edit{% endtrans %} {%- endif %} {%- if user.is_root %} - {% trans %}Delete{% endtrans %} + {% trans %}Delete{% endtrans %} {%- endif %}
+ {%- if not election.has_voted(user) and election.can_vote(user) %} +
+ +
+ {%- endif %} {% endblock %} {% block script %} {{ super() }}