Merge branch 'data_migrations' of gimli.ms.mff.cuni.cz:/akce/mam/git/mamweb into data_migrations
This commit is contained in:
commit
dc574d9185
13 changed files with 402 additions and 167 deletions
|
@ -155,7 +155,7 @@ class Oprava(models.Model):
|
||||||
# setattr(self,k,v)
|
# setattr(self,k,v)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return force_unicode(u'%s od %s: %s'%(self.status,self.autor,self.text))
|
return '{} od {}: {}'.format(self.status,self.autor,self.text)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ class Komentar(models.Model):
|
||||||
text = models.TextField(u'text komentáře',blank = True, help_text='Text komentáře')
|
text = models.TextField(u'text komentáře',blank = True, help_text='Text komentáře')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return force_unicode(u'%s od %s: %s'%(self.cas,self.autor,self.text))
|
return '{} od {}: {}'.format(self.cas,self.autor,self.text)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,72 +13,46 @@ body,
|
||||||
|
|
||||||
img{background:white;}
|
img{background:white;}
|
||||||
|
|
||||||
|
/* Barvy korektur */
|
||||||
|
.k_oprave {
|
||||||
|
--rgb: 255, 0, 0;
|
||||||
|
}
|
||||||
|
.opraveno {
|
||||||
|
--rgb: 0, 0, 255;
|
||||||
|
}
|
||||||
|
.neni_chyba {
|
||||||
|
--rgb: 128, 128, 128;
|
||||||
|
}
|
||||||
|
.k_zaneseni {
|
||||||
|
--rgb: 0, 255, 0;
|
||||||
|
}
|
||||||
|
|
||||||
.pointer-hi,
|
.pointer-hi,
|
||||||
.pointer,
|
.pointer{
|
||||||
.pointer-wontfix,
|
|
||||||
.pointer-wontfix-hi,
|
|
||||||
.pointer-ready,
|
|
||||||
.pointer-ready-hi,
|
|
||||||
.pointer-done,
|
|
||||||
.pointer-done-hi {
|
|
||||||
position:absolute;
|
position:absolute;
|
||||||
/*border-bottom-left-radius: 10px; */
|
/*border-bottom-left-radius: 10px; */
|
||||||
border-left: 2px solid yellow;
|
border-left: 2px solid yellow;
|
||||||
border-bottom: 2px solid yellow;
|
border-bottom: 2px solid yellow;
|
||||||
|
border-color: rgb(var(--rgb),var(--alpha));
|
||||||
|
}
|
||||||
|
|
||||||
|
.pointer {
|
||||||
|
border-width: 1px;
|
||||||
|
--alpha: 0.35;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pointer-done-hi,
|
|
||||||
.pointer-wontfix-hi,
|
|
||||||
.pointer-ready-hi,
|
|
||||||
.pointer-hi {
|
.pointer-hi {
|
||||||
border-width: 3px;
|
border-width: 3px;
|
||||||
}
|
--alpha: 1;
|
||||||
|
|
||||||
.pointer {
|
|
||||||
border-color: #F00; /*IE*/
|
|
||||||
border-color: rgba(255, 0, 0, 0.35);
|
|
||||||
}
|
|
||||||
.pointer-hi {
|
|
||||||
border-color: #F00; /*IE*/
|
|
||||||
border-color: rgba(255, 0, 0, 1);
|
|
||||||
}
|
|
||||||
.pointer-done {
|
|
||||||
border-color: #00F; /*IE*/
|
|
||||||
border-color: rgba(0, 0, 255, 0.2);
|
|
||||||
}
|
|
||||||
.pointer-done-hi {
|
|
||||||
border-color: #00F; /*IE*/
|
|
||||||
border-color: rgba(0, 0, 255, 1);
|
|
||||||
}
|
|
||||||
.pointer-wontfix {
|
|
||||||
border-color: #000; /*IE*/
|
|
||||||
border-color: rgba(128, 128, 128, 0.2);
|
|
||||||
}
|
|
||||||
.pointer-wontfix-hi {
|
|
||||||
border-color: #000; /*IE*/
|
|
||||||
border-color: rgba(128, 128, 128, 1);
|
|
||||||
}
|
|
||||||
.pointer-ready {
|
|
||||||
border-color: #0F0; /*IE*/
|
|
||||||
border-color: rgba(0, 255, 0, 0.2);
|
|
||||||
}
|
|
||||||
.pointer-ready-hi {
|
|
||||||
border-color: #0F0; /*IE*/
|
|
||||||
border-color: rgba(0, 255, 0, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.box:hover,
|
|
||||||
.box-done:hover,
|
.box:hover{
|
||||||
.box-ready:hover,
|
|
||||||
.box-wontfix:hover{
|
|
||||||
border-width:3px;
|
border-width:3px;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
}
|
}
|
||||||
.box,
|
.box {
|
||||||
.box-done,
|
|
||||||
.box-ready,
|
|
||||||
.box-wontfix {
|
|
||||||
margin: 1px;
|
margin: 1px;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
width:300px;
|
width:300px;
|
||||||
|
@ -86,18 +60,7 @@ img{background:white;}
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
border: 2px solid black;
|
border: 2px solid black;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
border-color: rgb(var(--rgb));
|
||||||
.box {
|
|
||||||
border-color: red;
|
|
||||||
}
|
|
||||||
.box-done {
|
|
||||||
border-color: blue;
|
|
||||||
}
|
|
||||||
.box-ready {
|
|
||||||
border-color: rgba(0,255,0,1);
|
|
||||||
}
|
|
||||||
.box-wontfix {
|
|
||||||
border-color: grey;
|
|
||||||
}
|
}
|
||||||
form {
|
form {
|
||||||
display:inline;
|
display:inline;
|
||||||
|
|
|
@ -65,6 +65,12 @@ function place_comments_one_div(img_id, comments)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function place_comments() {
|
||||||
|
for (var i=0; i < comments.length-1; i++) {
|
||||||
|
place_comments_one_div(comments[i][0], comments[i][1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ctrl-enter submits form
|
// ctrl-enter submits form
|
||||||
function textarea_onkey(ev)
|
function textarea_onkey(ev)
|
||||||
{
|
{
|
||||||
|
@ -212,45 +218,22 @@ function show_form(img_id, dx, dy, id, text, action) {
|
||||||
textarea.focus();
|
textarea.focus();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function box_onmouseover(box, stat)
|
function box_onmouseover(box)
|
||||||
{
|
{
|
||||||
var id = box.id;
|
var id = box.id;
|
||||||
var pointer = document.getElementById(box.id + '-pointer');
|
var pointer = document.getElementById(box.id + '-pointer');
|
||||||
switch (stat){
|
pointer.classList.remove('pointer');
|
||||||
case 'done':
|
pointer.classList.add('pointer-hi');
|
||||||
pointer.className = 'pointer-done-hi';
|
|
||||||
break;
|
|
||||||
case 'wontfix':
|
|
||||||
pointer.className = 'pointer-wontfix-hi';
|
|
||||||
break;
|
|
||||||
case 'ready':
|
|
||||||
pointer.className = 'pointer-ready-hi';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
pointer.className = 'pointer-hi';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function box_onmouseout(box, stat)
|
function box_onmouseout(box)
|
||||||
{
|
{
|
||||||
var id = box.id;
|
var id = box.id;
|
||||||
var pointer = document.getElementById(box.id + '-pointer');
|
var pointer = document.getElementById(box.id + '-pointer');
|
||||||
switch (stat){
|
pointer.classList.remove('pointer-hi');
|
||||||
case 'done':
|
pointer.classList.add('pointer');
|
||||||
pointer.className = 'pointer-done';
|
|
||||||
break;
|
|
||||||
case 'wontfix':
|
|
||||||
pointer.className = 'pointer-wontfix';
|
|
||||||
break;
|
|
||||||
case 'ready':
|
|
||||||
pointer.className = 'pointer-ready';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
pointer.className = 'pointer';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_scroll(form)
|
function save_scroll(form)
|
||||||
|
@ -261,6 +244,33 @@ function save_scroll(form)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggle_corrections(aclass)
|
||||||
|
{
|
||||||
|
var stylesheets = document.styleSheets;
|
||||||
|
var ssheet = null;
|
||||||
|
for (var i=0;i<stylesheets.length; i++){
|
||||||
|
if (stylesheets[i].title === "opraf-css"){
|
||||||
|
ssheet = stylesheets[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! ssheet){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (var i=0;i<ssheet.cssRules.length;i++){
|
||||||
|
var rule = ssheet.cssRules[i];
|
||||||
|
if (rule.selectorText === '.'+aclass){
|
||||||
|
if (rule.style.display === ""){
|
||||||
|
rule.style.display = "none";
|
||||||
|
} else {
|
||||||
|
rule.style.display = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
place_comments();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
String.prototype.unescapeHTML = function () {
|
String.prototype.unescapeHTML = function () {
|
||||||
return(
|
return(
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
<link rel="stylesheet" type="text/css" media="screen, projection" href="{% static "korektury/opraf.css"%}" />
|
<link rel="stylesheet" title="opraf-css" type="text/css" media="screen, projection" href="{% static "korektury/opraf.css"%}" />
|
||||||
<script src="{% static "korektury/opraf.js"%}"></script>
|
<script src="{% static "korektury/opraf.js"%}"></script>
|
||||||
<title>Korektury {{pdf.nazev}}</title>
|
<title>Korektury {{pdf.nazev}}</title>
|
||||||
</head>
|
</head>
|
||||||
|
@ -20,6 +20,29 @@
|
||||||
|
|
|
|
||||||
<a href="/">hlavní stránka</a> |
|
<a href="/">hlavní stránka</a> |
|
||||||
<a href="https://mam.mff.cuni.cz/wiki">wiki</a> |
|
<a href="https://mam.mff.cuni.cz/wiki">wiki</a> |
|
||||||
|
<hr />
|
||||||
|
Zobrazit:
|
||||||
|
<input type="checkbox"
|
||||||
|
id="k_oprave_checkbox"
|
||||||
|
name="k_oprave_checkbox"
|
||||||
|
onchange="toggle_corrections('k_oprave')" checked>
|
||||||
|
<label for="k_oprave_checkbox">K opravě ({{k_oprave_cnt}})</label>
|
||||||
|
<input type="checkbox"
|
||||||
|
id="opraveno_checkbox"
|
||||||
|
name="opraveno_checkbox"
|
||||||
|
onchange="toggle_corrections('opraveno')" checked>
|
||||||
|
<label for="opraveno_checkbox">Opraveno ({{opraveno_cnt}})</label>
|
||||||
|
<input type="checkbox"
|
||||||
|
id="neni_chyba_checkbox"
|
||||||
|
name="neni_chyba_checkbox"
|
||||||
|
onchange="toggle_corrections('neni_chyba')" checked>
|
||||||
|
<label for="neni_chyba_checkbox">Není chyba ({{neni_chyba_cnt}})</labe>
|
||||||
|
<input type="checkbox"
|
||||||
|
id="k_zaneseni_checkbox"
|
||||||
|
name="k_zaneseni_checkbox"
|
||||||
|
onchange="toggle_corrections('k_zaneseni')" checked>
|
||||||
|
<label for="k_zaneseni_checkbox">K zanesení ({{k_zaneseni_cnt}})</labe>
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
<div id="commform-div">
|
<div id="commform-div">
|
||||||
|
@ -81,12 +104,12 @@
|
||||||
{% for o in opravy %}
|
{% for o in opravy %}
|
||||||
<div onclick='img_click(this,event)'
|
<div onclick='img_click(this,event)'
|
||||||
id='op{{o.id}}-pointer'
|
id='op{{o.id}}-pointer'
|
||||||
class='pointer{%if o.status == 'opraveno' %}-done{% elif o.status == 'neni_chyba' %}-wontfix{% elif o.status == 'k_zaneseni' %}-ready{% endif %}'>
|
class='pointer {{o.status}}'>
|
||||||
</div>
|
</div>
|
||||||
<div name='op{{o.id}}' id='op{{o.id}}'
|
<div name='op{{o.id}}' id='op{{o.id}}'
|
||||||
class='box{%if o.status == 'opraveno' %}-done{% elif o.status == 'neni_chyba' %}-wontfix{% elif o.status == 'k_zaneseni' %}-ready{% endif %}'
|
class='box {{o.status}}'
|
||||||
onmouseover='box_onmouseover(this,{% if o.status == 'opraveno' %}"done"{% elif o.status == 'neni_chyba' %}"wontfix"{% elif o.status == 'k_zaneseni' %}"ready"{% else %}""{% endif %})'
|
onmouseover='box_onmouseover(this)'
|
||||||
onmouseout='box_onmouseout(this, {% if o.status == 'opraveno' %}"done"{% elif o.status == 'neni_chyba' %}"wontfix"{% elif o.status == 'k_zaneseni' %}"ready"{% else %}""{% endif %})'>
|
onmouseout='box_onmouseout(this)'>
|
||||||
|
|
||||||
<div class='corr-header'>
|
<div class='corr-header'>
|
||||||
<span class='author' id='op{{o.id}}-autor'>{{o.autor}}</span>
|
<span class='author' id='op{{o.id}}-autor'>{{o.autor}}</span>
|
||||||
|
@ -211,11 +234,6 @@
|
||||||
["img-{{s.strana}}", [{% for o in s.op_id %}["op{{o.id}}",{{o.x}},{{o.y}}],{% endfor %}[]]],
|
["img-{{s.strana}}", [{% for o in s.op_id %}["op{{o.id}}",{{o.x}},{{o.y}}],{% endfor %}[]]],
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
[]]
|
[]]
|
||||||
function place_comments() {
|
|
||||||
for (var i=0; i < comments.length-1; i++) {
|
|
||||||
place_comments_one_div(comments[i][0], comments[i][1])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{% if scroll %}
|
{% if scroll %}
|
||||||
window.scrollTo(0,{{scroll}});
|
window.scrollTo(0,{{scroll}});
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -17,7 +17,14 @@
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for pdf in object_list %}
|
{% for pdf in object_list %}
|
||||||
<li><span {% if pdf.status == 'zanaseni'%} class="comitting-text" {% elif pdf.status == 'zastarale' %} class="deprecated-text" {% endif %}> <b>{{ pdf.nazev }}</b> <i>{{pdf.komentar}}</i> <a href="/korektury/{{pdf.id}}">{{pdf.pdf.name}}</a> </span> </li>
|
<li><span {% if pdf.status == 'zanaseni'%} class="comitting-text" {% elif pdf.status == 'zastarale' %} class="deprecated-text" {% endif %}>
|
||||||
|
<b>{{ pdf.nazev }}</b>
|
||||||
|
<i>{{pdf.komentar}}</i>
|
||||||
|
<a href="/korektury/{{pdf.id}}">{{pdf.pdf.name}}</a>
|
||||||
|
(k opravě: {{pdf.k_oprave_cnt}},
|
||||||
|
opraveno: {{pdf.opraveno_cnt}},
|
||||||
|
není chyba: {{pdf.neni_chyba_cnt}},
|
||||||
|
k zanesení: {{pdf.k_zaneseni_cnt}}) </span> </li>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<li> Nejsou žádné dokumenty ke korekturování.
|
<li> Nejsou žádné dokumenty ke korekturování.
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -5,6 +5,7 @@ from django.utils.translation import ugettext as _
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpResponseForbidden
|
from django.http import HttpResponseForbidden
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
|
from django.db.models import Count,Q
|
||||||
|
|
||||||
from .models import Oprava,Komentar,KorekturovanePDF, Organizator
|
from .models import Oprava,Komentar,KorekturovanePDF, Organizator
|
||||||
from .forms import OpravaForm
|
from .forms import OpravaForm
|
||||||
|
@ -17,8 +18,16 @@ import unicodedata
|
||||||
class KorekturyHelpView(generic.TemplateView):
|
class KorekturyHelpView(generic.TemplateView):
|
||||||
template_name = 'korektury/help.html'
|
template_name = 'korektury/help.html'
|
||||||
|
|
||||||
|
|
||||||
class KorekturyListView(generic.ListView):
|
class KorekturyListView(generic.ListView):
|
||||||
model = KorekturovanePDF
|
model = KorekturovanePDF
|
||||||
|
# Nefunguje, filtry se vubec nepouziji
|
||||||
|
queryset = KorekturovanePDF.objects.annotate(
|
||||||
|
k_oprave_cnt=Count('oprava',filter=Q(oprava__status='k_oprave')),
|
||||||
|
opraveno_cnt=Count('oprava',filter=Q(oprava__status='opraveno')),
|
||||||
|
neni_chyba_cnt=Count('oprava',filter=Q(oprava__status='neni_chyba')),
|
||||||
|
k_zaneseni_cnt=Count('oprava',filter=Q(oprava__status='k_zaneseni')),
|
||||||
|
)
|
||||||
template_name = 'korektury/seznam.html'
|
template_name = 'korektury/seznam.html'
|
||||||
|
|
||||||
### Korektury
|
### Korektury
|
||||||
|
@ -35,7 +44,7 @@ class KorekturyView(generic.TemplateView):
|
||||||
# prirazeni autora podle prihlaseni
|
# prirazeni autora podle prihlaseni
|
||||||
autor_user = request.user
|
autor_user = request.user
|
||||||
# pokud existuje ucet (user), ale neni to organizator = 403
|
# pokud existuje ucet (user), ale neni to organizator = 403
|
||||||
autor = Organizator.objects.filter(user=autor_user).first()
|
autor = Organizator.objects.filter(osoba__user=autor_user).first()
|
||||||
if not autor:
|
if not autor:
|
||||||
return HttpResponseForbidden()
|
return HttpResponseForbidden()
|
||||||
|
|
||||||
|
@ -133,24 +142,24 @@ class KorekturyView(generic.TemplateView):
|
||||||
# Prijemci e-mailu
|
# Prijemci e-mailu
|
||||||
emails = set()
|
emails = set()
|
||||||
# e-mail autora korektury
|
# e-mail autora korektury
|
||||||
email = oprava.autor.user.email
|
email = oprava.autor.osoba.email
|
||||||
if email:
|
if email:
|
||||||
emails.add(email)
|
emails.add(email)
|
||||||
|
|
||||||
# nalezeni e-mailu na autory komentaru
|
# nalezeni e-mailu na autory komentaru
|
||||||
for komentar in oprava.komentar_set.all():
|
for komentar in oprava.komentar_set.all():
|
||||||
email_komentujiciho = komentar.autor.user.email
|
email_komentujiciho = komentar.autor.osoba.email
|
||||||
if email_komentujiciho:
|
if email_komentujiciho:
|
||||||
emails.add(email_komentujiciho)
|
emails.add(email_komentujiciho)
|
||||||
|
|
||||||
# zodpovedny org
|
# zodpovedny org
|
||||||
if oprava.pdf.org:
|
if oprava.pdf.org:
|
||||||
email_zobpovedny = oprava.pdf.org.user.email
|
email_zobpovedny = oprava.pdf.org.osoba.email
|
||||||
if email_zobpovedny:
|
if email_zobpovedny:
|
||||||
emails.add(email_zobpovedny)
|
emails.add(email_zobpovedny)
|
||||||
|
|
||||||
# odstran e-mail autora opravy
|
# odstran e-mail autora opravy
|
||||||
email = autor.user.email
|
email = autor.osoba.email
|
||||||
if email:
|
if email:
|
||||||
emails.discard(email)
|
emails.discard(email)
|
||||||
|
|
||||||
|
@ -190,6 +199,11 @@ class KorekturyView(generic.TemplateView):
|
||||||
strany = set(o.strana for o in opravy)
|
strany = set(o.strana for o in opravy)
|
||||||
opravy_na_stranu = [{'strana': s, 'op_id': opravy.filter(strana=s)} for s in strany]
|
opravy_na_stranu = [{'strana': s, 'op_id': opravy.filter(strana=s)} for s in strany]
|
||||||
context['opravy_strany'] = opravy_na_stranu
|
context['opravy_strany'] = opravy_na_stranu
|
||||||
|
|
||||||
|
context['k_oprave_cnt'] = opravy.filter(status='k_oprave').count()
|
||||||
|
context['opraveno_cnt'] = opravy.filter(status='opraveno').count()
|
||||||
|
context['neni_chyba_cnt'] = opravy.filter(status='neni_chyba').count()
|
||||||
|
context['k_zaneseni_cnt'] = opravy.filter(status='k_zaneseni').count()
|
||||||
|
|
||||||
context['opravy'] = opravy
|
context['opravy'] = opravy
|
||||||
context['zasluhy'] = zasluhy
|
context['zasluhy'] = zasluhy
|
||||||
|
|
|
@ -47,7 +47,43 @@ DATABASES = {
|
||||||
#}
|
#}
|
||||||
|
|
||||||
# LOGGING
|
# LOGGING
|
||||||
|
LOGGING = {
|
||||||
|
'version': 1,
|
||||||
|
'disable_existing_loggers': True,
|
||||||
|
'filters': {
|
||||||
|
'require_debug_false': {
|
||||||
|
'()': 'django.utils.log.RequireDebugFalse'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'formatters': {
|
||||||
|
'simple': {
|
||||||
|
'format': '%(asctime)s - %(name)s - %(levelname)-8s - %(message)s',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'handlers': {
|
||||||
|
'dummy': {
|
||||||
|
'class': 'logging.NullHandler',
|
||||||
|
},
|
||||||
|
'console': {
|
||||||
|
'level': 'DEBUG',
|
||||||
|
'class': 'logging.StreamHandler',
|
||||||
|
'formatter': 'simple',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'loggers': {
|
||||||
|
# Vypisovani databazovych dotazu do konzole
|
||||||
|
'django.db.backends': {
|
||||||
|
'level': 'DEBUG',
|
||||||
|
'handlers': ['console'],
|
||||||
|
'propagate': False,
|
||||||
|
},
|
||||||
|
'': {
|
||||||
|
'handlers': ['console'],
|
||||||
|
'level': 'DEBUG',
|
||||||
|
'propagate': False,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
# set to 'DEBUG' for EXTRA verbose output
|
# set to 'DEBUG' for EXTRA verbose output
|
||||||
LOGGING['handlers']['console']['level'] = 'INFO'
|
# LOGGING['handlers']['console']['level'] = 'INFO'
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ class Migration(migrations.Migration):
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='organizator',
|
model_name='organizator',
|
||||||
name='organizuje_od',
|
name='organizuje_od',
|
||||||
field=models.DateTimeField(default='1900-01-01T00:00:00', verbose_name='Organizuje od'),
|
field=models.DateTimeField(null=True,blank=True, verbose_name='Organizuje od'),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='organizator',
|
model_name='organizator',
|
||||||
|
|
|
@ -23,6 +23,35 @@ def resitel_to_osoba(apps,schema_editor):
|
||||||
o.telefon = r.telefon
|
o.telefon = r.telefon
|
||||||
o.ulice = r.ulice
|
o.ulice = r.ulice
|
||||||
o.user = r.user
|
o.user = r.user
|
||||||
|
if o.user:
|
||||||
|
u = o.user
|
||||||
|
if u.first_name:
|
||||||
|
if not o.jmeno:
|
||||||
|
o.jmeno = u.first_name
|
||||||
|
u.first_name = 'Použij osobu!'
|
||||||
|
elif o.jmeno == u.first_name:
|
||||||
|
u.first_name = 'Použij osobu!'
|
||||||
|
else:
|
||||||
|
raise ValueError('jmeno a first_name rozdílné: "{}" vs. "{}"'.format(o.jmeno, u.first_name))
|
||||||
|
if u.last_name:
|
||||||
|
if not o.prijmeni:
|
||||||
|
o.prijmeni = u.last_name
|
||||||
|
u.last_name = 'Použij osobu!'
|
||||||
|
elif o.prijmeni == u.last_name:
|
||||||
|
u.last_name = 'Použij osobu!'
|
||||||
|
else:
|
||||||
|
raise ValueError('prijmeni a last_name rozdílné: "{}" vs. "{}"'.format(o.prijmeni, u.last_name))
|
||||||
|
if u.email:
|
||||||
|
if not o.email:
|
||||||
|
o.email = u.email
|
||||||
|
u.email = 'Použij osobu!'
|
||||||
|
elif o.email == u.email:
|
||||||
|
u.email = 'Použij osobu!'
|
||||||
|
else:
|
||||||
|
raise ValueError('o.email a u.email rozdílné: "{}" vs. "{}"'.format(o.email, u.first_name))
|
||||||
|
u.save()
|
||||||
|
|
||||||
|
|
||||||
o.save()
|
o.save()
|
||||||
r.osoba = o
|
r.osoba = o
|
||||||
r.save()
|
r.save()
|
||||||
|
|
82
seminar/migrations/0052_user_to_organizator.py
Normal file
82
seminar/migrations/0052_user_to_organizator.py
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.15 on 2019-05-16 20:59
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
def spoj_k_organizatorum_osoby(apps, scema_editor):
|
||||||
|
Organizator = apps.get_model('seminar', 'Organizator')
|
||||||
|
Resitel = apps.get_model('seminar', 'Resitel')
|
||||||
|
Osoba = apps.get_model('seminar', 'Osoba')
|
||||||
|
for org in Organizator.objects.all():
|
||||||
|
|
||||||
|
# Spárování organizátora s osobou
|
||||||
|
user = org.user
|
||||||
|
resitele = Resitel.objects.filter(user=user)
|
||||||
|
if resitele.count() != 0:
|
||||||
|
osoba = resitele.first().osoba
|
||||||
|
else:
|
||||||
|
osoba = Osoba(user=user)
|
||||||
|
|
||||||
|
# Přesun informací z usera do osoby
|
||||||
|
# pro řešitele již v minule migraci
|
||||||
|
osoba.jmeno = user.first_name
|
||||||
|
osoba.prijmeni = user.last_name
|
||||||
|
osoba.email = user.email
|
||||||
|
user.jmeno = "Použij osobu!"
|
||||||
|
user.prijmeni = "Použij osobu!"
|
||||||
|
user.email = "Použij osobu!"
|
||||||
|
user.save()
|
||||||
|
|
||||||
|
# Přesun informací z organizátora do jeho osoby
|
||||||
|
osoba.prezdivka = org.prezdivka if org.prezdivka is not None else ''
|
||||||
|
osoba.foto = org.foto
|
||||||
|
|
||||||
|
# Všechno uložit
|
||||||
|
osoba.save()
|
||||||
|
org.osoba = osoba
|
||||||
|
org.save()
|
||||||
|
|
||||||
|
def fix_problem(apps, schema_editor):
|
||||||
|
Problem = apps.get_model('seminar', 'Problem')
|
||||||
|
Organizator = apps.get_model('seminar', 'Organizator')
|
||||||
|
for pr in Problem.objects.all():
|
||||||
|
if pr.autor_old is not None:
|
||||||
|
pr.autor = Organizator.objects.filter(osoba__user=pr.autor_old).first()
|
||||||
|
else:
|
||||||
|
pr.autor = None
|
||||||
|
if pr.opravovatel is not None:
|
||||||
|
pr.opravovatele.add(Organizator.objects.filter(osoba__user=pr.opravovatel).first())
|
||||||
|
pr.save()
|
||||||
|
|
||||||
|
def fix_pohadka(apps, schema_editor):
|
||||||
|
Pohadka = apps.get_model('seminar', 'Pohadka')
|
||||||
|
Organizator = apps.get_model('seminar', 'Organizator')
|
||||||
|
for poh in Pohadka.objects.all():
|
||||||
|
if poh.autor_old is not None:
|
||||||
|
poh.autor = Organizator.objects.filter(osoba__user=poh.autor_old).first()
|
||||||
|
else:
|
||||||
|
poh.autor = None
|
||||||
|
poh.save()
|
||||||
|
|
||||||
|
def fix_novinka(apps, schema_editor):
|
||||||
|
Novinky = apps.get_model('seminar', 'Novinky')
|
||||||
|
Organizator = apps.get_model('seminar', 'Organizator')
|
||||||
|
for nov in Novinky.objects.all():
|
||||||
|
nov.autor = Organizator.objects.filter(osoba__user=nov.autor_old).first()
|
||||||
|
nov.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('seminar', '0051_resitel_to_osoba'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(spoj_k_organizatorum_osoby),
|
||||||
|
migrations.RunPython(fix_problem),
|
||||||
|
migrations.RunPython(fix_pohadka),
|
||||||
|
migrations.RunPython(fix_novinka),
|
||||||
|
]
|
36
seminar/migrations/0053_organizator_organizuje_od_do.py
Normal file
36
seminar/migrations/0053_organizator_organizuje_od_do.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.20 on 2019-05-16 21:26
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import datetime as dt
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
def rok_to_datetime(apps,schema_editor):
|
||||||
|
Organizator = apps.get_model('seminar','Organizator')
|
||||||
|
for o in Organizator.objects.all():
|
||||||
|
rok = o.organizuje_od_roku
|
||||||
|
if rok:
|
||||||
|
o.organizuje_od = dt.datetime(rok,1,1)
|
||||||
|
rok = o.organizuje_do_roku
|
||||||
|
if rok:
|
||||||
|
o.organizuje_do = dt.datetime(rok,12,31)
|
||||||
|
o.save()
|
||||||
|
|
||||||
|
def datetime_to_rok(apps,schema_editor):
|
||||||
|
Organizator = apps.get_model('seminar','Organizator')
|
||||||
|
for o in Organizator.objects.all():
|
||||||
|
o.organizuje_od_roku = o.organizuje_od.year
|
||||||
|
o.organizuje_do_roku = o.organizuje_do.year
|
||||||
|
o.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('seminar', '0052_user_to_organizator'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(rok_to_datetime, datetime_to_rok),
|
||||||
|
]
|
51
seminar/migrations/0054_problem_to_uloha_tema_clanek.py
Normal file
51
seminar/migrations/0054_problem_to_uloha_tema_clanek.py
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.20 on 2019-05-17 17:44
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
def uloha_to_Uloha(apps,schema_editor):
|
||||||
|
Problem = apps.get_model('seminar', 'Problem')
|
||||||
|
Uloha = apps.get_model('seminar', 'Uloha')
|
||||||
|
Text = apps.get_model('seminar', 'Text')
|
||||||
|
|
||||||
|
ulohy = Problem.objects.filter(typ = 'uloha')
|
||||||
|
for uold in ulohy:
|
||||||
|
zadani = Text.objects.create(na_web = uold.text_zadani)
|
||||||
|
vzorak = Text.objects.create(na_web = uold.text_reseni)
|
||||||
|
unew = Uloha.objects.create(
|
||||||
|
nazev = uold.nazev,
|
||||||
|
stav = uold.stav,
|
||||||
|
zamereni = uold.zamereni,
|
||||||
|
poznamka = uold.poznamka,
|
||||||
|
zadani = zadani,
|
||||||
|
vzorak = vzorak,
|
||||||
|
autor = uold.autor,
|
||||||
|
kod = uold.kod,
|
||||||
|
cislo_zadani = uold.cislo_zadani_old,
|
||||||
|
cislo_reseni = uold.cislo_reseni_old,
|
||||||
|
max_body = uold.body,
|
||||||
|
vytvoreno = uold.vytvoreno,
|
||||||
|
)
|
||||||
|
unew.opravovatele.add(*uold.opravovatele.all())
|
||||||
|
unew.save()
|
||||||
|
|
||||||
|
def tema_to_Tema(apps, schema_editor):
|
||||||
|
Problem = apps.get_model('seminar', 'Problem')
|
||||||
|
Tema = apps.get_model('seminar', 'Tema')
|
||||||
|
Text = apps.get_model('seminar', 'Text')
|
||||||
|
|
||||||
|
temata = Problem.objects.filter(typ = 'tema')
|
||||||
|
# Bordel bordel bordel. Téma nemá zadání, je potřeba vyrobit TemaVCisleNode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('seminar', '0053_organizator_organizuje_od_do'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(uloha_to_Uloha),
|
||||||
|
]
|
|
@ -40,13 +40,12 @@ class SeminarModelBase(models.Model):
|
||||||
|
|
||||||
def admin_url(self):
|
def admin_url(self):
|
||||||
model_name = self.__class__.__name__.lower()
|
model_name = self.__class__.__name__.lower()
|
||||||
return reverse('admin:seminar_%s_change'%(model_name, ), args=(self.id, ))
|
return reverse('admin:seminar_{}_change'.format(model_name), args=(self.id, ))
|
||||||
|
|
||||||
def verejne_url(self):
|
def verejne_url(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
|
||||||
class Osoba(SeminarModelBase):
|
class Osoba(SeminarModelBase):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -117,14 +116,14 @@ class Osoba(SeminarModelBase):
|
||||||
options={'quality': 95})
|
options={'quality': 95})
|
||||||
|
|
||||||
def plne_jmeno(self):
|
def plne_jmeno(self):
|
||||||
return force_unicode('%s %s' % (self.jmeno, self.prijmeni))
|
return '{} {}'.format(self.jmeno, self.prijmeni)
|
||||||
|
|
||||||
def inicial_krestni(self):
|
def inicial_krestni(self):
|
||||||
jmena = self.jmeno.split()
|
jmena = self.jmeno.split()
|
||||||
return " ".join(['{}.'.format(jmeno[0]) for jmeno in jmena])
|
return " ".join(['{}.'.format(jmeno[0]) for jmeno in jmena])
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return force_unicode("Osoba({})".format(self.plne_jmeno()))
|
return self.plne_jmeno()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Mělo by být částečně vytaženo z Aesopa
|
# Mělo by být částečně vytaženo z Aesopa
|
||||||
|
@ -132,7 +131,6 @@ class Osoba(SeminarModelBase):
|
||||||
#
|
#
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
|
||||||
class Skola(SeminarModelBase):
|
class Skola(SeminarModelBase):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -185,7 +183,7 @@ class Skola(SeminarModelBase):
|
||||||
blank=True, null=True)
|
blank=True, null=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return force_unicode('%s, %s, %s' % (self.nazev, self.ulice, self.mesto))
|
return '{}, {}, {}'.format(self.nazev, self.ulice, self.mesto)
|
||||||
|
|
||||||
class Prijemce(SeminarModelBase):
|
class Prijemce(SeminarModelBase):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -204,10 +202,12 @@ class Prijemce(SeminarModelBase):
|
||||||
help_text='Které osobě či na jakou adresu se mají zasílat čísla')
|
help_text='Které osobě či na jakou adresu se mají zasílat čísla')
|
||||||
|
|
||||||
# FIXME: možná chceme něco jako vazbu na osobu XOR školu a počet kusů k zaslání
|
# FIXME: možná chceme něco jako vazbu na osobu XOR školu a počet kusů k zaslání
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.osoba.plne_jmeno()
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
|
||||||
class Resitel(SeminarModelBase):
|
class Resitel(SeminarModelBase):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -292,12 +292,11 @@ class Resitel(SeminarModelBase):
|
||||||
else:
|
else:
|
||||||
return 'Akad.'
|
return 'Akad.'
|
||||||
def __str__():
|
def __str__():
|
||||||
return(force_unicode(u"Řešitel ({})".format(self.osoba.plne_jmeno())))
|
return self.osoba.plne_jmeno()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
|
||||||
class Rocnik(SeminarModelBase):
|
class Rocnik(SeminarModelBase):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -317,11 +316,11 @@ class Rocnik(SeminarModelBase):
|
||||||
help_text='Exportuje se jen podle tohoto flagu (ne veřejnosti), a to jen čísla s veřejnou výsledkovkou')
|
help_text='Exportuje se jen podle tohoto flagu (ne veřejnosti), a to jen čísla s veřejnou výsledkovkou')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return force_unicode('%s (%d/%d)' % (self.rocnik, self.prvni_rok, self.prvni_rok+1))
|
return '{} ({}/{})'.format(self.rocnik, self.prvni_rok, self.prvni_rok+1)
|
||||||
|
|
||||||
# Ročník v římských číslech
|
# Ročník v římských číslech
|
||||||
def roman(self):
|
def roman(self):
|
||||||
return force_unicode(roman(int(self.rocnik)))
|
return roman(int(self.rocnik))
|
||||||
|
|
||||||
def verejne(self):
|
def verejne(self):
|
||||||
return len(self.verejna_cisla()) > 0
|
return len(self.verejna_cisla()) > 0
|
||||||
|
@ -367,7 +366,6 @@ def cislo_pdf_filename(self, filename):
|
||||||
return os.path.join('cislo', 'pdf', rocnik, '{}-{}.pdf'.format(rocnik, self.cislo))
|
return os.path.join('cislo', 'pdf', rocnik, '{}-{}.pdf'.format(rocnik, self.cislo))
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
|
||||||
class Cislo(SeminarModelBase):
|
class Cislo(SeminarModelBase):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -418,7 +416,7 @@ class Cislo(SeminarModelBase):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
# Potenciální DB HOG, pokud by se ročník necachoval
|
# Potenciální DB HOG, pokud by se ročník necachoval
|
||||||
r = Rocnik.cached_rocnik(self.rocnik_id)
|
r = Rocnik.cached_rocnik(self.rocnik_id)
|
||||||
return force_unicode('%s.%s' % (r.rocnik, self.cislo, ))
|
return '{}.{}'.format(r.rocnik, self.cislo)
|
||||||
|
|
||||||
def verejne(self):
|
def verejne(self):
|
||||||
return self.verejne_db
|
return self.verejne_db
|
||||||
|
@ -428,15 +426,15 @@ class Cislo(SeminarModelBase):
|
||||||
return reverse('seminar_cislo', kwargs={'rocnik': self.rocnik.rocnik, 'cislo': self.cislo})
|
return reverse('seminar_cislo', kwargs={'rocnik': self.rocnik.rocnik, 'cislo': self.cislo})
|
||||||
|
|
||||||
def nasledujici(self):
|
def nasledujici(self):
|
||||||
u"Vrací None, pokud je toto poslední"
|
"Vrací None, pokud je toto poslední"
|
||||||
return self.relativni_v_rocniku(1)
|
return self.relativni_v_rocniku(1)
|
||||||
|
|
||||||
def predchozi(self):
|
def predchozi(self):
|
||||||
u"Vrací None, pokud je toto první"
|
"Vrací None, pokud je toto první"
|
||||||
return self.relativni_v_rocniku(-1)
|
return self.relativni_v_rocniku(-1)
|
||||||
|
|
||||||
def relativni_v_rocniku(self, rel_index):
|
def relativni_v_rocniku(self, rel_index):
|
||||||
u"Číslo o `index` dále v ročníku. None pokud neexistuje."
|
"Číslo o `index` dále v ročníku. None pokud neexistuje."
|
||||||
cs = self.rocnik.cisla.order_by('cislo').all()
|
cs = self.rocnik.cisla.order_by('cislo').all()
|
||||||
i = list(cs).index(self) + rel_index
|
i = list(cs).index(self) + rel_index
|
||||||
if (i < 0) or (i >= len(cs)):
|
if (i < 0) or (i >= len(cs)):
|
||||||
|
@ -453,7 +451,6 @@ class Cislo(SeminarModelBase):
|
||||||
return c
|
return c
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
|
||||||
class Organizator(SeminarModelBase):
|
class Organizator(SeminarModelBase):
|
||||||
# zmena dedicnosti z models.Model na SeminarModelBase, potencialni vznik bugu
|
# zmena dedicnosti z models.Model na SeminarModelBase, potencialni vznik bugu
|
||||||
|
|
||||||
|
@ -467,7 +464,7 @@ class Organizator(SeminarModelBase):
|
||||||
editable=False
|
editable=False
|
||||||
)
|
)
|
||||||
|
|
||||||
organizuje_od = models.DateTimeField('Organizuje od', blank=False, null=False, default="1900-01-01T00:00:00")
|
organizuje_od = models.DateTimeField('Organizuje od', blank=True, null=True)
|
||||||
|
|
||||||
organizuje_do = models.DateTimeField('Organizuje do', blank=True, null=True)
|
organizuje_do = models.DateTimeField('Organizuje do', blank=True, null=True)
|
||||||
|
|
||||||
|
@ -486,18 +483,17 @@ class Organizator(SeminarModelBase):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.osoba.prezdivka:
|
if self.osoba.prezdivka:
|
||||||
return u"%s '%s' %s".format(self.osoba.jmeno,
|
return "{} '{}' {}".format(self.osoba.jmeno,
|
||||||
self.osoba.prezdivka,
|
self.osoba.prezdivka,
|
||||||
self.osoba.prijmeni)
|
self.osoba.prijmeni)
|
||||||
else:
|
else:
|
||||||
return u"%s %s".format(self.osoba.jmeno, self.osoba.prijmeni)
|
return "{} {}".format(self.osoba.jmeno, self.osoba.prijmeni)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = 'Organizátor'
|
verbose_name = 'Organizátor'
|
||||||
verbose_name_plural = 'Organizátoři'
|
verbose_name_plural = 'Organizátoři'
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
|
||||||
class Soustredeni(SeminarModelBase):
|
class Soustredeni(SeminarModelBase):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -546,7 +542,7 @@ class Soustredeni(SeminarModelBase):
|
||||||
help_text='Exportuje se jen podle tohoto flagu (ne veřejnosti)')
|
help_text='Exportuje se jen podle tohoto flagu (ne veřejnosti)')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return force_unicode('%s (%s)'.format(self.misto, self.datum_zacatku))
|
return '{} ({})'.format(self.misto, self.datum_zacatku)
|
||||||
|
|
||||||
def verejne(self):
|
def verejne(self):
|
||||||
return self.verejne_db
|
return self.verejne_db
|
||||||
|
@ -559,7 +555,6 @@ class Soustredeni(SeminarModelBase):
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
|
||||||
class Problem(SeminarModelBase):
|
class Problem(SeminarModelBase):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -616,7 +611,7 @@ class Problem(SeminarModelBase):
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return force_unicode('%s' % (self.nazev, ))
|
return self.nazev
|
||||||
|
|
||||||
# Implicitini implementace, jednotlivé dědící třídy si přepíšou
|
# Implicitini implementace, jednotlivé dědící třídy si přepíšou
|
||||||
def kod_v_rocniku(self):
|
def kod_v_rocniku(self):
|
||||||
|
@ -649,7 +644,7 @@ class Problem(SeminarModelBase):
|
||||||
if self.body:
|
if self.body:
|
||||||
b = self.body
|
b = self.body
|
||||||
pocet_bodu = int(b) if int(b) == b else b
|
pocet_bodu = int(b) if int(b) == b else b
|
||||||
return u"({}\u2009b)".format(pocet_bodu) if self.body else ""
|
return "({}\u2009b)".format(pocet_bodu) if self.body else ""
|
||||||
|
|
||||||
class Tema(Problem):
|
class Tema(Problem):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -670,8 +665,8 @@ class Tema(Problem):
|
||||||
def kod_v_rocniku(self):
|
def kod_v_rocniku(self):
|
||||||
if self.stav == 'zadany':
|
if self.stav == 'zadany':
|
||||||
if self.nadproblem:
|
if self.nadproblem:
|
||||||
return force_unicode(self.nadproblem.kod_v_rocniku()+".t{}".format(self.kod))
|
return self.nadproblem.kod_v_rocniku()+".t{}".format(self.kod)
|
||||||
return force_unicode("t{}".format(self.kod))
|
return "t{}".format(self.kod)
|
||||||
return '<Není zadaný>'
|
return '<Není zadaný>'
|
||||||
|
|
||||||
class Clanek(Problem):
|
class Clanek(Problem):
|
||||||
|
@ -686,7 +681,7 @@ class Clanek(Problem):
|
||||||
# Nemělo by být potřeba
|
# Nemělo by být potřeba
|
||||||
# if self.nadproblem:
|
# if self.nadproblem:
|
||||||
# return force_unicode(self.nadproblem.kod_v_rocniku()+".c{}".format(self.kod))
|
# return force_unicode(self.nadproblem.kod_v_rocniku()+".c{}".format(self.kod))
|
||||||
return force_unicode("c{}".format(self.kod))
|
return "c{}".format(self.kod)
|
||||||
return '<Není zadaný>'
|
return '<Není zadaný>'
|
||||||
|
|
||||||
class Text(SeminarModelBase):
|
class Text(SeminarModelBase):
|
||||||
|
@ -727,16 +722,15 @@ class Uloha(Problem):
|
||||||
|
|
||||||
def kod_v_rocniku(self):
|
def kod_v_rocniku(self):
|
||||||
if self.stav == 'zadany':
|
if self.stav == 'zadany':
|
||||||
name=u"{}.u{}".format(self.cislo_zadani.cislo,self.kod)
|
name="{}.u{}".format(self.cislo_zadani.cislo,self.kod)
|
||||||
if self.nadproblem:
|
if self.nadproblem:
|
||||||
return force_unicode(self.nadproblem.kod_v_rocniku()+name)
|
return self.nadproblem.kod_v_rocniku()+name
|
||||||
return force_unicode(name)
|
return name
|
||||||
return '<Není zadaný>'
|
return '<Není zadaný>'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
|
||||||
class Reseni(SeminarModelBase):
|
class Reseni(SeminarModelBase):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -783,8 +777,7 @@ class Reseni(SeminarModelBase):
|
||||||
help_text='Udává, zda je řešení zveřejněno')
|
help_text='Udává, zda je řešení zveřejněno')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return force_unicode(u"%s: %s".format(self.resitel.osoba.plne_jmeno(),
|
return "{}: {}".format(self.resitel.osoba.plne_jmeno(), self.problem.nazev)
|
||||||
self.problem.nazev))
|
|
||||||
# NOTE: Potenciální DB HOG (bez select_related)
|
# NOTE: Potenciální DB HOG (bez select_related)
|
||||||
|
|
||||||
## Pravdepodobne uz nebude potreba:
|
## Pravdepodobne uz nebude potreba:
|
||||||
|
@ -814,6 +807,9 @@ class Hodnoceni(SeminarModelBase):
|
||||||
|
|
||||||
problem = models.ForeignKey(Problem, verbose_name='problém')
|
problem = models.ForeignKey(Problem, verbose_name='problém')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "{}, {}, {}".format(self.problem, self.reseni, self.body)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## FIXME: Budeme řešit později, pokud to bude potřeba.
|
## FIXME: Budeme řešit později, pokud to bude potřeba.
|
||||||
|
@ -849,7 +845,6 @@ def generate_filename(self, filename):
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
|
||||||
class PrilohaReseni(SeminarModelBase):
|
class PrilohaReseni(SeminarModelBase):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -871,10 +866,9 @@ class PrilohaReseni(SeminarModelBase):
|
||||||
help_text='Neveřejná poznámka k příloze řešení (plain text), např. o původu')
|
help_text='Neveřejná poznámka k příloze řešení (plain text), např. o původu')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return force_unicode(self.soubor)
|
return self.soubor
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
|
||||||
class Pohadka(SeminarModelBase):
|
class Pohadka(SeminarModelBase):
|
||||||
u"""Kus pohádky před/za úlohou v čísle"""
|
u"""Kus pohádky před/za úlohou v čísle"""
|
||||||
|
|
||||||
|
@ -917,11 +911,10 @@ class Pohadka(SeminarModelBase):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
uryvek = self.text if len(self.text) < 50 else self.text[:(50-3)]+"..."
|
uryvek = self.text if len(self.text) < 50 else self.text[:(50-3)]+"..."
|
||||||
return force_unicode(uryvek)
|
return uryvek
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
|
||||||
class Soustredeni_Ucastnici(SeminarModelBase):
|
class Soustredeni_Ucastnici(SeminarModelBase):
|
||||||
# zmena dedicnosti z models.Model na SeminarModelBase, potencialni vznik bugu
|
# zmena dedicnosti z models.Model na SeminarModelBase, potencialni vznik bugu
|
||||||
|
|
||||||
|
@ -942,11 +935,10 @@ class Soustredeni_Ucastnici(SeminarModelBase):
|
||||||
help_text='Neveřejná poznámka k účasti (plain text)')
|
help_text='Neveřejná poznámka k účasti (plain text)')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return force_unicode('%s na %s'.format(self.resitel, self.soustredeni))
|
return '{} na {}'.format(self.resitel, self.soustredeni)
|
||||||
# NOTE: Poteciální DB HOG bez select_related
|
# NOTE: Poteciální DB HOG bez select_related
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
|
||||||
class Soustredeni_Organizatori(SeminarModelBase):
|
class Soustredeni_Organizatori(SeminarModelBase):
|
||||||
# zmena dedicnosti z models.Model na SeminarModelBase, potencialni vznik bugu
|
# zmena dedicnosti z models.Model na SeminarModelBase, potencialni vznik bugu
|
||||||
|
|
||||||
|
@ -967,13 +959,12 @@ class Soustredeni_Organizatori(SeminarModelBase):
|
||||||
help_text='Neveřejná poznámka k účasti organizátora (plain text)')
|
help_text='Neveřejná poznámka k účasti organizátora (plain text)')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return force_unicode('%s na %s'.format(self.organizator, self.soustredeni))
|
return '{} na {}'.format(self.organizator, self.soustredeni)
|
||||||
# NOTE: Poteciální DB HOG bez select_related
|
# NOTE: Poteciální DB HOG bez select_related
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
|
||||||
class Konfera(models.Model):
|
class Konfera(models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'seminar_konfera'
|
db_table = 'seminar_konfera'
|
||||||
|
@ -1023,12 +1014,11 @@ class Konfera(models.Model):
|
||||||
upload_to = generate_filename_konfera, blank=True)
|
upload_to = generate_filename_konfera, blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return force_unicode(u"%s: (%s)".format(self.nazev, self.soustredeni))
|
return "{}: ({})".format(self.nazev, self.soustredeni)
|
||||||
|
|
||||||
|
|
||||||
# Vazebna tabulka. Mozna se generuje automaticky.
|
# Vazebna tabulka. Mozna se generuje automaticky.
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
|
||||||
class Reseni_Resitele(models.Model):
|
class Reseni_Resitele(models.Model):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -1045,11 +1035,10 @@ class Reseni_Resitele(models.Model):
|
||||||
reseni = models.ForeignKey(Reseni, verbose_name='řešení')
|
reseni = models.ForeignKey(Reseni, verbose_name='řešení')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return force_unicode('%s od %s'.format(self.reseni, self.resitel))
|
return '{} od {}'.format(self.reseni, self.resitel)
|
||||||
# NOTE: Poteciální DB HOG bez select_related
|
# NOTE: Poteciální DB HOG bez select_related
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
|
||||||
class Konfery_Ucastnici(models.Model):
|
class Konfery_Ucastnici(models.Model):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -1069,7 +1058,7 @@ class Konfery_Ucastnici(models.Model):
|
||||||
help_text='Neveřejná poznámka k účasti (plain text)')
|
help_text='Neveřejná poznámka k účasti (plain text)')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return force_unicode('%s na %s'.format(self.resitel, self.konfera, ))
|
return '{} na {}'.format(self.resitel, self.konfera)
|
||||||
# NOTE: Poteciální DB HOG bez select_related
|
# NOTE: Poteciální DB HOG bez select_related
|
||||||
|
|
||||||
class Obrazek(SeminarModelBase):
|
class Obrazek(SeminarModelBase):
|
||||||
|
@ -1283,6 +1272,12 @@ class Nastaveni(SingletonModel):
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class Novinky(models.Model):
|
class Novinky(models.Model):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = 'Novinka'
|
||||||
|
verbose_name_plural = 'Novinky'
|
||||||
|
ordering = ['-datum']
|
||||||
|
|
||||||
datum = models.DateField(auto_now_add=True)
|
datum = models.DateField(auto_now_add=True)
|
||||||
|
|
||||||
text = models.TextField('Text novinky', blank=True, null=True)
|
text = models.TextField('Text novinky', blank=True, null=True)
|
||||||
|
@ -1302,9 +1297,3 @@ class Novinky(models.Model):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '[' + str(self.datum) + '] ' + self.text[0:50]
|
return '[' + str(self.datum) + '] ' + self.text[0:50]
|
||||||
|
|
||||||
class Meta:
|
|
||||||
verbose_name = 'Novinka'
|
|
||||||
verbose_name_plural = 'Novinky'
|
|
||||||
ordering = ['-datum']
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue