Skip to content
Snippets Groups Projects
Commit c8b0cee2 authored by Tomáš Valenta's avatar Tomáš Valenta
Browse files

Merge branch 'feat/rv-voting' into 'test'

Test release

See merge request !1
parents 37f9da80 8dc422f7
No related branches found
No related tags found
2 merge requests!2Release,!1Test release
Pipeline #11291 failed
Showing
with 236 additions and 29 deletions
......@@ -8,7 +8,7 @@ RUN apt-get install nodejs && rm -rf /var/lib/apt/lists/*
COPY . .
RUN pip install -r requirements/base.txt -r requirements/prod.txt
RUN pip install -r requirements/base.txt -r requirements/production.txt
RUN npm install
RUN npm run build
......@@ -16,14 +16,14 @@ RUN npm run build
RUN DATABASE_URL=postgres://x/x \
SECRET_KEY=x \
ALLOWED_HOSTS=x \
python manage.py collectstatic --noinput --settings=rybicka.settings.prod
python manage.py collectstatic --noinput --settings=rybicka.settings.production
RUN bash -c "adduser --disabled-login --quiet --gecos app app && \
chmod -R o+r /app/ && \
chmod o+x /app/run.sh"
USER app
ENV DJANGO_SETTINGS_MODULE "rybicka.settings.prod"
ENV DJANGO_SETTINGS_MODULE "rybicka.settings.production"
EXPOSE 8000
......
......@@ -3,7 +3,7 @@
PYTHON = python
VENV = .venv
PORT = 8012
SETTINGS = rybicka.settings.prod
SETTINGS = rybicka.settings.dev
.PHONY: help venv install build run shell migrations migrate
......@@ -26,7 +26,7 @@ venv: .venv/bin/python
${PYTHON} -m venv ${VENV}
install: venv
${VENV}/bin/pip install -r requirements/base.txt -r requirements/prod.txt
${VENV}/bin/pip install -r requirements/base.txt -r requirements/production.txt
${VENV}/bin/nodeenv --python-virtualenv --node=19.3.0
${VENV}/bin/npm install
......
......@@ -2,5 +2,8 @@ DATABASE_URL="postgresql://rybicka:rybicka@localhost:5432/rybicka"
SECRET_KEY="%@=^sip3=tqn6d_-xvvidc1@-t0t3&*kab@vr4c4"
CHOBOTNICE_API_URL="https://chobotnice.pirati.cz/graphql/"
CHOBOTNICE_RV_GID="R3JvdXBUeXBlOjYyNQ=="
# Production settings
ALLOWED_HOSTS="nastroje.pirati.cz"
ALLOWED_HOSTS="tools.pirati.cz"
......@@ -7,6 +7,11 @@
{% block description %}Výpočet velikosti skupiny členů podle jednoacího řádu.{% endblock %}
{% block head %}
<link
rel="stylesheet"
href="https://styleguide.pirati.cz/2.11.x/css/styles.css"
>
{% render_bundle "member_group_size_calc" %}
{% endblock %}
......@@ -15,17 +20,17 @@
<h1 class="text-6xl font-bebas mb-5">Kalkulačka velikosti skupiny členů</h1>
<div class="bg-amber-100 p-4 flex flex-row items-center gap-4 mb-4 lg:w-[768px] md:w-full">
<i class="fa-solid fa-lightbulb text-3xl text-amber-800"></i>
<i class="ico--book text-3xl text-amber-800"></i>
<div class="text-amber-800">
Tato kalkulačka slouží pro výpočet skupiny členů podle <a
class="underline text-amber-900"
href="https://wiki.pirati.cz/rules/jdr"
href="https://wiki.pirati.cz/rules/jdr#skupina_clenu"
>Jednacího řádu</a>.
</div>
</div>
<div class="bg-gray-100 p-4 flex flex-row items-start gap-4 mb-4 lg:w-[768px] md:w-full">
<i class="fa-solid fa-circle-info text-3xl text-gray-800"></i>
<i class="ico--info text-3xl text-gray-800"></i>
<div class="text-gray-800">
<h2 class="text-lg font-bold mb-3">Jednací řád celostátního fóra</h2>
......@@ -123,7 +128,7 @@
</div>
<p class="font-light">
<i>Vypočtené hodnoty jsou zaokrouhleny na celé číslo nahoru.</i>
<i>Vypočtené hodnoty se zaokrouhlují na celé osoby (nahoru).</i>
</p>
</main>
{% endblock %}
......@@ -4,9 +4,10 @@
"description": "",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-free": "^6.2.1",
"css-loader": "^6.7.3",
"jquery": "^3.6.3",
"js-cookie": "^3.0.1",
"select2": "^4.1.0-rc.0",
"style-loader": "^3.3.1",
"tailwindcss": "^3.2.4",
"webpack": "^5.75.0",
......
Django==4.1.5
django-database-url==1.0.3
django-environ==0.9.0
psycopg2-binary==2.9.5
django-webpack-loader==1.8.0
django-http-exceptions==1.4.0
gql[requests]==3.4.0
nodeenv==1.7.0
psycopg2-binary==2.9.5
requests==2.28.2
File moved
{% extends "shared/base.html" %}
{% load render_bundle from webpack_loader %}
{% block title %}Kalkulačka hlasování RV{% endblock %}
{% block header_name %}Hlasování RV{% endblock %}
{% block description %}TODO - Popis{% endblock %}
{% block head %}
{% render_bundle "rv_voting_calc" %}
{% endblock %}
{% block content %}
<main>
</main>
{% endblock %}
{% comment %}
It's fine to pass in |safe here, as the template variables have
already been sanitized once, as each step got rendered.
{% endcomment %}
{{ html_steps|safe }}
<div id="md-steps" class="hidden">
{% for md_step in md_steps %}
{{ md_step }}{% if not forloop.last %}
---
{% endif %}{% endfor %}
</div>
<li class="bg-green-200 drop-shadow-md p-4 font-semibold text-center text-xl">
Možnost {{ option_key }} vyhrává s {{ option.vote_count }} hlasy.
</li>
<li class="bg-gray-100 drop-shadow-md p-4">
<div class="pb-2 mb-2 border-b border-gray-300">
<h2 class="text-2xl font-semibold font-bebas">Počáteční rozdělení</h2>
<small class="text-sm">
<strong>{{ total_ticket_count }}</strong> lístků,
hranice pro nadpoloviční podporu <strong>{{ has_support_treshold }}</strong>
</small>
</div>
{% include "rv_voting_calc/includes/option_list.html" with options=options options_by_member=options_by_member show_proposers=True show_has_support=True %}
</li>
<li class="bg-red-200 drop-shadow-md p-4 font-semibold text-center text-xl">
Ani jedna možnost nevyhrává.
</li>
{% load index %}
<li class="bg-gray-100 drop-shadow-md p-4">
<div class="pb-2 mb-3 border-b border-gray-300">
<h2 class="text-2xl font-semibold font-bebas">{{ iteration|add:1 }}. vyřazovací kolo</h2>
</div>
<p class="mb-2 text-red-600 font-semibold">
Možnost {{ option_key }} bude {% if randomly %}losováním{% else %}kvůli nepopularitě{% endif %} odstraněna
</p>
{% include "rv_voting_calc/includes/option_list.html" with options=options options_by_member=options_by_member show_proposers=True show_marked_for_deletion=True %}
</li>
<li class="bg-gray-100 drop-shadow-md p-4">
<div class="pb-2 mb-2 border-b border-gray-300">
<h2 class="text-2xl font-semibold font-bebas">Po vyřazení možností bez nadpoloviční podpory</h2>
</div>
{% if options_with_support_count != 0 %}
{% include "rv_voting_calc/includes/option_list.html" with options=options options_by_member=options_by_member %}
{% else %}
<p class="text-gray-800 mt-3">Žádné možnosti nemají nadpoloviční podporu.</p>
{% endif %}
</li>
{% load index %}
<ul class="flex flex-col gap-2">
{% for option_key, option in options.items %}
{% if not option.marked_for_deletion or show_marked_for_deletion %}
{% if option.has_support or show_has_support %}
<h3 class="flex gap-2 items-end text-xl font-semibold {% if option.marked_for_deletion or not option.has_support %}text-red-600{% endif %}">
{{ option_key }}
<span class="text-sm {% if option.marked_for_deletion or not option.has_support %}text-red-600{% else %}text-gray-600{% endif %}">
{{ option.ticket_count }} lístků, {{ option.vote_count }} hlasů
</span>
{% if show_has_support and not option.has_support %}
<span class="text-sm text-red-600">(Nemá nadpoloviční podporu)</span>
{% endif %}
</h3>
{% if option.ticket_votes|length != 0 %}
<ul class="flex gap-3 mt-1 flex-wrap">
{% for vote in option.ticket_votes %}
{% if not vote.hidden %}
<li class="flex">
<div class="px-4 py-2 {% if not option.marked_for_deletion and option.has_support %}bg-gray-300{% else %}bg-red-300{% endif %}">
{{ rv_members|index:vote.member|index:"displayName" }}
</div>
<ul class="px-4 py-2 flex gap-1 {% if not option.marked_for_deletion and option.has_support %}bg-gray-200{% else %}bg-red-200{% endif %}">
{% for option in options_by_member|index:vote.member %}
<li>{{ option }}{% if not forloop.last %}, {% endif %}</li>
{% endfor %}
</ul>
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
</ul>
{% load index %}
{% for option_key, option in options.items %}{% if not option.marked_for_deletion or show_marked_for_deletion %}{% if option.has_support or show_has_support %}
- **Možnost {{ option_key }}** - {{ option.ticket_count }} lístků, {{ option.vote_count }} hlasů.{% if show_has_support and not option.has_support %} *(Nemá nadpoloviční podporu)*{% endif %}{% if option.marked_for_deletion or not option.has_support %} *(K odstranění)*{% endif %}{% if option.ticket_votes|length != 0 %} Volby: {% for vote in option.ticket_votes %}{% if not vote.hidden %}
- **{{ rv_members|index:vote.member|index:"displayName" }}** - přijatelné možnosti:{% for option in options_by_member|index:vote.member %}
- {{ option }}{% endfor %}{% endif %}{% endfor %}{% endif %}{% endif %}{% endif %}{% endfor %}
{% extends "shared/base.html" %}
{% load render_bundle from webpack_loader %}
{% block title %}Kalkulačka hlasování RV{% endblock %}
{% block header_name %}Hlasování RV{% endblock %}
{% block description %}TODO - Popis{% endblock %}
{% block head %}
{% render_bundle "rv_voting_calc" %}
<link
href="https://styleguide.pirati.cz/2.10.x/css/styles.css"
rel="stylesheet"
media="all"
>
<link
href="https://styleguide.pirati.cz/2.10.x/css/pattern-scaffolding.css"
rel="stylesheet"
media="all"
>
{% endblock %}
{% block content %}
<main>
<h1 class="text-6xl font-bebas mb-5">Kalkulačka hlasování RV</h1>
<div class="grid grid-cols-1 md:grid-cols-2 gap-7 mb-5 pb-4 items-center border-b border-gray-100">
<h2 class="text-2xl font-bebas">Hlasy členů</h2>
<div class="flex items-center gap-3 justify-between">
<h2 class="text-2xl font-bebas">Výsledky</h2>
<button
class="btn disabled:cursor-progress"
id="count-votes"
{% if not options_by_member %}disabled{% endif %}
>
<div class="btn__body">
Vypočítat
</div>
</button>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-7">
<ul class="flex flex-col gap-2">
{% for member in rv_members %}
<li class="flex gap-4 items-center">
<div class="basis-56 flex items-center">
<i class="ico--user text-xl mr-2"></i>
{{ member.displayName }}
</div>
<select
id="{{ member.username }}-selection"
class="__vote-selection grow w-full"
multiple="multiple"
></select>
</li>
{% endfor %}
</ul>
<div>
<ul
class="flex flex-col gap-5"
id="result"
>
</ul>
<div class="mt-4 flex gap-4 md:justify-end justify-center">
<a
class="hidden btn"
id="permalink"
href=""
><div class="btn__body">Permalink</div></a>
<a
class="hidden btn"
id="download-log"
download="kroky.md"
href=""
><div class="btn__body">Stáhnout log</div></a>
</div>
</div>
</div>
</main>
{{ keyed_rv_members|json_script:"rv-members" }}
<script>
const VOTE_CALCULATION_ENDPOINT = "{% url "rv_voting_calc:get_calculated_votes" %}"
{% if options_by_member %}
{% for member, selected_options in options_by_member.items %}
{% for selected_option in selected_options %}
$(`#${$.escapeSelector("{{ member}}")}-selection`).append(
new Option(
"{{ selected_option }}",
"{{ selected_option }}",
true,
true,
)
);
{% endfor %}
$(`#${$.escapeSelector("{{ member}}")}-selection`).trigger("change");
{% endfor %}
{% endif %}
</script>
{% endblock %}
**Možnost {{ option_key }} vyhrává s {{ option.vote_count }} hlasy.**
# Počáteční rozdělení
**{{ total_ticket_count }}** lístků, hranice pro nadpoloviční podporu **{{ has_support_treshold }}**.
{% include "rv_voting_calc/includes/option_list.md" with options=options options_by_member=options_by_member show_proposers=True show_has_support=True %}
**Ani jedna možnost nevyhrává.**
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