From 5b86c09311218e05c9204e9f8c5985346a62bfd2 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Thu, 30 Apr 2020 00:38:09 +0200 Subject: [PATCH 1/9] =?UTF-8?q?P=C5=99ejmenov=C3=A1ny=20star=C3=A9=20testy?= =?UTF-8?q?,=20aby=20mi=20nepadalo=20./manage.py=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/{tests.py => old_tests.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename seminar/{tests.py => old_tests.py} (100%) diff --git a/seminar/tests.py b/seminar/old_tests.py similarity index 100% rename from seminar/tests.py rename to seminar/old_tests.py From 8bdfa745e90eb619037c13a56d2455f7b321c67b Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Thu, 30 Apr 2020 00:41:12 +0200 Subject: [PATCH 2/9] =?UTF-8?q?Za=C4=8D=C3=A1tek=20test=C5=AF=20TreeLib?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/tests_treelib.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 seminar/tests_treelib.py diff --git a/seminar/tests_treelib.py b/seminar/tests_treelib.py new file mode 100644 index 00000000..9c67ca22 --- /dev/null +++ b/seminar/tests_treelib.py @@ -0,0 +1,32 @@ +from django.test import TestCase +import seminar.treelib as tl +import seminar.models as m + +class SimpleTreeLibTests(TestCase): + def setUp(self): + # Vyrobíme pár nějakých Nodů + self.root = m.CastNode(root=None, first_child=None, succ=None, nadpis="Root") + self.root.save() + self.some_node = m.CastNode(root=self.root, first_child=None, succ=None, nadpis="Přetržené") + self.other_node = m.CastNode(root=self.root, first_child=None, succ=None, nadpis="Dítě") + self.some_orphan = m.CastNode(root=None, first_child=None, succ=None, nadpis="Ošklivé") + self.other_orphan = m.CastNode(root=None, first_child=None, succ=None, nadpis="Káčátko") + + # Trochu je pospojujeme + self.root.first_child = self.some_node + self.some_node.succ = self.other_node + self.some_orphan.first_child = self.other_orphan + + # Všechno uložíme + self.other_node.save() + self.some_node.save() + self.other_orphan.save() + self.some_orphan.save() + self.root.save() + + def test_safe_functions(self): + self.assertEqual(tl.safe_pred(self.other_node), self.some_node) + self.assertIsNone(tl.safe_pred(self.root)) + self.assertIsNone(tl.safe_pred(self.some_node)) + self.assertIsNone(tl.safe_pred(self.some_orphan)) + self.assertIsNone(tl.safe_pred(self.other_orphan)) From 14400a2465c3cd23026bc3c229f97ff9885ec6bf Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Thu, 30 Apr 2020 01:27:24 +0200 Subject: [PATCH 3/9] =?UTF-8?q?Otestov=C3=A1na=20i=20druh=C3=A1=20safe=20f?= =?UTF-8?q?unkce=20(aspo=C5=88=20tro=C5=A1ku)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/tests_treelib.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/seminar/tests_treelib.py b/seminar/tests_treelib.py index 9c67ca22..3245d0a6 100644 --- a/seminar/tests_treelib.py +++ b/seminar/tests_treelib.py @@ -25,8 +25,16 @@ class SimpleTreeLibTests(TestCase): self.root.save() def test_safe_functions(self): + # safe_pred self.assertEqual(tl.safe_pred(self.other_node), self.some_node) self.assertIsNone(tl.safe_pred(self.root)) self.assertIsNone(tl.safe_pred(self.some_node)) self.assertIsNone(tl.safe_pred(self.some_orphan)) self.assertIsNone(tl.safe_pred(self.other_orphan)) + + # safe_father_of_first + self.assertIsNone(tl.safe_father_of_first(self.root)) + self.assertEqual(tl.safe_father_of_first(self.some_node), self.root) + self.assertEqual(tl.safe_father_of_first(self.other_node), self.root) + self.assertIsNone(tl.safe_father_of_first(self.some_orphan)) + self.assertEqual(tl.safe_father_of_first(self.other_orphan), self.some_orphan) From f52b89f5139b7807e8127e74eb33ebbefb3897a7 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Wed, 6 May 2020 19:51:33 +0200 Subject: [PATCH 4/9] =?UTF-8?q?M=C3=ADsto=20ulo=C5=BEen=C3=AD=20n=C3=A1hle?= =?UTF-8?q?du=20titulky=20v=20separ=C3=A1tn=C3=AD=20migraci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/migrations/0082_auto_20200506_1951.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 seminar/migrations/0082_auto_20200506_1951.py diff --git a/seminar/migrations/0082_auto_20200506_1951.py b/seminar/migrations/0082_auto_20200506_1951.py new file mode 100644 index 00000000..3132c434 --- /dev/null +++ b/seminar/migrations/0082_auto_20200506_1951.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.12 on 2020-05-06 17:51 + +from django.db import migrations, models +import seminar.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0081_auto_20200408_2221'), + ] + + operations = [ + migrations.AlterField( + model_name='cislo', + name='titulka_nahled', + field=models.ImageField(blank=True, help_text='Obrázek titulní strany, generuje se automaticky', null=True, upload_to=seminar.models.cislo_png_filename, verbose_name='Obrázek titulní strany'), + ), + ] From 86f2e494c2b18f21c307e347ad1fd0d9b9619865 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Wed, 6 May 2020 19:52:27 +0200 Subject: [PATCH 5/9] TreeNode: first_child je 1-2-1-Field, ne FK. --- seminar/migrations/0083_auto_20200506_1952.py | 19 +++++++++++++++++++ seminar/models.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 seminar/migrations/0083_auto_20200506_1952.py diff --git a/seminar/migrations/0083_auto_20200506_1952.py b/seminar/migrations/0083_auto_20200506_1952.py new file mode 100644 index 00000000..0c7fcf38 --- /dev/null +++ b/seminar/migrations/0083_auto_20200506_1952.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.12 on 2020-05-06 17:52 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0082_auto_20200506_1951'), + ] + + operations = [ + migrations.AlterField( + model_name='treenode', + name='first_child', + field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='father_of_first', to='seminar.TreeNode', verbose_name='první potomek'), + ), + ] diff --git a/seminar/models.py b/seminar/models.py index 57d4304a..43d6e59d 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -1246,7 +1246,7 @@ class TreeNode(PolymorphicModel): blank = False, on_delete = models.SET_NULL, # Vrcholy s null kořenem jsou sirotci bez ročníku verbose_name="kořen stromu") - first_child = models.ForeignKey('TreeNode', + first_child = models.OneToOneField('TreeNode', related_name='father_of_first', null = True, blank = True, From fb40de121f1f25eba1a100d86abbefe58521bfec Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Thu, 7 May 2020 00:55:21 +0200 Subject: [PATCH 6/9] =?UTF-8?q?Zru=C5=A1en=20unicodecsv.py,=20opraven=20So?= =?UTF-8?q?ust=C5=99e=C4=8Fkov=C3=BD=20export=20=C3=BA=C4=8Dastn=C3=ADk?= =?UTF-8?q?=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/views/unicodecsv.py | 62 ------------------------------------- seminar/views/views_all.py | 6 ++-- 2 files changed, 3 insertions(+), 65 deletions(-) delete mode 100644 seminar/views/unicodecsv.py diff --git a/seminar/views/unicodecsv.py b/seminar/views/unicodecsv.py deleted file mode 100644 index 4c38f6b5..00000000 --- a/seminar/views/unicodecsv.py +++ /dev/null @@ -1,62 +0,0 @@ -import csv, codecs -from io import StringIO - -class UTF8Recoder: - """ - Iterator that reads an encoded stream and reencodes the input to UTF-8 - """ - def __init__(self, f, encoding): - self.reader = codecs.getreader(encoding)(f) - - def __iter__(self): - return self - - def next(self): - return self.reader.next().encode("utf-8") - -class UnicodeReader: - """ - A CSV reader which will iterate over lines in the CSV file "f", - which is encoded in the given encoding. - """ - - def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwds): - f = UTF8Recoder(f, encoding) - self.reader = csv.reader(f, dialect=dialect, **kwds) - - def next(self): - row = self.reader.next() - return [unicode(s, "utf-8") for s in row] - - def __iter__(self): - return self - -class UnicodeWriter: - """ - A CSV writer which will write rows to CSV file "f", - which is encoded in the given encoding. - """ - - def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwds): - # Redirect output to a queue - self.queue = cStringIO.StringIO() - self.writer = csv.writer(self.queue, dialect=dialect, **kwds) - self.stream = f - self.encoder = codecs.getincrementalencoder(encoding)() - - def writerow(self, row): - self.writer.writerow([s.encode("utf-8") for s in row]) - # Fetch UTF-8 output from the queue ... - data = self.queue.getvalue() - data = data.decode("utf-8") - # ... and reencode it into the target encoding - data = self.encoder.encode(data) - # write to the target stream - self.stream.write(data) - # empty queue - self.queue.truncate(0) - - def writerows(self, rows): - for row in rows: - self.writerow(row) - diff --git a/seminar/views/views_all.py b/seminar/views/views_all.py index ab38bc58..c17ef7bf 100644 --- a/seminar/views/views_all.py +++ b/seminar/views/views_all.py @@ -20,7 +20,6 @@ import seminar.models as s from seminar.models import Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Organizator, Resitel, Novinky, Soustredeni_Ucastnici, Pohadka, Tema, Clanek, Osoba, Skola # Tohle je stare a chceme se toho zbavit. Pouzivejte s.ToCoChci #from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva from seminar import utils,treelib -from .unicodecsv import UnicodeWriter from seminar.forms import PrihlaskaForm, LoginForm, ProfileEditForm import seminar.forms as f @@ -955,10 +954,11 @@ def soustredeniUcastniciExportView(request,soustredeni): response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename="ucastnici.csv"' - writer = UnicodeWriter(response) + writer = csv.writer(response) writer.writerow(["jmeno", "prijmeni", "rok_maturity", "telefon", "email", "ulice", "mesto", "psc","stat"]) for u in ucastnici: - writer.writerow([u.jmeno, u.prijmeni, str(u.rok_maturity), u.telefon, u.email, u.ulice, u.mesto, u.psc, u.stat.name]) + o = u.osoba + writer.writerow([o.jmeno, o.prijmeni, str(u.rok_maturity), o.telefon, o.email, o.ulice, o.mesto, o.psc, o.stat.name]) return response From 18bb451bcf322058624723354ec09082dcbd546e Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Thu, 7 May 2020 01:03:53 +0200 Subject: [PATCH 7/9] =?UTF-8?q?Mezi=20ulic=C3=AD=20a=20=C4=8D=C3=ADslem=20?= =?UTF-8?q?popisn=C3=BDm=20m=C3=A1=20b=C3=BDt=20mezera?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/testutils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seminar/testutils.py b/seminar/testutils.py index 18319546..3c4356a2 100644 --- a/seminar/testutils.py +++ b/seminar/testutils.py @@ -78,7 +78,7 @@ def gen_osoby(rnd, size): rnd.randint(1, 28)) ulic = rnd.choice(seznam_ulic) cp = rnd.randint(1, 99) - ulice = "".join([ulic, str(cp)]) + ulice = " ".join([ulic, str(cp)]) mesto = rnd.choice(seznam_mest) psc = "".join([str(rnd.choice([k for k in range(10)])) for i in range(5)]) From f5b99aac4769308f5aa4edbd67b2744031b4153d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kate=C5=99ina=20=C4=8C=C3=AD=C5=BEkov=C3=A1?= Date: Wed, 13 May 2020 21:35:18 +0200 Subject: [PATCH 8/9] =?UTF-8?q?vzhled=20v=C5=A1emo=C5=BEn=C3=BDch=20formul?= =?UTF-8?q?=C3=A1=C5=99=C5=AF,=20opravy=20oto=C4=8Dn=C3=BDch=20karet=20na?= =?UTF-8?q?=20mobilu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mamweb/static/css/mamweb.css | 44 ++++++++++++++++++- .../seminar/cojemam/organizatori.html | 2 +- seminar/templates/seminar/login.html | 14 +++++- .../templates/seminar/prihlaska_field.html | 9 ++-- 4 files changed, 59 insertions(+), 10 deletions(-) diff --git a/mamweb/static/css/mamweb.css b/mamweb/static/css/mamweb.css index dc942cc2..a9621bc5 100644 --- a/mamweb/static/css/mamweb.css +++ b/mamweb/static/css/mamweb.css @@ -7,6 +7,7 @@ font-weight: normal; body { font-family: 'OpenSans'; background-color: #fffbf6; + min-height: 100%; } div.container { @@ -296,7 +297,7 @@ ul.submenu { ul.submenu { background-color: #e84e10; - z-index: 5; + z-index: 50; font-weight: 400; } @@ -439,6 +440,10 @@ ul.submenu { ul.submenu { margin-top: 8px; /* mezera mezi hlavním menu a submenu */ } + + a.ref-org-foto { + pointer-events: none; + } } /* malý tablet, mobil */ @@ -564,6 +569,7 @@ ul.submenu { display: block; } + /*patička mobil*/ #footer { @@ -947,3 +953,39 @@ p.gdpr { div.gdpr { font-size: 6pt; } + +/* přihláška a další formuláře */ + +table.form td, table.form tr { + table-layout: fixed; + word-wrap: break-word; + padding: 5px; +} + +.field-with-comment{ + position:relative; +} + +.field-comment{ + display:none; + text-shadow: 0 1px 0 #fff; + background-color: #f0f0f0 ; + border-color: #dbdbdb; + position:absolute; + z-index:100; + border:1px; + border-style:solid; + border-width:1px; + border-radius: 5px; + padding:3px; + top:20px; + left:20px; +} + +.field-with-comment:hover span.field-comment{ + display:block; +} + +input { + margin: 5px; +} diff --git a/seminar/templates/seminar/cojemam/organizatori.html b/seminar/templates/seminar/cojemam/organizatori.html index a3957101..5b147aa5 100644 --- a/seminar/templates/seminar/cojemam/organizatori.html +++ b/seminar/templates/seminar/cojemam/organizatori.html @@ -53,7 +53,7 @@
{% if org.osoba.foto %} - {{org.osoba.jmeno}} {{org.osoba.prijmeni}} + {{org.osoba.jmeno}} {{org.osoba.prijmeni}} {% else %} {# pokud osoba nemá fotku, zobrazuje se defaultní obrázek #} {% load static %} {{org.osoba.jmeno}} {{org.osoba.prijmeni}} {% endif %} diff --git a/seminar/templates/seminar/login.html b/seminar/templates/seminar/login.html index 9769a41a..0263b9a6 100644 --- a/seminar/templates/seminar/login.html +++ b/seminar/templates/seminar/login.html @@ -18,8 +18,18 @@ -Zapomněl jsem heslo
-Zaregistrovat
+
+ +
+ +
+

+ Ješte nejste zaregistrováni? +

+ +
+ +
{% endblock %} diff --git a/seminar/templates/seminar/prihlaska_field.html b/seminar/templates/seminar/prihlaska_field.html index 04ecf145..8344a683 100644 --- a/seminar/templates/seminar/prihlaska_field.html +++ b/seminar/templates/seminar/prihlaska_field.html @@ -4,17 +4,14 @@ + - + {{ field }} + {{ field.help_text|safe }} -{% if field.help_text %} - - {{ field.help_text|safe }} - -{% endif %} {% if field.errors %} From 90dfbab82d9b9de294d8ab56bd30568853df17e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kate=C5=99ina=20=C4=8C=C3=AD=C5=BEkov=C3=A1?= Date: Wed, 13 May 2020 22:23:05 +0200 Subject: [PATCH 9/9] =?UTF-8?q?submitov=C3=A1tko=20drobnosti=20vzhledu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/templates/seminar/nahraj_reseni.html | 24 +++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/seminar/templates/seminar/nahraj_reseni.html b/seminar/templates/seminar/nahraj_reseni.html index 7e3d1e72..d95f8567 100644 --- a/seminar/templates/seminar/nahraj_reseni.html +++ b/seminar/templates/seminar/nahraj_reseni.html @@ -14,31 +14,39 @@
{% csrf_token %} -{{form}} -{{prilohy.management_form}} +{{ form }} +{{ prilohy.management_form }} + + +

Přilohy s řešením

+
{% for form in prilohy.forms %}
- {{form.non_field_errors}} - {{form.errors}} + {{ form.non_field_errors }} + {{ form.errors }} {{ form }}
- +
{% endfor %}
+ + - + +
+

Odevzdat má řešení

+
{% endblock %}