diff --git a/src/nalodeni/people.py b/src/nalodeni/people.py index 85c2b9b..7e2b664 100644 --- a/src/nalodeni/people.py +++ b/src/nalodeni/people.py @@ -76,6 +76,72 @@ def get_AppUser_districts(request): return rslt +@ensure_csrf_cookie +@login_required(login_url="/prihlaseni") +@role_required(['sso_kodo']) +def eu2019(request, dist=None): + if dist is None: + dist = int(request.POST.get('dist', -1)) + doCsvExport = None != request.POST.get('doCsvExport', None) + + objs = models.Euro2019Interest.objects.all() + + districts = [(-1, ' -- vše dostupné -- ')] + get_AppUser_districts(request) + # filtrujeme jen povolene kraje, nebo vse pro adminy + if dist != -1 and (dist in request.session['spc']['dist'] or 'sso_admin' in request.session['site_perms']): + selDist = dist + objs = objs.filter(district=selDist) + else: + selDist = -1 + + if doCsvExport: + response = HttpResponse(content_type='text/csv') + response['Content-Disposition'] = 'attachment; filename="eu2019-kraj-%s-%s.csv"' % (selDist, date.today()) + + row_headers = [ + "ID", + "Vytvořeno", + "E-mail", + "Kraj", + "PSČ", + "Chci info emailem", + "Chci rozdávat Listy", + "Chci se zapojit", + "Poznámka", + "Datum souhlasu o.ú.", + ] + col_count = len(row_headers) + row_nums = {} + + writer = csv.writer(response) + writer.writerow(row_headers) + for obj in objs: + row = len(row_headers) * [None] + row[0] = obj.id + row[1] = obj.createdStamp + row[2] = obj.email + row[3] = models.AppUser.DISTRICT_CHOICES_STR[obj.district] if obj.district else None + row[4] = obj.postcode + row[5] = 1 if obj.want_info else 0 + row[6] = 1 if obj.want_campaign else 0 + row[7] = 1 if obj.want_be_active else 0 + row[8] = obj.note + row[9] = obj.dc_stamp + + writer.writerow(row) + + return response + + + template = 'people/eu2019.html' + context = { + 'people' : objs, + 'distAvail' : districts, + 'selDist' : selDist, + } + + return render(request, template, context) + @ensure_csrf_cookie @login_required(login_url="/prihlaseni") @role_required(['sso_kodo']) diff --git a/src/nalodeni/templates/people/eu2019.html b/src/nalodeni/templates/people/eu2019.html new file mode 100644 index 0000000..489cff4 --- /dev/null +++ b/src/nalodeni/templates/people/eu2019.html @@ -0,0 +1,81 @@ +{% extends 'pirati_cz.html' %} + +{%block head%} + +{%endblock%} +{%block body%} +
+
+
+
+
+

Seznam EU2019 zájemců o pomoc

+
+ {%csrf_token%} +
+ +
+
+
+
+ +
+
+
+ {% if people|length > 0 %} + {%csrf_token%} + + + + + + + + + + + + {% for p in people %} + + + + + + + + + + + {% endfor %} +
VytvořenoE-mailKrajPSČChci infoChci rozdávatChci se zapojitPoznámka
{{p.createdStamp}}{{p.email}}{{p.get_district_display}}{{p.postcode|default_if_none:'-'}}{%if p.want_info%}ano{%else%}ne{%endif%}{%if p.want_campaign%}ano{%else%}ne{%endif%}{%if p.want_be_active%}ano{%else%}ne{%endif%}{{p.note|default_if_none:'-'}}
+ {%else%} + Žádné položky + {%endif%} +
+
+
+
+
+ +
+
+
+
+   +
+
+
+
+ + +{%endblock%} diff --git a/src/nalodeni/templates/pirati_cz.html b/src/nalodeni/templates/pirati_cz.html index 0f8a706..e8cf18e 100644 --- a/src/nalodeni/templates/pirati_cz.html +++ b/src/nalodeni/templates/pirati_cz.html @@ -155,7 +155,7 @@
- + Pirátská strana NALODĚNÍ @@ -240,6 +240,7 @@
  • Nově přihlášení
  • Čekající registrace
  • Statistiky +
  • EU 2019
  • diff --git a/src/nalodeni/urls.py b/src/nalodeni/urls.py index 39ad285..93e3ea8 100644 --- a/src/nalodeni/urls.py +++ b/src/nalodeni/urls.py @@ -18,6 +18,7 @@ urlpatterns = [ url(r'^eurovolby-2019/$', views.page_eurovolby_2019, name="page_eurovolby_2019"), url(r'^eurovolby-2019/ok/$', views.page_eurovolby_2019, name="page_eurovolby_2019_ok", kwargs={'reg_ok':True}), + url(r'^people/eu2019/$', people.eu2019, name="people_eu2019"), url(r'^paluby/$', views.paluby, name="paluby"), url(r'^posadky/$', views.posadky, name="posadky"),