Browse Source

Merge branch 'opraf' of atrey.karlin.mff.cuni.cz:/akce/MaM/MaMweb/mamweb into opraf

remotes/origin/opraf
Matěj Kocián 9 years ago
parent
commit
3a7206b9d2
  1. 2
      galerie/admin.py
  2. 2
      galerie/autocomplete_light_registry.py
  3. 15
      galerie/urls.py
  4. 2
      korektury/models.py
  5. 4
      korektury/urls.py
  6. 1
      mamweb/settings_common.py
  7. 3
      mamweb/urls.py
  8. 58
      requirements.txt
  9. 2
      seminar/admin.py
  10. 2
      seminar/autocomplete_light_registry.py
  11. 75
      seminar/models.py
  12. 1
      seminar/templates/seminar/archiv/cislo.html
  13. 22
      seminar/templates/seminar/archiv/resitel_uloha.html
  14. 5
      seminar/templates/seminar/archiv/tituly.tex
  15. 2
      seminar/tools.py
  16. 9
      seminar/urls.py
  17. 51
      seminar/views.py

2
galerie/admin.py

@ -5,7 +5,7 @@ from django.contrib import admin
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django import forms from django import forms
from django.db import models from django.db import models
import autocomplete_light from autocomplete_light import shortcuts as autocomplete_light
# akction # akction

2
galerie/autocomplete_light_registry.py

@ -2,7 +2,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import autocomplete_light from autocomplete_light import shortcuts as autocomplete_light
from models import Obrazek, Galerie from models import Obrazek, Galerie
from views import cesta_od_korene from views import cesta_od_korene

15
galerie/urls.py

@ -1,12 +1,13 @@
# coding: utf-8 # coding: utf-8
from django.conf.urls import patterns, include, url from django.conf.urls import patterns, include, url
from . import views
urlpatterns = patterns('', urlpatterns = [
(r'^(?P<pk>\d+)/$', 'galerie.views.nahled'), url(r'^(?P<pk>\d+)/$', views.nahled),
(r'^(?P<pk>\d+)/(?P<fotka>\d+)/$', 'galerie.views.detail'), url(r'^(?P<pk>\d+)/(?P<fotka>\d+)/$', views.detail),
(r'^(?P<galerie>\d+)/new/$', 'galerie.views.new_galerie'), url(r'^(?P<galerie>\d+)/new/$', views.new_galerie),
(r'^(?P<galerie>\d+)/plus/(?P<subgalerie>\d+)/$', 'galerie.views.plus_galerie'), url(r'^(?P<galerie>\d+)/plus/(?P<subgalerie>\d+)/$', views.plus_galerie),
(r'^(?P<galerie>\d+)/minus/(?P<subgalerie>\d+)/$', 'galerie.views.minus_galerie'), url(r'^(?P<galerie>\d+)/minus/(?P<subgalerie>\d+)/$', views.minus_galerie),
) ]

2
korektury/models.py

@ -8,7 +8,7 @@ from django.utils.encoding import force_unicode
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
import subprocess import subprocess
import reversion from reversion import revisions as reversion
# PrilohaReseni method # PrilohaReseni method
def generate_filename(self, filename): def generate_filename(self, filename):

4
korektury/urls.py

@ -5,8 +5,8 @@ from . import views
staff_member_required = user_passes_test(lambda u: u.is_staff) staff_member_required = user_passes_test(lambda u: u.is_staff)
urlpatterns = patterns('', urlpatterns = [
url(r'^korektury/$', staff_member_required(views.KorekturyListView.as_view()), name='korektury-list'), url(r'^korektury/$', staff_member_required(views.KorekturyListView.as_view()), name='korektury-list'),
url(r'^korektury/(?P<pdf>\d+)/$', staff_member_required(views.KorekturyView.as_view()), name='korektury'), url(r'^korektury/(?P<pdf>\d+)/$', staff_member_required(views.KorekturyView.as_view()), name='korektury'),
url(r'^korektury/help/', staff_member_required(views.KorekturyHelpView.as_view()), name='korektury-help'), url(r'^korektury/help/', staff_member_required(views.KorekturyHelpView.as_view()), name='korektury-help'),
) ]

