@ -0,0 +1,12 @@ |
|||||
|
|
||||
|
from datetime import datetime, date |
||||
|
|
||||
|
def vzhled(request): |
||||
|
''' Podle casu prida do templatu, zdali je nebo neni noc ''' |
||||
|
hodin = datetime.now().hour |
||||
|
if (hodin <= 6) or (hodin >= 20): |
||||
|
noc = True |
||||
|
else: |
||||
|
noc = False |
||||
|
return {'noc' : noc} |
||||
|
|
@ -0,0 +1,84 @@ |
|||||
|
from datetime import datetime, date |
||||
|
|
||||
|
from django.conf import settings |
||||
|
from django.http import HttpResponse, HttpResponseRedirect |
||||
|
|
||||
|
|
||||
|
|
||||
|
class LoggedInHintCookieMiddleware(object): |
||||
|
"""Middleware to securely help with 'logged-in' detection for dual HTTP/HTTPS sites. |
||||
|
|
||||
|
On insecure requests: Checks for a (non-secure) cookie settings.LOGGED_IN_HINT_COOKIE_NAME |
||||
|
and if present, redirects to HTTPS (same adress). |
||||
|
Note this usually breaks non-GET (POST) requests. |
||||
|
|
||||
|
On secure requests: Updates cookie settings.LOGGED_IN_HINT_COOKIE_NAME to reflect |
||||
|
whether an user is logged in in the current session (cookie set to 'True' or cleared). |
||||
|
The cookie is set to expire at the same time as the sessionid cookie. |
||||
|
|
||||
|
By default, LOGGED_IN_HINT_COOKIE_NAME = 'logged_in_hint'. |
||||
|
""" |
||||
|
|
||||
|
def __init__(self): |
||||
|
if hasattr(settings, 'LOGGED_IN_HINT_COOKIE_NAME'): |
||||
|
self.cookie_name = settings.LOGGED_IN_HINT_COOKIE_NAME |
||||
|
else: self.cookie_name = 'logged_in_hint' |
||||
|
self.cookie_value = 'True' |
||||
|
|
||||
|
def cookie_correct(self, request): |
||||
|
return self.cookie_name in request.COOKIES and request.COOKIES[self.cookie_name] == self.cookie_value |
||||
|
|
||||
|
def process_request(self, request): |
||||
|
if not request.is_secure(): |
||||
|
if self.cookie_correct(request): |
||||
|
# redirect insecure (assuming http) requests with hint cookie to https |
||||
|
url = HttpRequest.build_absolute_uri() |
||||
|
assert url[:5] == 'http:' |
||||
|
return HttpResponseRedirect('https:' + url[5:]) |
||||
|
return None |
||||
|
|
||||
|
def process_response(self, request, response): |
||||
|
if request.is_secure(): |
||||
|
# assuming full session info (as the conn. is secure) |
||||
|
if request.user.is_authenticated(): |
||||
|
if not self.cookie_correct(request): |
||||
|
expiry = None if request.session.get_expire_at_browser_close() else request.session.get_expiry_date() |
||||
|
response.set_cookie(self.cookie_name, value=self.cookie_value, expires=expiry, secure=False) |
||||
|
else: |
||||
|
if self.cookie_name in request.COOKIES: |
||||
|
response.delete_cookie(self.cookie_name) |
||||
|
return response |
||||
|
|
||||
|
|
||||
|
class vzhled: |
||||
|
|
||||
|
def process_request(self, request): |
||||
|
return None |
||||
|
|
||||
|
def process_view(self, request, view_func, view_args, view_kwargs): |
||||
|
#print "====== process_request ======" |
||||
|
#print view_func |
||||
|
#print view_args |
||||
|
#print view_kwargs |
||||
|
#print "=============================" |
||||
|
return None |
||||
|
|
||||
|
def process_template_response(self, request, response): |
||||
|
hodin = datetime.now().hour |
||||
|
if (hodin <= 6) or (hodin >= 14): # TODO 20 |
||||
|
response.context_data['noc'] = True |
||||
|
else: |
||||
|
response.context_data['noc'] = False |
||||
|
return response |
||||
|
|
||||
|
def process_response(self, request, response): |
||||
|
#hodin = datetime.now().hour |
||||
|
#if (hodin <= 6) or (hodin >= 14): # TODO 20 |
||||
|
#response.context_data['noc'] = True |
||||
|
#else: |
||||
|
#response.context_data['noc'] = False |
||||
|
return response |
||||
|
|
||||
|
|
||||
|
##def process_exception(request, exception): |
||||
|
#pass |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 400 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 519 KiB |
After Width: | Height: | Size: 64 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 101 KiB |
Before Width: | Height: | Size: 562 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 512 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 456 KiB |
After Width: | Height: | Size: 122 KiB |
Before Width: | Height: | Size: 679 KiB |
@ -0,0 +1,19 @@ |
|||||
|
{% extends "base.html" %} |
||||
|
|
||||
|
{% load staticfiles %} |
||||
|
|
||||
|
{% block content %} |
||||
|
<h2> |
||||
|
{% block nadpis1a %}{% block nadpis1b %} |
||||
|
O-jo-jo-jo-joj |
||||
|
{% endblock %}{% endblock %} |
||||
|
</h2> |
||||
|
|
||||
|
<p> |
||||
|
Chybička se vloudila. |
||||
|
Zkuste přejít na <a href="/">titulní stránku</a> |
||||
|
nebo se podívat na <a href="/zadani/aktualni/">aktuální zadání</a>. |
||||
|
</p> |
||||
|
<img src="{% static '500.png' %}"> |
||||
|
{% endblock %} |
||||
|
|
@ -0,0 +1,19 @@ |
|||||
|
{% extends "base.html" %} |
||||
|
|
||||
|
{% load staticfiles %} |
||||
|
|
||||
|
{% block content %} |
||||
|
<h2> |
||||
|
{% block nadpis1a %}{% block nadpis1b %} |
||||
|
Vrrrrrrrrr |
||||
|
{% endblock %}{% endblock %} |
||||
|
</h2> |
||||
|
|
||||
|
<p> |
||||
|
Tady pravděpodobně nemáte co dělat. |
||||
|
Zkuste přejít na <a href="/">titulní stránku</a> |
||||
|
nebo se podívat na <a href="/zadani/aktualni/">aktuální zadání</a>. |
||||
|
</p> |
||||
|
<img src="{% static '500.png' %}"> |
||||
|
{% endblock %} |
||||
|
|
@ -0,0 +1,20 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
|
from django.core.management.base import NoArgsCommand |
||||
|
from django.contrib.sessions.models import Session |
||||
|
from django.contrib.auth.models import User |
||||
|
|
||||
|
class Command(NoArgsCommand): |
||||
|
u"""Vypiš username přihlášeného orga s daným session_key. |
||||
|
|
||||
|
Příkaz pro manage.py, který ze vstupu přečte session_key (tak, jak je |
||||
|
uložen v cookie sessionid) a pokud session existuje a příslušný přihlášený |
||||
|
uživatel má právo přihlásit se do admina, vypíše jeho username. |
||||
|
""" |
||||
|
def handle_noargs(self, **options): |
||||
|
session_key = raw_input() |
||||
|
s = Session.objects.get(pk=session_key).get_decoded() |
||||
|
user_id = s['_auth_user_id'] |
||||
|
user = User.objects.get(pk=user_id) |
||||
|
if user.is_staff: |
||||
|
print(user.username) |
@ -0,0 +1,44 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import models, migrations |
||||
|
import django_countries.fields |
||||
|
import seminar.models |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('seminar', '0031_cislo_pdf'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AlterModelOptions( |
||||
|
name='soustredeni', |
||||
|
options={'ordering': ['-rocnik__rocnik', '-datum_zacatku'], 'verbose_name': 'Soust\u0159ed\u011bn\xed', 'verbose_name_plural': 'Soust\u0159ed\u011bn\xed'}, |
||||
|
), |
||||
|
migrations.AlterField( |
||||
|
model_name='cislo', |
||||
|
name='cislo', |
||||
|
field=models.CharField(help_text='V\u011bt\u0161inou jen "1", vyj\xedme\u010dn\u011b "7-8", lexikograficky ur\u010duje po\u0159ad\xed v ro\u010dn\xedku!', max_length=32, verbose_name='n\xe1zev \u010d\xedsla', db_index=True), |
||||
|
preserve_default=True, |
||||
|
), |
||||
|
migrations.AlterField( |
||||
|
model_name='cislo', |
||||
|
name='pdf', |
||||
|
field=models.FileField(help_text='Pdf \u010d\xedsla, kter\xe9 si mohou \u0159e\u0161itel\xe9 st\xe1hnout', upload_to=seminar.models.cislo_pdf_filename, null=True, verbose_name='pdf', blank=True), |
||||
|
preserve_default=True, |
||||
|
), |
||||
|
migrations.AlterField( |
||||
|
model_name='problem', |
||||
|
name='typ', |
||||
|
field=models.CharField(default=b'uloha', max_length=32, verbose_name='typ probl\xe9mu', choices=[(b'uloha', '\xdaloha'), (b'tema', 'T\xe9ma'), (b'serial', 'Seri\xe1l'), (b'org-clanek', 'Organiz\xe1torsk\xfd \u010dl\xe1nek'), (b'res-clanek', '\u0158e\u0161itelsk\xfd \u010dl\xe1nek')]), |
||||
|
preserve_default=True, |
||||
|
), |
||||
|
migrations.AlterField( |
||||
|
model_name='skola', |
||||
|
name='stat', |
||||
|
field=django_countries.fields.CountryField(default=b'CZ', help_text='ISO 3166-1 k\xf3d zem\u011b velk\xfdmi p\xedsmeny (CZ, SK, ...)', max_length=2, verbose_name='st\xe1t'), |
||||
|
preserve_default=True, |
||||
|
), |
||||
|
] |
@ -0,0 +1,20 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import models, migrations |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('seminar', '0032_cislo_pdf_blank_typos'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AlterField( |
||||
|
model_name='organizator', |
||||
|
name='studuje', |
||||
|
field=models.CharField(help_text=b"Nap\xc5\x99. 'Studuje Obecnou fyziku (Bc.), 3. ro\xc4\x8dn\xc3\xadk', 'Vystudovala Diskr\xc3\xa9tn\xc3\xad modely a algoritmy (Mgr.)' nebo 'P\xc5\x99edn\xc3\xa1\xc5\xa1\xc3\xad na MFF'", max_length=256, null=True, verbose_name=b'Studium aj.', blank=True), |
||||
|
preserve_default=True, |
||||
|
), |
||||
|
] |
@ -0,0 +1,29 @@ |
|||||
|
<table class='vysledkovka'> |
||||
|
<tr class='border-b'> |
||||
|
<th class='border-r'># |
||||
|
<th class='border-r'>Jméno |
||||
|
<th class='border-r'>R. |
||||
|
<th class='border-r'>Odjakživa |
||||
|
{% for c in vysledkovka.cisla %} |
||||
|
<th class='border-r'><a href="{{ c.verejne_url }}"> |
||||
|
{{c.rocnik.rocnik}}.{{ c.cislo }}</a> |
||||
|
{% endfor %} |
||||
|
<th class='border-r'>Celkem |
||||
|
|
||||
|
{% for rv in vysledkovka.radky %} |
||||
|
<tr> |
||||
|
<td class='border-r'>{% autoescape off %}{{ rv.poradi }}{% endautoescape %} |
||||
|
<th class='border-r'> |
||||
|
{% if rv.titul %} |
||||
|
{{ rv.titul }}<sup>MM</sup> |
||||
|
{% endif %} |
||||
|
{{ rv.resitel.plne_jmeno }} |
||||
|
<td class='border-r'>{{ rv.resitel.rocnik }} |
||||
|
<td class='border-r'>{{ rv.body_odjakziva }} |
||||
|
{% for b in rv.body_cisla %} |
||||
|
<td class='border-r'>{{ b }} |
||||
|
{% endfor %} |
||||
|
<td class='border-r'><b>{{ rv.body_rocnik }}</b> |
||||
|
</tr> |
||||
|
{% endfor %} |
||||
|
</table> |
@ -0,0 +1,35 @@ |
|||||
|
{% extends "seminar/zadani/base.html" %} |
||||
|
|
||||
|
{% block submenu %} |
||||
|
{% with "vysledkova-listina" as selected %} |
||||
|
{% include 'seminar/zadani/submenu.html' %} |
||||
|
{% endwith %} |
||||
|
{% endblock submenu %} |
||||
|
|
||||
|
|
||||
|
{% block content %} |
||||
|
{% with nastaveni.aktualni_rocnik as rocnik %} |
||||
|
|
||||
|
<h2> |
||||
|
{% block nadpis1a %}{% block nadpis1b %} |
||||
|
Výsledky |
||||
|
{% endblock %}{% endblock %} |
||||
|
</h2> |
||||
|
|
||||
|
{% if vysledkovka %} |
||||
|
{% include "seminar/vysledkovka_rocnik.html" %} |
||||
|
{% else %} |
||||
|
V tomto ročníku zatím žádné výsledky nejsou |
||||
|
{% endif %} |
||||
|
|
||||
|
{% if user.is_staff and vysledkovka_s_neverejnymi %} |
||||
|
<div class='mam-org-only'> |
||||
|
<h2>Výsledky včetně neveřejných</h2> |
||||
|
{% with vysledkovka_s_neverejnymi as vysledkovka %} |
||||
|
{% include "seminar/vysledkovka_rocnik.html" %} |
||||
|
{% endwith %} |
||||
|
</div> |
||||
|
{% endif %} |
||||
|
|
||||
|
{% endwith %} |
||||
|
{% endblock content %} |