|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import datetime
|
|
|
|
|
|
|
|
roman_numerals = zip((1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1),
|
|
|
|
('M', 'CM', 'D', 'CD','C', 'XC','L','XL','X','IX','V','IV','I'))
|
|
|
|
|
|
|
|
def roman(num):
|
|
|
|
res = ""
|
|
|
|
for i, n in roman_numerals:
|
|
|
|
res += n * (num // i)
|
|
|
|
num %= i
|
|
|
|
return res
|
|
|
|
|
|
|
|
def from_roman(rom):
|
|
|
|
if not rom:
|
|
|
|
return 0
|
|
|
|
for i, n in roman_numerals:
|
|
|
|
if rom.upper().startswith(n):
|
|
|
|
return i + from_roman(rom[len(n):])
|
|
|
|
raise Exception('Invalid roman numeral: "%s"', rom)
|
|
|
|
|
|
|
|
|
|
|
|
def seznam_problemu():
|
|
|
|
from .models import Problem, Resitel, Rocnik, Reseni, Cislo
|
|
|
|
problemy = []
|
|
|
|
|
|
|
|
# Pomocna fce k formatovani problemovych hlasek
|
|
|
|
def prb(cls, msg, objs=None):
|
|
|
|
s = u'<b>%s:</b> %s' % (cls.__name__, msg)
|
|
|
|
if objs:
|
|
|
|
s += u' ['
|
|
|
|
for o in objs:
|
|
|
|
try:
|
|
|
|
url = o.admin_url()
|
|
|
|
except:
|
|
|
|
url = None
|
|
|
|
if url:
|
|
|
|
s += u'<a href="%s">%s</a>, ' % (url, o.pk, )
|
|
|
|
else:
|
|
|
|
s += u'%s, ' % (o.pk, )
|
|
|
|
s = s[:-2] + u']'
|
|
|
|
problemy.append(s)
|
|
|
|
|
|
|
|
# Duplicita jmen
|
|
|
|
jmena = {}
|
|
|
|
for r in Resitel.objects.all():
|
|
|
|
j = r.plne_jmeno()
|
|
|
|
if j not in jmena:
|
|
|
|
jmena[j] = []
|
|
|
|
jmena[j].append(r)
|
|
|
|
for j in jmena:
|
|
|
|
if len(jmena[j]) > 1:
|
|
|
|
prb(Resitel, u'Duplicitní jméno "%s"' % (j, ), jmena[j])
|
|
|
|
|
|
|
|
# Data maturity a narození
|
|
|
|
for r in Resitel.objects.all():
|
|
|
|
if not r.rok_maturity:
|
|
|
|
prb(Resitel, u'Neznámý rok maturity', [r])
|
|
|
|
if r.rok_maturity and (r.rok_maturity < 1990 or r.rok_maturity > datetime.date.today().year + 10):
|
|
|
|
prb(Resitel, u'Podezřelé datum maturity', [r])
|
|
|
|
if r.datum_narozeni and (r.datum_narozeni.year < 1970 or r.datum_narozeni.year > datetime.date.today().year - 12):
|
|
|
|
prb(Resitel, u'Podezřelé datum narození', [r])
|
|
|
|
# if not r.email:
|
|
|
|
# prb(Resitel, u'Neznámý email', [r])
|
|
|
|
|
|
|
|
return problemy
|
|
|
|
|