1
mamweb/settings_common.py

@ -240,5 +240,6 @@ LOGGING = {
# MaM specific # MaM specific
SEMINAR_RESENI_DIR = os.path.join(BASE_DIR, 'media', 'reseni') SEMINAR_RESENI_DIR = os.path.join(BASE_DIR, 'media', 'reseni')
SEMINAR_KONFERY_DIR = os.path.join(BASE_DIR, 'media', 'konfery')
KOREKTURY_PDF_DIR = os.path.join(BASE_DIR, 'media', 'korektury','pdf') KOREKTURY_PDF_DIR = os.path.join(BASE_DIR, 'media', 'korektury','pdf')
KOREKTURY_IMG_DIR = os.path.join(BASE_DIR, 'media', 'korektury','img') KOREKTURY_IMG_DIR = os.path.join(BASE_DIR, 'media', 'korektury','img')

3
mamweb/urls.py

@ -4,12 +4,13 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.contrib import admin from django.contrib import admin
from django.conf import settings from django.conf import settings
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django import views
urlpatterns = [ urlpatterns = [
# Admin a nastroje # Admin a nastroje
url(r'^admin/', include(admin.site.urls)), # NOQA url(r'^admin/', include(admin.site.urls)), # NOQA
url(r'^ckeditor/', include('ckeditor.urls')), url(r'^ckeditor/', include('ckeditor_uploader.urls')),
url(r'^autocomplete/', include('autocomplete_light.urls')), url(r'^autocomplete/', include('autocomplete_light.urls')),
# Seminarova aplikace (ma vlastni podadresare) # Seminarova aplikace (ma vlastni podadresare)

58
requirements.txt

@ -2,47 +2,47 @@
psycopg2==2.6.1 psycopg2==2.6.1
html5lib==0.9999999 html5lib==0.9999999
ipython==4.0.0 ipython==4.0.1
Pillow==2.9.0 Pillow==3.1.0
pytz==2014.10 pytz==2015.7
six==1.9.0 six==1.10.0
pexpect==3.3 pexpect==4.0.1
traitlets==4.0.0 traitlets==4.0.0
# Django and modules # Django and modules
Django==1.7.10 # Updatable to 1.9 (possibly incompatible) Django==1.8.8
django-bootstrap-sass==0.0.6a0 #django-bootstrap-sass
django-mptt==0.7.3 django-mptt==0.8.0
django-reversion==1.9.3 django-reversion==1.10.0
django-sekizai==0.8.1 django-sekizai==0.9.0
django-countries==3.2 django-countries==3.4.1
django-solo==1.1.0 django-solo==1.1.1
django-ckeditor==4.4.7 # Updatable to 5.0 (some incompatible changes) django-ckeditor==5.0.2
django-flat-theme==0.9.3 django-flat-theme==1.1.3
django-taggit==0.17 django-taggit==0.17.6
django-autocomplete-light==2.2.6 django-autocomplete-light==2.2.10
django-crispy-forms==1.4.0 django-crispy-forms==1.6.0
django-imagekit==3.2.7 django-imagekit==3.3
# Comments # Comments
akismet==0.2.0 akismet==0.2.0
django-fluent-comments==1.0.2 django-fluent-comments==1.1
django-threadedcomments==1.0b1 django-threadedcomments==1.0.1
django-contrib-comments==1.6.1 django-contrib-comments==1.6.2
# debug tools/extensions # debug tools/extensions
django-debug-toolbar==1.4 django-debug-toolbar==1.4
django-extensions==1.5.6 django-extensions==1.6.1
sqlparse==0.1.16 sqlparse==0.1.18
Werkzeug==0.10.4 Werkzeug==0.11.3
# G+, FB authorisation # G+, FB authorisation
# django-allauth==0.19.1 # django-allauth
# oauthlib==0.7.2 # oauthlib
# python-openid==2.2.5 # python-openid
# requests==2.5.3 # requests
# requests-oauthlib==0.4.2 # requests-oauthlib

2
seminar/admin.py

@ -12,7 +12,7 @@ from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Soustredeni_Organizatori, Novinky, Organizator from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Soustredeni_Organizatori, Novinky, Organizator
import autocomplete_light from autocomplete_light import shortcuts as autocomplete_light
class UserModelChoiceField(forms.ModelChoiceField): class UserModelChoiceField(forms.ModelChoiceField):

2
seminar/autocomplete_light_registry.py

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import autocomplete_light from autocomplete_light import shortcuts as autocomplete_light
from models import Skola, Resitel, Problem, Organizator from models import Skola, Resitel, Problem, Organizator
from taggit.models import Tag from taggit.models import Tag

75
seminar/models.py

@ -16,6 +16,7 @@ from imagekit.processors import ResizeToFit, Transpose
from PIL import Image from PIL import Image
import os import os
from functools import partial
from cStringIO import StringIO from cStringIO import StringIO
from django.core.files.base import ContentFile from django.core.files.base import ContentFile
@ -23,7 +24,7 @@ from django_countries.fields import CountryField
from solo.models import SingletonModel from solo.models import SingletonModel
from taggit.managers import TaggableManager from taggit.managers import TaggableManager
import reversion from reversion import revisions as reversion
from seminar.utils import roman from seminar.utils import roman
@ -544,13 +545,13 @@ class Reseni(SeminarModelBase):
# PrilohaReseni method # PrilohaReseni method
def generate_filename(self, filename): def generate_filename(self, filename, directory):
clean = filename.replace('/','-').replace('\0', '') clean = filename.replace('/','-').replace('\0', '')
datedir = timezone.now().strftime('%Y-%m') datedir = timezone.now().strftime('%Y-%m')
fname = "%s_%s" % ( fname = "%s_%s" % (
timezone.now().strftime('%Y-%m-%d-%H:%M'), timezone.now().strftime('%Y-%m-%d-%H:%M'),
clean) clean)
return os.path.join(settings.SEMINAR_RESENI_DIR, datedir, fname) return os.path.join(directory, datedir, fname)
@reversion.register(ignore_duplicate_revisions=True) @reversion.register(ignore_duplicate_revisions=True)
@ -570,7 +571,7 @@ class PrilohaReseni(SeminarModelBase):
timestamp = models.DateTimeField(u'vytvořeno', default=timezone.now, blank=True, editable=False) timestamp = models.DateTimeField(u'vytvořeno', default=timezone.now, blank=True, editable=False)
soubor = models.FileField(u'soubor', upload_to = generate_filename) soubor = models.FileField(u'soubor', upload_to = partial(generate_filename,directory=settings.SEMINAR_RESENI_DIR))
poznamka = models.TextField(u'neveřejná poznámka', blank=True, poznamka = models.TextField(u'neveřejná poznámka', blank=True,
help_text=u'Neveřejná poznámka k příloze řešení (plain text), např. o původu') help_text=u'Neveřejná poznámka k příloze řešení (plain text), např. o původu')
@ -734,6 +735,72 @@ class Soustredeni_Organizatori(models.Model):
# NOTE: Poteciální DB HOG bez select_related # NOTE: Poteciální DB HOG bez select_related
@reversion.register(ignore_duplicate_revisions=True)
@python_2_unicode_compatible
class Konfera(models.Model):
class Meta:
db_table = 'seminar_konfera'
verbose_name = u'Konfera'
verbose_name_plural = u'Konfery'
# Interní ID
id = models.AutoField(primary_key = True)
nazev = models.CharField(u'název konfery', max_length=40, help_text = u'Název konfery')
popis = models.TextField(u'popis konfery', blank=True,
help_text=u'Popis konfery k zobrazení na webu')
abstrakt = models.TextField(u'abstrakt', blank=True,
help_text=u'Abstrakt konfery tak, jak byl uveden ve sborníku')
organizator = models.ForeignKey(Organizator, verbose_name=u'organizátor', related_name='konfery',
on_delete = models.SET_NULL, null=True)
ucastnici = models.ManyToManyField(Resitel, verbose_name=u'účastníci konfery',
help_text=u'Seznam účastníků konfery', through='Konfery_Ucastnici')
soustredeni = models.ForeignKey(Soustredeni, verbose_name=u'soustředění', related_name='konfery',
on_delete = models.SET_NULL, null=True)
org_poznamka = models.TextField(u'neveřejná poznámka', blank=True,
help_text=u'Neveřejná poznámka ke konfeře(plain text)')
#prispevek #TODO
TYP_VELETRH = 'veletrh'
TYP_PREZENTACE = 'prezentace'
TYP_CHOICES = [
(TYP_VELETRH, u'Veletrh (postery)'),
(TYP_PREZENTACE, u'Prezentace (přednáška)'),
]
typ_prezentace = models.CharField(u'typ prezentace', max_length=16, choices=TYP_CHOICES, blank=False, default=TYP_VELETRH)
prezentace = models.FileField(u'prezentace',help_text = u'Prezentace nebo fotka posteru',
upload_to = partial(generate_filename,directory=settings.SEMINAR_KONFERY_DIR))
materialy = models.FileField(u'materialy',help_text = u'Další materiály ke konfeře zabalené do jednoho souboru',
upload_to = partial(generate_filename,directory=settings.SEMINAR_KONFERY_DIR))
def __str__(self):
return force_unicode(u"%s: (%s)" % (self.nazev, self.soustredeni))
@reversion.register(ignore_duplicate_revisions=True)
@python_2_unicode_compatible
class Konfery_Ucastnici(models.Model):
class Meta:
db_table = 'seminar_konfery_ucastnici'
verbose_name = u'Účast na konfeře'
verbose_name_plural = u'Účasti na konfeře'
ordering = ['konfera', 'resitel']
# Interní ID
id = models.AutoField(primary_key = True)
resitel = models.ForeignKey(Resitel, verbose_name=u'řešitel')
konfera = models.ForeignKey(Konfera, verbose_name=u'konfera')
poznamka = models.TextField(u'neveřejná poznámka', blank=True,
help_text=u'Neveřejná poznámka k účasti (plain text)')
def __str__(self):
return force_unicode(u'%s na %s' % (self.resitel, self.konfera, ))
# NOTE: Poteciální DB HOG bez select_related
@python_2_unicode_compatible @python_2_unicode_compatible
class VysledkyBase(SeminarModelBase): class VysledkyBase(SeminarModelBase):

1
seminar/templates/seminar/archiv/cislo.html

@ -33,6 +33,7 @@
<ul> <ul>
<li><a href="obalky.pdf">Obálky (PDF)</a></li> <li><a href="obalky.pdf">Obálky (PDF)</a></li>
<li><a href="tituly.tex">Tituly (TeX)</a></li> <li><a href="tituly.tex">Tituly (TeX)</a></li>
<li><a href="vysledkovka.tex">Výsledkovka (TeX)</a></li>
</ul> </ul>
</div> </div>
{% endif %} {% endif %}

22
seminar/templates/seminar/archiv/resitel_uloha.html

@ -0,0 +1,22 @@
{% extends "seminar/archiv/base.html" %}
{% block content %}
<h1> K obálkování </h1>
<table>
<th>
<td>Jméno</td>
{% for u in ulohy %}
<td>{{u.nazev}}
{% endfor %}
</th>
{% for row in kdoco %}
<tr>
{% for cell in row%}
<td>{{cell}}</td>
{% endfor %}
</tr>
{% endfor %}
</table>
{% endblock content %}

5
seminar/templates/seminar/archiv/tituly.tex

@ -1,3 +1,8 @@
{% if broken %}
%% POZOR! %% Dva resitele maji stejne makro!!!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{% endif %}
{% autoescape off %} {% autoescape off %}
{% load tex %} {% load tex %}

2
seminar/tools.py

@ -2,7 +2,7 @@
import logging as log import logging as log
from .models import Resitel from .models import Resitel
import reversion from reversion import revisions as reversion
def merge_props(r1, r2, prop, pretend=True, smaller=False, equal=True): def merge_props(r1, r2, prop, pretend=True, smaller=False, equal=True):
"""Merge r2.`prop` into r1.`prop`. """Merge r2.`prop` into r1.`prop`.

9
seminar/urls.py

@ -1,10 +1,12 @@
from django.conf.urls import * # NOQA from django.conf.urls import * # NOQA
from django.conf.urls import patterns, url from django.conf.urls import patterns, url
from django.contrib.auth.decorators import user_passes_test
from . import views, export from . import views, export
from utils import staff_member_required from utils import staff_member_required
urlpatterns = patterns('', staff_member_required = user_passes_test(lambda u: u.is_staff)
urlpatterns = [
url(r'^co-je-MaM/organizatori/$', views.CojemamOrganizatoriView.as_view(), name='organizatori'), url(r'^co-je-MaM/organizatori/$', views.CojemamOrganizatoriView.as_view(), name='organizatori'),
url(r'^co-je-MaM/organizatori/organizovali/$', views.CojemamOrganizatoriStariView.as_view(), name='stari_organizatori'), url(r'^co-je-MaM/organizatori/organizovali/$', views.CojemamOrganizatoriStariView.as_view(), name='stari_organizatori'),
@ -43,7 +45,8 @@ urlpatterns = patterns('',
staff_member_required(views.TitulyView), name='seminar_cislo_titul'), staff_member_required(views.TitulyView), name='seminar_cislo_titul'),
url(r'^stav$', url(r'^stav$',
staff_member_required(views.StavDatabazeView), name='stav_databaze'), staff_member_required(views.StavDatabazeView), name='stav_databaze'),
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>\d+)/resitel_uloha.html$',
staff_member_required(views.resitelUlohaView),name='seminar_cislo_resitel_uloha'),
url(r'^soustredeni/(?P<soustredeni>\d+)/obalky.pdf', url(r'^soustredeni/(?P<soustredeni>\d+)/obalky.pdf',
staff_member_required(views.soustredeniObalkyView),name='seminar_soustredeni_obalky'), staff_member_required(views.soustredeniObalkyView),name='seminar_soustredeni_obalky'),
]
)

