Browse Source

Merge branch 'data_migrations' into treenode_editor

export_seznamu_prednasek
parent
commit
5d17bcfc8e
  1. 44
      mamweb/static/css/mamweb.css
  2. 0
      seminar/old_tests.py
  3. 2
      seminar/templates/seminar/cojemam/organizatori.html
  4. 14
      seminar/templates/seminar/login.html
  5. 24
      seminar/templates/seminar/nahraj_reseni.html
  6. 9
      seminar/templates/seminar/prihlaska_field.html
  7. 40
      seminar/tests_treelib.py
  8. 2
      seminar/testutils.py
  9. 62
      seminar/views/unicodecsv.py
  10. 6
      seminar/views/views_all.py

44
mamweb/static/css/mamweb.css

@ -7,6 +7,7 @@ font-weight: normal;
body { body {
font-family: 'OpenSans'; font-family: 'OpenSans';
background-color: #fffbf6; background-color: #fffbf6;
min-height: 100%;
} }
div.container { div.container {
@ -296,7 +297,7 @@ ul.submenu {
ul.submenu { ul.submenu {
background-color: #e84e10; background-color: #e84e10;
z-index: 5; z-index: 50;
font-weight: 400; font-weight: 400;
} }
@ -439,6 +440,10 @@ ul.submenu {
ul.submenu { ul.submenu {
margin-top: 8px; /* mezera mezi hlavním menu a submenu */ margin-top: 8px; /* mezera mezi hlavním menu a submenu */
} }
a.ref-org-foto {
pointer-events: none;
}
} }
/* malý tablet, mobil */ /* malý tablet, mobil */
@ -564,6 +569,7 @@ ul.submenu {
display: block; display: block;
} }
/*patička mobil*/ /*patička mobil*/
#footer { #footer {
@ -947,3 +953,39 @@ p.gdpr {
div.gdpr { div.gdpr {
font-size: 6pt; 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;
}

0
seminar/tests.py → seminar/old_tests.py

2
seminar/templates/seminar/cojemam/organizatori.html

@ -53,7 +53,7 @@
<div class="flip-card-foto"> <div class="flip-card-foto">
{% if org.osoba.foto %} {% if org.osoba.foto %}
<a href="{{org.osoba.foto.url}}"><img src="{{org.osoba.foto_male.url}}" height="{{org.osoba.foto_male.height}}" alt="{{org.osoba.jmeno}} {{org.osoba.prijmeni}}"></a> <a href="{{org.osoba.foto.url}}" class="ref-org-foto"><img src="{{org.osoba.foto_male.url}}" height="{{org.osoba.foto_male.height}}" alt="{{org.osoba.jmeno}} {{org.osoba.prijmeni}}"></a>
{% else %} {# pokud osoba nemá fotku, zobrazuje se defaultní obrázek #} {% else %} {# pokud osoba nemá fotku, zobrazuje se defaultní obrázek #}
{% load static %} <img src="{% static 'images/no-photo.png' %}" height=200px alt="{{org.osoba.jmeno}} {{org.osoba.prijmeni}}"> {% load static %} <img src="{% static 'images/no-photo.png' %}" height=200px alt="{{org.osoba.jmeno}} {{org.osoba.prijmeni}}">
{% endif %} {% endif %}

14
seminar/templates/seminar/login.html

@ -18,8 +18,18 @@
<input type="submit" value="Přihlásit"> <input type="submit" value="Přihlásit">
</form> </form>
<a href="{% url 'reset_password' %}">Zapomněl jsem heslo</a><br> <form action="{% url 'reset_password' %}">
<a href="{% url 'seminar_prihlaska' %}">Zaregistrovat</a><br> <input type="submit" value="Zapomněl jsem heslo" />
</form>
<hr>
<h2>
Ješte nejste zaregistrováni?
</h2>
<form action="{% url 'seminar_prihlaska' %}">
<input type="submit" value="Registrovat" />
</form>
{% endblock %} {% endblock %}

24
seminar/templates/seminar/nahraj_reseni.html

@ -14,31 +14,39 @@
</h1> </h1>
<form enctype="multipart/form-data" action="{% url 'seminar_nahraj_reseni' %}" method="post"> <form enctype="multipart/form-data" action="{% url 'seminar_nahraj_reseni' %}" method="post">
{% csrf_token %} {% csrf_token %}
{{form}} {{ form }}
{{prilohy.management_form}} {{ prilohy.management_form }}
<h4>Přilohy s řešením</h4>
<div id="form_set"> <div id="form_set">
{% for form in prilohy.forms %} {% for form in prilohy.forms %}
<div class="attachment"> <div class="attachment">
{{form.non_field_errors}} {{ form.non_field_errors }}
{{form.errors}} {{ form.errors }}
<table class='no_error'> <table class='no_error'>
{{ form }} {{ form }}
</table> </table>
<input type="button" value="Odebrat" class="remove_attachment" id="{{form.prefix}}-jsremove"> <input type="button" value="Odebrat přílohu" class="remove_attachment" id="{{form.prefix}}-jsremove">
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<input type="button" value="Přidat přílohu" id="add_attachment"> <input type="button" value="Přidat přílohu" id="add_attachment">
<div id="empty_form" style="display:none"> <div id="empty_form" style="display:none">
<div class="attachment"> <div class="attachment">
<table class='no_error'> <table class='no_error'>
{{ prilohy.empty_form }} {{ prilohy.empty_form }}
</table> </table>
<input type="button" value="Odebrat" class="remove_attachment" id="id_prilohy-__prefix__-jsremove"> <input type="button" value="Odebrat přílohu" class="remove_attachment" id="id_prilohy-__prefix__-jsremove">
</div> </div>
</div> </div>
<input type="submit" value="Odevzdat">
<hr>
<h4>Odevzdat má řešení</h4>
<input type="submit" value="Odevzdat">
</form> </form>
{% endblock %} {% endblock %}

9
seminar/templates/seminar/prihlaska_field.html

@ -4,17 +4,14 @@
<label class="field-label{% if field.field.required %} field-required{% endif %}" for="{{ field.id_for_label }}"> <label class="field-label{% if field.field.required %} field-required{% endif %}" for="{{ field.id_for_label }}">
{{ field.label }}: {{ field.label }}:
</label> </label>
</td> </td>
<td> <td {% if field.help_text %} class="field-with-comment"{% endif %}>
{{ field }} {{ field }}
<span class="field-comment">{{ field.help_text|safe }}
</td> </td>
</tr> </tr>
{% if field.help_text %}
<tr>
<td colspan="2"><span class="field-helptext">{{ field.help_text|safe }}</span></td>
</tr>
{% endif %}
{% if field.errors %} {% if field.errors %}
<tr> <tr>

40
seminar/tests_treelib.py

@ -0,0 +1,40 @@
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):
# 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)

2
seminar/testutils.py

@ -78,7 +78,7 @@ def gen_osoby(rnd, size):
rnd.randint(1, 28)) rnd.randint(1, 28))
ulic = rnd.choice(seznam_ulic) ulic = rnd.choice(seznam_ulic)
cp = rnd.randint(1, 99) cp = rnd.randint(1, 99)
ulice = "".join([ulic, str(cp)]) ulice = " ".join([ulic, str(cp)])
mesto = rnd.choice(seznam_mest) mesto = rnd.choice(seznam_mest)
psc = "".join([str(rnd.choice([k for k in range(10)])) for i in range(5)]) psc = "".join([str(rnd.choice([k for k in range(10)])) for i in range(5)])

62
seminar/views/unicodecsv.py

@ -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)

6
seminar/views/views_all.py

@ -21,7 +21,6 @@ import seminar.models as m
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 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 .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva
from seminar import utils, treelib from seminar import utils, treelib
from .unicodecsv import UnicodeWriter
from seminar.forms import PrihlaskaForm, LoginForm, ProfileEditForm from seminar.forms import PrihlaskaForm, LoginForm, ProfileEditForm
import seminar.forms as f import seminar.forms as f
@ -1056,10 +1055,11 @@ def soustredeniUcastniciExportView(request,soustredeni):
response = HttpResponse(content_type='text/csv') response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename="ucastnici.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"]) writer.writerow(["jmeno", "prijmeni", "rok_maturity", "telefon", "email", "ulice", "mesto", "psc","stat"])
for u in ucastnici: 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 return response

Loading…
Cancel
Save