From 206ddf4abef9fdd674c7f36f13a7fb74b22268b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Koci=C3=A1n?= Date: Fri, 20 Jan 2017 12:13:25 +0100 Subject: [PATCH] =?UTF-8?q?Opravy=20stylu=20p=C5=99i=20merge=20do=20stable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- korektury/views.py | 13 ++++++----- seminar/urls.py | 10 +++++++-- seminar/views.py | 54 +++++++++++++++++++++++++--------------------- 3 files changed, 45 insertions(+), 32 deletions(-) diff --git a/korektury/views.py b/korektury/views.py index 6562f8fd..979830bf 100644 --- a/korektury/views.py +++ b/korektury/views.py @@ -181,11 +181,14 @@ class KorekturyView(generic.TemplateView): o.komentare = o.komentar_set.all() for k in o.komentare: if k.autor in zasluhy: - zasluhy[k.autor]+=1 - else: - zasluhy[k.autor]=1 - zasluhy = [{'autor':jmeno, 'pocet':pocet} for (jmeno,pocet) in zasluhy.items()] - zasluhy.sort(key=lambda z:z['pocet'],reverse=True) + zasluhy[k.autor] += 1 + else: + zasluhy[k.autor] = 1 + zasluhy = [ + {'autor': jmeno, 'pocet': pocet} + for (jmeno, pocet) in zasluhy.items() + ] + zasluhy.sort(key=lambda z: z['pocet'], reverse=True) strany = set(o.strana for o in opravy) opravy_na_stranu = [{'strana': s, 'op_id': opravy.filter(strana=s)} for s in strany] diff --git a/seminar/urls.py b/seminar/urls.py index 7a365748..de5b10d6 100644 --- a/seminar/urls.py +++ b/seminar/urls.py @@ -72,10 +72,16 @@ urlpatterns = [ staff_member_required(views.soustredeniObalkyView), name='seminar_soustredeni_obalky'), url(r'^tex-upload/login/$', views.LoginView, name='seminar_login'), - url(r'^tex-upload/$', staff_member_required(views.texUploadView), name='seminar_tex_upload'), + url( + r'^tex-upload/$', + staff_member_required(views.texUploadView), + name='seminar_tex_upload' + ), # Ceka na autocomplete v3 - #url(r'^autocomplete/organizatori/$', staff_member_required(views.OrganizatorAutocomplete.as_view()), name='seminar_autocomplete_organizator') + # url(r'^autocomplete/organizatori/$', + # staff_member_required(views.OrganizatorAutocomplete.as_view()), + # name='seminar_autocomplete_organizator') ] diff --git a/seminar/views.py b/seminar/views.py index 4b76a1fa..08a27162 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -122,26 +122,31 @@ class StareNovinkyView(generic.ListView): ### Co je M&M -## Organizatori + +# Organizatori def aktivniOrganizatori(rok=date.today().year): - return Organizator.objects.exclude( - organizuje_do_roku__isnull=False, - organizuje_do_roku__lt=rok - ).order_by('user__first_name') + return Organizator.objects.exclude( + organizuje_do_roku__isnull=False, + organizuje_do_roku__lt=rok + ).order_by('user__first_name') + class CojemamOrganizatoriView(generic.ListView): model = Organizator - template_name='seminar/cojemam/organizatori.html' + template_name = 'seminar/cojemam/organizatori.html' queryset = aktivniOrganizatori() + def get_context_data(self, **kwargs): context = super(CojemamOrganizatoriView, self).get_context_data(**kwargs) context['aktivni'] = True return context + class CojemamOrganizatoriStariView(generic.ListView): model = Organizator - template_name='seminar/cojemam/organizatori.html' - queryset = Organizator.objects.exclude(id__in = aktivniOrganizatori()).order_by('-organizuje_do_roku') + template_name = 'seminar/cojemam/organizatori.html' + queryset = Organizator.objects.exclude( + id__in=aktivniOrganizatori()).order_by('-organizuje_do_roku') ### Archiv @@ -807,24 +812,23 @@ def texDownloadView(request, rocnik, cislo): return JsonResponse(response) - # Ceka na autocomplete v3 -#class OrganizatorAutocomplete(autocomplete.Select2QuerySetView): -# def get_queryset(self): -# if not self.request.user.is_authenticated(): -# return Organizator.objects.none() +# class OrganizatorAutocomplete(autocomplete.Select2QuerySetView): +# def get_queryset(self): +# if not self.request.user.is_authenticated(): +# return Organizator.objects.none() # -# qs = aktivniOrganizatori() +# qs = aktivniOrganizatori() # -# if self.q: -# if self.q[0] == "!": -# qs = Organizator.objects.all() -# query = self.q[1:] -# else: -# query = self.q -# qs = qs.filter( -# Q(prezdivka__isstartswith=query)| -# Q(user__first_name__isstartswith=query)| -# Q(user__last_name__isstartswith=query)) +# if self.q: +# if self.q[0] == "!": +# qs = Organizator.objects.all() +# query = self.q[1:] +# else: +# query = self.q +# qs = qs.filter( +# Q(prezdivka__isstartswith=query)| +# Q(user__first_name__isstartswith=query)| +# Q(user__last_name__isstartswith=query)) # -# return qs +# return qs