51
seminar/views.py

@ -3,7 +3,7 @@
from django.shortcuts import get_object_or_404, render from django.shortcuts import get_object_or_404, render
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
from django.views import generic from django.views import generic
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.http import Http404 from django.http import Http404
@ -356,7 +356,7 @@ class CisloObalkyStruct:
# Vraci QuerySet aktualnich resitelu = nekdy neco poslali, ale jeste neodmaturovali # Vraci QuerySet aktualnich resitelu = nekdy neco poslali, ale jeste neodmaturovali
def aktualniResitele(rocnik): def aktualniResitele(rocnik):
letos = Rocnik.objects.filter(rocnik = rocnik).first() letos = Rocnik.objects.get(rocnik = rocnik)
return Resitel.objects.filter(rok_maturity__gt = letos.prvni_rok) return Resitel.objects.filter(rok_maturity__gt = letos.prvni_rok)
# # ALERT: pokud nekdo nema vypleny rok maturity, tak neni aktualni, protoze Karel Tesar a jini # # ALERT: pokud nekdo nema vypleny rok maturity, tak neni aktualni, protoze Karel Tesar a jini
# return Resitel.objects.filter(Q(rok_maturity__gt = letos.prvni_rok)|Q(rok_maturity = None)) # return Resitel.objects.filter(Q(rok_maturity__gt = letos.prvni_rok)|Q(rok_maturity = None))
@ -371,8 +371,8 @@ def aktivniResitele(rocnik,cislo):
aktualni_resitele = aktualniResitele(rocnik) aktualni_resitele = aktualniResitele(rocnik)
letos.rocnik = Rocnik.objects.filter(rocnik = rocnik).first() letos.rocnik = Rocnik.objects.get(rocnik = rocnik)
loni.rocnik = Rocnik.objects.filter(rocnik = int(rocnik)-1).first() loni.rocnik = Rocnik.objects.get(rocnik = int(rocnik)-1)
letos.cisla = Cislo.objects.filter(rocnik=letos.rocnik,cislo__lte = cislo) letos.cisla = Cislo.objects.filter(rocnik=letos.rocnik,cislo__lte = cislo)
loni.cisla = Cislo.objects.filter(rocnik=loni.rocnik) loni.cisla = Cislo.objects.filter(rocnik=loni.rocnik)
if int(cislo) > 3: if int(cislo) > 3:
@ -404,24 +404,53 @@ def obalkyView(request,resitele):
shutil.rmtree(tempdir) shutil.rmtree(tempdir)
return response return response
def resitelUlohaView(request,rocnik,cislo):
rocnik = Rocnik.objects.get(rocnik=rocnik)
cislo = Cislo.objects.get(rocnik=rocnik,cislo=cislo)
reseni = Reseni.objects.filter(cislo_body=cislo).order_by('resitel')
# TODO: Nasledujici 4 radky jsou fuj. Znate neco lepsiho?
resitele = list(set([r.resitel for r in reseni]))
resitele.sort(key=lambda r: (r.prijmeni,r.jmeno))
ulohy = list(set([r.problem for r in reseni]))
ulohy.sort(key=lambda u: (u.typ,u.kod))
kdoco = []
for r in resitele:
res_ulohy = [r.jmeno+" "+r.prijmeni]
for u in ulohy:
try:
rsni = reseni.get(resitel=r,problem=u)
res_ulohy.append(rsni.body)
except ObjectDoesNotExist:
res_ulohy.append("")
kdoco.append(res_ulohy)
return render(request, 'seminar/archiv/resitel_uloha.html',{'ulohy':ulohy,'kdoco':kdoco})
### Tituly ### Tituly
# TODO udelat neco jako get_objects_or_404 # TODO udelat neco jako get_objects_or_404
def TitulyView(request, rocnik, cislo): def TitulyView(request, rocnik, cislo):
rocnik_obj = Rocnik.objects.filter(rocnik = rocnik).first() rocnik_obj = Rocnik.objects.get(rocnik = rocnik)
resitele = Resitel.objects.filter(rok_maturity__gte = rocnik_obj.prvni_rok) resitele = Resitel.objects.filter(rok_maturity__gte = rocnik_obj.prvni_rok)
cislo_obj = Cislo.objects.filter(rocnik = rocnik_obj, cislo = cislo).first() cislo_obj = Cislo.objects.get(rocnik = rocnik_obj, cislo = cislo)
asciijmena = []
broken = False
for resitel in resitele: for resitel in resitele:
vys = VysledkyKCisluOdjakziva.objects.filter(resitel = resitel, cislo = cislo_obj).first() try:
if vys == None: vys = VysledkyKCisluOdjakziva.objects.get(resitel = resitel, cislo = cislo_obj)
body = 0
else:
body = vys.body body = vys.body
except ObjectDoesNotExist:
body = 0
resitel.titul = resitel.get_titul(body) resitel.titul = resitel.get_titul(body)
resitel.ascii = unicodedata.normalize('NFKD',resitel.jmeno+resitel.prijmeni).encode("ascii","ignore").replace(" ","") resitel.ascii = unicodedata.normalize('NFKD',resitel.jmeno+resitel.prijmeni).encode("ascii","ignore").replace(" ","")
if resitel.ascii not in asciijmena:
asciijmena.append(resitel.ascii)
else:
broken = True
return render(request, 'seminar/archiv/tituly.tex',{'resitele': resitele}) return render(request, 'seminar/archiv/tituly.tex',{'resitele': resitele,'broken':broken})
### Soustredeni ### Soustredeni

Loading…
Cancel
Save