Vypis tabulky EU2019
This commit is contained in:
parent
8456cedbd9
commit
ea43bfaf5c
|
@ -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'])
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
{% extends 'pirati_cz.html' %}
|
||||
|
||||
{%block head%}
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$("#check_all").on("change", function(){
|
||||
if( $(this).prop('checked') ){
|
||||
$(".people_form input[type='checkbox']").prop("checked", true);
|
||||
} else {
|
||||
$(".people_form input[type='checkbox']").prop("checked", false);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{%endblock%}
|
||||
{%block body%}
|
||||
<div class="row">
|
||||
<div class="medium-12 large-12 columns">
|
||||
<section class="o-section o-section--spaceBot">
|
||||
<div class="o-section-inner">
|
||||
<div class="o-section-block">
|
||||
<h2>Seznam EU2019 zájemců o pomoc</h2>
|
||||
<form action="#" method="POST">
|
||||
{%csrf_token%}
|
||||
<div class="medium-4 large-4 columns">
|
||||
<select name="dist" onChange="this.form.submit()">{% for d in distAvail%}<option value="{{d.0}}"{%if selDist == d.0%} selected="selected"{%endif%}>{{d.1}}</option>{%endfor%}</select>
|
||||
</div>
|
||||
<div class="medium-4 large-4 columns">
|
||||
</div>
|
||||
<div class="medium-4 large-4 columns">
|
||||
<input type="submit" name="doCsvExport" value="CSV export" class="button" style="border: 0px; float:right;"/>
|
||||
</div>
|
||||
</form>
|
||||
<br/>
|
||||
{% if people|length > 0 %}
|
||||
{%csrf_token%}
|
||||
<table class="table-list">
|
||||
<tr>
|
||||
<th>Vytvořeno</th>
|
||||
<th>E-mail</th>
|
||||
<th>Kraj</th>
|
||||
<th>PSČ</th>
|
||||
<th>Chci info</th>
|
||||
<th>Chci rozdávat</th>
|
||||
<th>Chci se zapojit</th>
|
||||
<th>Poznámka</th>
|
||||
</tr>
|
||||
{% for p in people %}
|
||||
<tr>
|
||||
<td>{{p.createdStamp}}</td>
|
||||
<td>{{p.email}}</td>
|
||||
<td>{{p.get_district_display}}</td>
|
||||
<td>{{p.postcode|default_if_none:'-'}}</td>
|
||||
<td>{%if p.want_info%}ano{%else%}ne{%endif%}</td>
|
||||
<td>{%if p.want_campaign%}ano{%else%}ne{%endif%}</td>
|
||||
<td>{%if p.want_be_active%}ano{%else%}ne{%endif%}</td>
|
||||
<td>{{p.note|default_if_none:'-'}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{%else%}
|
||||
<em>Žádné položky</em>
|
||||
{%endif%}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="medium-12 large-12 columns">
|
||||
<section class="o-section o-section--spaceBot">
|
||||
<div class="o-section-inner">
|
||||
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{%endblock%}
|
|
@ -155,7 +155,7 @@
|
|||
<div class="c-top-bar-inner u-cf">
|
||||
|
||||
<div class="top-bar-title">
|
||||
<a href="https://www.pirati.cz/pripoj-se" title='Zpět na hlavní web'>
|
||||
<a href="https://www.pirati.cz/" title='Zpět na hlavní web'>
|
||||
<img src="https://www.pirati.cz/assets/img/brand/logo_napis.svg" alt="Pirátská strana">
|
||||
</a>
|
||||
<span class="title-text">NALODĚNÍ</span>
|
||||
|
@ -240,6 +240,7 @@
|
|||
<li class="c-top-sub-nav__item"><a href="/people/list-new/"{%if request.resolver_match.url_name == 'people_list_new'%} class="is-active"{%endif%}>Nově přihlášení</a>
|
||||
<li class="c-top-sub-nav__item"><a href="/people/pending/"{%if request.resolver_match.url_name == 'people_pending'%} class="is-active"{%endif%}>Čekající registrace</a>
|
||||
<li class="c-top-sub-nav__item"><a href="/stats/reg_counts/"{%if request.resolver_match.url_name == 'stats_reg_counts'%} class="is-active"{%endif%}>Statistiky</a>
|
||||
<li class="c-top-sub-nav__item"><a href="/people/eu2019/"{%if request.resolver_match.url_name == 'people_eu2019'%} class="is-active"{%endif%}>EU 2019</a>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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"),
|
||||
|
|
Loading…
Reference in New Issue