diff --git a/Vagrantfile b/Vagrantfile index af9ad85..10e9410 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -4,7 +4,13 @@ $msg_up = < 0 else "" return render_template('editpoll.html', poll_id=poll_id, name=name, options=options, choice_type=choice_type, possible_recipients=possible_recipients, sending_out_to_amount=sending_out_to_amount, - closes_on_date=closes_on_date, mail_template=mail_template, should_disable=should_disable, + closes_on_date=closes_on_date.strftime("%Y-%m-%d %H:%M"), mail_template=mail_template, should_disable=should_disable, max_choices=max_choices, description=description) @app.route('/admin/editpoll', methods=['POST']) @@ -454,21 +457,28 @@ def admin_results(): return "Głosowanie nie istnieje", 400 name, options, max_choices, possible_recipients_len, sending_out_to_len, sent_to_len = row print(f"ilosc opcji :{ max_choices}") - vote_results = result_getter(poll_id, max_choices) - - voted_len = int(subprocess.Popen(['du', '--inodes', '-sS', f"/opt/sw/poll/{poll_id}/results/"], stdout=subprocess.PIPE).stdout.read().decode('utf8').split('\t')[0]) - 1 results = [] - for i, option in enumerate(options): - results.append({ 'score': vote_results.get(f"option_{i}", 0), 'name': option['name'], 'description': option['description'] }) + + try: + vote_results = result_getter(poll_id, max_choices) + + voted_len = int(subprocess.Popen(['du', '--inodes', '-sS', f"/opt/sw/poll/{poll_id}/results/"], stdout=subprocess.PIPE).stdout.read().decode('utf8').split('\t')[0]) - 1 + + + for i, option in enumerate(options): + results.append({ 'score': vote_results.get(f"option_{i}", 0), 'name': option['name'], 'description': option['description'] }) + except: + return "Nikt nie zagłosował v Brak plików", 400 + return render_template('results.html', - name=name, - possible_recipients_len=possible_recipients_len, - sending_out_to_len=sending_out_to_len, - sent_to_len=sent_to_len, - voted_len=voted_len, - results=results) + name=name, + possible_recipients_len=possible_recipients_len, + sending_out_to_len=sending_out_to_len, + sent_to_len=sent_to_len, + voted_len=voted_len, + results=results) @app.route('/admin/peek', methods=['GET']) @login_required diff --git a/sw-database/schema.sql b/sw-database/schema.sql index 70d164f..0bed59b 100644 --- a/sw-database/schema.sql +++ b/sw-database/schema.sql @@ -57,8 +57,7 @@ create table polls( -- Czas kiedy głosowanie się kończy -- Format: "YYYY-MM-DD hh:mm" -- Na przykład: "2022-01-01 13:30" - -- Issue na zmianę typu na `timestamp with time zone`: https://github.com/informatyzacja-sspwr-projekty/SWv2/issues/10 - closes_on_date text not null, + closes_on_date timestamptz not null, -- Czy sw-mailsender wysyła maile z `sending_out_to`? mailing_active boolean default false not null, @@ -83,5 +82,5 @@ create table polls( -- Jeżeli wartość nie jest NULL, o danej godzinie głosowanie zostanie rozpocząte -- (między innymi ustawiając `mailing_active` na true) - planned_start_sending timestamp with time zone + planned_start_sending timestamptz not null );