Merge branch 'data_migrations' of gimli.ms.mff.cuni.cz:/akce/mam/git/mamweb into data_migrations
This commit is contained in:
commit
e7e57140af
12 changed files with 55 additions and 70 deletions
|
@ -1,7 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from autocomplete_light import shortcuts as autocomplete_light
|
||||
|
||||
from .models import Obrazek, Galerie
|
||||
|
|
|
@ -30,7 +30,7 @@ def obrazek_filename_velky():
|
|||
|
||||
def obrazek_filename(self, filename):
|
||||
gal = self.galerie
|
||||
cislo_gal = force_unicode(gal.pk)
|
||||
cislo_gal = gal.pk
|
||||
|
||||
# najdi kořenovou galerii
|
||||
while (gal.galerie_up):
|
||||
|
@ -39,8 +39,8 @@ def obrazek_filename(self, filename):
|
|||
# soustředění je v cestě jen pokud galerie pod nějaké patří
|
||||
cesta = (
|
||||
['Galerie'] +
|
||||
(["soustredeni_" + force_unicode(gal.soustredeni.pk)] if gal.soustredeni else []) +
|
||||
["galerie_" + cislo_gal, force_unicode(self.nazev)]
|
||||
(["soustredeni_" + gal.soustredeni.pk] if gal.soustredeni else []) +
|
||||
["galerie_" + cislo_gal, self.nazev]
|
||||
)
|
||||
|
||||
return os.path.join(*cesta)
|
||||
|
@ -60,8 +60,8 @@ class Obrazek(models.Model):
|
|||
galerie = models.ForeignKey('Galerie', blank=True, null=True, on_delete=models.SET_NULL)
|
||||
poradi = models.IntegerField('Pořadí', blank=True, null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.obrazek_velky.name)
|
||||
def __str__(self):
|
||||
return self.obrazek_velky.name
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'Obrázek'
|
||||
|
@ -94,7 +94,7 @@ class Galerie(models.Model):
|
|||
on_delete=models.PROTECT)
|
||||
poradi = models.IntegerField('Pořadí', blank = True, null = True)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.nazev
|
||||
class Meta:
|
||||
verbose_name = 'Galerie'
|
||||
|
|
|
@ -3,7 +3,6 @@ import os
|
|||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from django.conf import settings
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.encoding import force_text
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.utils.text import get_valid_filename
|
||||
|
@ -29,7 +28,6 @@ def generate_filename(self, filename):
|
|||
|
||||
|
||||
#@reversion.register(ignore_duplicates=True)
|
||||
#@python_2_unicode_compatible
|
||||
class KorekturovanePDF(models.Model):
|
||||
class Meta:
|
||||
ordering = ['-cas']
|
||||
|
@ -112,7 +110,6 @@ class KorekturovanePDF(models.Model):
|
|||
self.convert()
|
||||
|
||||
@reversion.register(ignore_duplicates=True)
|
||||
@python_2_unicode_compatible
|
||||
class Oprava(models.Model):
|
||||
class Meta:
|
||||
db_table = 'opravy'
|
||||
|
@ -159,7 +156,6 @@ class Oprava(models.Model):
|
|||
|
||||
|
||||
@reversion.register(ignore_duplicates=True)
|
||||
@python_2_unicode_compatible
|
||||
class Komentar(models.Model):
|
||||
class Meta:
|
||||
db_table = 'komentare'
|
||||
|
|
|
@ -13,7 +13,6 @@ from .forms import OpravaForm
|
|||
import subprocess
|
||||
import shutil
|
||||
import os
|
||||
import unicodedata
|
||||
|
||||
class KorekturyHelpView(generic.TemplateView):
|
||||
template_name = 'korektury/help.html'
|
||||
|
|
|
@ -24,6 +24,7 @@ INSTALLED_APPS += (
|
|||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
INTERNAL_IPS = ['127.0.0.1']
|
||||
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = True
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from django.urls import path, include
|
||||
from django.conf.urls.i18n import i18n_patterns
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
from django.contrib import admin
|
||||
from django.conf import settings
|
||||
|
@ -9,30 +8,32 @@ from django.urls import path # As per docs.
|
|||
|
||||
urlpatterns = [
|
||||
|
||||
# Admin a nastroje
|
||||
path('admin/', admin.site.urls), # NOQA
|
||||
path('ckeditor/', include('ckeditor_uploader.urls')),
|
||||
path('autocomplete/', include('autocomplete_light.urls')),
|
||||
# Admin a nastroje
|
||||
path('admin/', admin.site.urls), # NOQA
|
||||
path('ckeditor/', include('ckeditor_uploader.urls')),
|
||||
path('autocomplete/', include('autocomplete_light.urls')),
|
||||
|
||||
# Seminarova aplikace (ma vlastni podadresare)
|
||||
path('', include('seminar.urls')),
|
||||
|
||||
# Korekturovaci aplikace (ma vlastni podadresare)
|
||||
path('', include('korektury.urls')),
|
||||
|
||||
# Prednaskova aplikace (ma vlastni podadresare)
|
||||
path('', include('prednasky.urls')),
|
||||
# Seminarova aplikace (ma vlastni podadresare)
|
||||
path('', include('seminar.urls')),
|
||||
|
||||
# Korekturovaci aplikace (ma vlastni podadresare)
|
||||
path('', include('korektury.urls')),
|
||||
|
||||
# Prednaskova aplikace (ma vlastni podadresare)
|
||||
path('', include('prednasky.urls')),
|
||||
|
||||
# Comments (interni i verejne)
|
||||
path('comments_dj/', include('django_comments.urls')),
|
||||
path('comments_fl/', include('fluent_comments.urls')),
|
||||
# Comments (interni i verejne)
|
||||
path('comments_dj/', include('django_comments.urls')),
|
||||
path('comments_fl/', include('fluent_comments.urls')),
|
||||
|
||||
]
|
||||
|
||||
# This is only needed when using runserver.
|
||||
if settings.DEBUG:
|
||||
urlpatterns += [
|
||||
path('media/<path:path>', views.static.serve, # NOQA
|
||||
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
|
||||
]
|
||||
urlpatterns += staticfiles_urlpatterns()
|
||||
import debug_toolbar
|
||||
urlpatterns += [
|
||||
path('media/<path:path>', views.static.serve, # NOQA
|
||||
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
|
||||
path('__debug__/', include(debug_toolbar.urls)),
|
||||
]
|
||||
urlpatterns += staticfiles_urlpatterns()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.encoding import force_text
|
||||
|
||||
from seminar.models import Organizator, Soustredeni
|
||||
|
@ -16,7 +15,6 @@ STAV_CHOICES = (
|
|||
)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Seznam(models.Model):
|
||||
class Meta:
|
||||
db_table = 'prednasky_seznam'
|
||||
|
@ -30,8 +28,8 @@ class Seznam(models.Model):
|
|||
stav = models.IntegerField('Stav',choices=STAV_CHOICES,default = STAV_NAVRH)
|
||||
|
||||
def __str__(self):
|
||||
return force_unicode("Seznam {}přednášek na {}".format("návrhů "
|
||||
if self.stav == STAV_NAVRH else "", self.soustredeni))
|
||||
return "Seznam {}přednášek na {}".format("návrhů "
|
||||
if self.stav == STAV_NAVRH else "", self.soustredeni)
|
||||
|
||||
|
||||
CHOICES_OBTIZNOST = (
|
||||
|
@ -46,7 +44,6 @@ CHOICES_BODY = (
|
|||
(1, '1'),
|
||||
)
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Prednaska(models.Model):
|
||||
class Meta:
|
||||
db_table = 'prednasky_prednaska'
|
||||
|
@ -65,10 +62,9 @@ class Prednaska(models.Model):
|
|||
seznamy = models.ManyToManyField(Seznam)
|
||||
|
||||
def __str__(self):
|
||||
return force_unicode(u"{} ({})".format(self.nazev, self.org))
|
||||
return "{} ({})".format(self.nazev, self.org)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Hlasovani(models.Model):
|
||||
class Meta:
|
||||
db_table = 'prednasky_hlasovani'
|
||||
|
@ -82,6 +78,6 @@ class Hlasovani(models.Model):
|
|||
seznam = models.ForeignKey(Seznam,null=True,on_delete=models.SET_NULL)
|
||||
|
||||
def __str__(self):
|
||||
return force_unicode("{} dal {} bodů {} v seznamu {}".format(self.ucastnik,
|
||||
self.body, self.prednaska, self.seznam))
|
||||
return "{} dal {} bodů {} v seznamu {}".format(self.ucastnik,
|
||||
self.body, self.prednaska, self.seznam)
|
||||
|
||||
|
|
|
@ -28,13 +28,13 @@ django-imagekit
|
|||
|
||||
# Comments
|
||||
akismet==1.0.1
|
||||
django-fluent-comments==2.0.2
|
||||
django-fluent-comments==2.1
|
||||
django-threadedcomments==1.2
|
||||
django-contrib-comments==1.9.0
|
||||
|
||||
# debug tools/extensions
|
||||
|
||||
django-debug-toolbar==1.9.1
|
||||
django-debug-toolbar==1.11
|
||||
django-extensions==2.1.9
|
||||
sqlparse==0.2.4
|
||||
Werkzeug==0.14.1
|
||||
|
|
|
@ -6,7 +6,6 @@ from django.db import models
|
|||
from django.contrib import auth
|
||||
from django.utils import timezone
|
||||
from django.conf import settings
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.text import slugify
|
||||
from django.urls import reverse
|
||||
|
@ -301,7 +300,7 @@ class Resitel(SeminarModelBase):
|
|||
return 'Prof.'
|
||||
else:
|
||||
return 'Akad.'
|
||||
def __str__():
|
||||
def __str__(self):
|
||||
return self.osoba.plne_jmeno()
|
||||
|
||||
|
||||
|
@ -488,7 +487,7 @@ class Organizator(SeminarModelBase):
|
|||
|
||||
studuje = models.CharField('Studium aj.', max_length = 256,
|
||||
null = True, blank = True,
|
||||
help_text=u"Např. 'Studuje Obecnou fyziku (Bc.), 3. ročník', "
|
||||
help_text="Např. 'Studuje Obecnou fyziku (Bc.), 3. ročník', "
|
||||
"'Vystudovala Diskrétní modely a algoritmy (Mgr.)' nebo "
|
||||
"'Přednáší na MFF'")
|
||||
|
||||
|
@ -496,7 +495,7 @@ class Organizator(SeminarModelBase):
|
|||
null = True, blank = True)
|
||||
|
||||
skola = models.CharField('Škola, kterou studuje', max_length = 256, null=True, blank=True,
|
||||
help_text=u"Škola, např. MFF, VŠCHT, VUT, ... prostě aby se nemuselo psát do studuje"
|
||||
help_text="Škola, např. MFF, VŠCHT, VUT, ... prostě aby se nemuselo psát do studuje"
|
||||
"školu, ale jen obor, možnost zobrazit zvlášť")
|
||||
|
||||
def __str__(self):
|
||||
|
@ -642,8 +641,8 @@ class Problem(SeminarModelBase):
|
|||
def kod_v_rocniku(self):
|
||||
if self.stav == 'zadany':
|
||||
if self.nadproblem:
|
||||
return force_unicode(self.nadproblem.kod_v_rocniku()+".{}".format(self.kod))
|
||||
return force_unicode(str(self.kod))
|
||||
return self.nadproblem.kod_v_rocniku()+".{}".format(self.kod)
|
||||
return str(self.kod)
|
||||
return '<Není zadaný>'
|
||||
|
||||
def verejne(self):
|
||||
|
@ -712,7 +711,7 @@ class Clanek(Problem):
|
|||
if self.stav == 'zadany':
|
||||
# Nemělo by být potřeba
|
||||
# if self.nadproblem:
|
||||
# return force_unicode(self.nadproblem.kod_v_rocniku()+".c{}".format(self.kod))
|
||||
# return self.nadproblem.kod_v_rocniku()+".c{}".format(self.kod)
|
||||
return "c{}".format(self.kod)
|
||||
return '<Není zadaný>'
|
||||
|
||||
|
@ -913,7 +912,7 @@ class PrilohaReseni(SeminarModelBase):
|
|||
|
||||
|
||||
class Pohadka(SeminarModelBase):
|
||||
u"""Kus pohádky před/za úlohou v čísle"""
|
||||
"""Kus pohádky před/za úlohou v čísle"""
|
||||
|
||||
class Meta:
|
||||
db_table = 'seminar_pohadky'
|
||||
|
@ -1252,7 +1251,6 @@ class TextNode(TreeNode):
|
|||
verbose_name = 'text')
|
||||
|
||||
## FIXME: Logiku přesunout do views.
|
||||
#@python_2_unicode_compatible
|
||||
#class VysledkyBase(SeminarModelBase):
|
||||
#
|
||||
# class Meta:
|
||||
|
@ -1275,8 +1273,8 @@ class TextNode(TreeNode):
|
|||
# verbose_name='body za číslo')
|
||||
#
|
||||
# def __str__(self):
|
||||
# return force_unicode(u"%s: %sb (%s)".format(self.resitel.plne_jmeno(), self.body,
|
||||
# str(self.cislo)))
|
||||
# return "%s: %sb (%s)".format(self.resitel.plne_jmeno(), self.body,
|
||||
# str(self.cislo))
|
||||
# # NOTE: DB zatez pri vypisu (ale nepouzivany)
|
||||
|
||||
|
||||
|
@ -1314,7 +1312,6 @@ class TextNode(TreeNode):
|
|||
#
|
||||
#
|
||||
## FIXME: Logiku přesunout do views.
|
||||
#@python_2_unicode_compatible
|
||||
#class VysledkyCelkemKCislu(VysledkyBase):
|
||||
#
|
||||
# class Meta:
|
||||
|
@ -1327,12 +1324,11 @@ class TextNode(TreeNode):
|
|||
#
|
||||
# def __str__(self):
|
||||
# # NOTE: DB HOG (ale nepouzivany)
|
||||
# return force_unicode(u"%s: %sb / %sb (do %s)" % (self.resitel.plne_jmeno(), self.body, self.body_celkem, str(self.cislo)))
|
||||
# return "%s: %sb / %sb (do %s)" % (self.resitel.plne_jmeno(), self.body, self.body_celkem, str(self.cislo))
|
||||
##mozna potreba upravit
|
||||
|
||||
|
||||
@reversion.register(ignore_duplicates=True)
|
||||
@python_2_unicode_compatible
|
||||
class Nastaveni(SingletonModel):
|
||||
|
||||
class Meta:
|
||||
|
@ -1356,7 +1352,6 @@ class Nastaveni(SingletonModel):
|
|||
|
||||
|
||||
@reversion.register(ignore_duplicates=True)
|
||||
@python_2_unicode_compatible
|
||||
class Novinky(models.Model):
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -1 +1 @@
|
|||
{% for sous_ucast in object_list %}{{ sous_ucast.resitel.email }}{% if not forloop.last %}, {% endif %}{% endfor %}
|
||||
{% for sous_ucast in object_list %}{{ sous_ucast.resitel.osoba.email }}{% if not forloop.last %}, {% endif %}{% endfor %}
|
||||
|
|
|
@ -19,7 +19,7 @@ def merge_props(r1, r2, prop, pretend=True, smaller=False, equal=True):
|
|||
r1.__setattr__(prop, a2)
|
||||
elif a2:
|
||||
if equal and a1 != a2:
|
||||
log.warn(u"merge: Ruzna %s: %s VS %s", prop, a1, a2)
|
||||
log.warn("merge: Ruzna %s: %s VS %s", prop, a1, a2)
|
||||
if smaller:
|
||||
if not pretend:
|
||||
r1.__setattr__(prop, min(a1, a2))
|
||||
|
@ -33,16 +33,16 @@ def merge_Resitel(rbase, rmerge, pretend=True):
|
|||
# Ma relace: skola
|
||||
# Je v relaci: user, reseni, soustredeni_ucastnici, vysledky_base(VIEW)
|
||||
|
||||
log.info(u"merge: %s <- %s", unicode(rbase), unicode(rmerge))
|
||||
log.info("merge: %s <- %s", unicode(rbase), unicode(rmerge))
|
||||
|
||||
assert not rbase.user
|
||||
assert not rmerge.user
|
||||
assert rbase != rmerge
|
||||
|
||||
if (rbase.jmeno != rmerge.jmeno) or (rbase.prijmeni != rmerge.prijmeni):
|
||||
log.error(u"merge: Ruzna jmena: %s VS %s", rbase, rmerge)
|
||||
log.error("merge: Ruzna jmena: %s VS %s", rbase, rmerge)
|
||||
if rbase.rok_maturity != rmerge.rok_maturity:
|
||||
log.error(u"merge: Ruzne roky maturity: %s VS %s", rbase.rok_maturity, rmerge.rok_maturity)
|
||||
log.error("merge: Ruzne roky maturity: %s VS %s", rbase.rok_maturity, rmerge.rok_maturity)
|
||||
|
||||
with reversion.create_revision():
|
||||
reversion.set_comment('Merge duplicitnich Resitelu: %r <- %r' % (rbase.pk, rmerge.pk))
|
||||
|
|
|
@ -14,7 +14,6 @@ from django.contrib.auth import authenticate, login
|
|||
from .models import Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Organizator, Resitel, Novinky, Soustredeni_Ucastnici, Pohadka, Tema, Clanek
|
||||
#from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva
|
||||
from . import utils
|
||||
from .unicodecsv import UnicodeWriter
|
||||
from .forms import NameForm
|
||||
|
||||
from datetime import timedelta, date, datetime
|
||||
|
@ -35,7 +34,7 @@ import csv
|
|||
def verejna_temata(rocnik):
|
||||
"""Vrací queryset zveřejněných témat v daném ročníku.
|
||||
"""
|
||||
return Problem.objects.filter(typ=Problem.TYP_TEMA, cislo_zadani__rocnik=rocnik, cislo_zadani__verejne_db=True).order_by('kod')
|
||||
return Tema.objects.filter(rocnik=rocnik).order_by('kod') #FIXME Ještě je potřeba zjistit, jestli je tematko verejne.
|
||||
|
||||
|
||||
def AktualniZadaniView(request):
|
||||
|
@ -629,10 +628,10 @@ 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])
|
||||
writer.writerow([u.osoba.jmeno, u.osoba.prijmeni, str(u.rok_maturity), u.osoba.telefon, u.osoba.email, u.osoba.ulice, u.osoba.mesto, u.osoba.psc, u.osoba.stat.name])
|
||||
return response
|
||||
|
||||
|
||||
|
@ -642,7 +641,7 @@ def soustredeniUcastniciExportView(request,soustredeni):
|
|||
class ClankyResitelView(generic.ListView):
|
||||
model = Problem
|
||||
template_name = 'seminar/clanky/resitelske_clanky.html'
|
||||
queryset = Clanek.objects.filter(stav=Problem.STAV_ZADANY).select_related('cislo_zadani__rocnik').order_by('-cislo_zadani__rocnik__rocnik', 'kod')
|
||||
queryset = Clanek.objects.filter(stav=Problem.STAV_ZADANY).select_related('cislo__rocnik').order_by('-cislo__rocnik__rocnik', 'kod')
|
||||
|
||||
# FIXME: pokud chceme orgoclanky, tak nejak zavest do modelu a podle toho odkomentovat a upravit
|
||||
#class ClankyOrganizatorView(generic.ListView)<F12>:
|
||||
|
|
Loading…
Reference in a new issue