NEW: zobrazeni data nalodeni v seznamu nalodenych, FIX: code formatting and culture

This commit is contained in:
Jarmil 2019-09-24 17:05:06 +02:00
parent f3422771a2
commit 0ed654abd2
5 changed files with 25 additions and 33 deletions

View File

@ -339,6 +339,7 @@ class UserSkill(Model):
ordering = ['tag',]
unique_together = ( ('tag',),)
class UserTopic(Model):
"""
Zájmová témata daného uživatele.
@ -356,8 +357,6 @@ class UserTopic(Model):
unique_together = ( ('tag',),)
class UserForm(Model, DataAudited):
"""
Dotaznik ohledne dovednosti a schopnosti uzivatele.
@ -372,7 +371,7 @@ class UserForm(Model, DataAudited):
class AppRegEmail(Model):
"""
Pozadavky na registraci emailu.
Pozadavky na registraci emailu - sem jdou novi lide, kteri vyplni formular 'jdu do toho'
"""
createdStamp = DateTimeField(_('Uživatel vytvořen'),
default=datetime.datetime.now, blank=False, null=False, editable=False)

View File

@ -34,6 +34,7 @@ from . import auth as nalodeni_auth
# Logger instance
logger = logging.getLogger(__name__)
def role_required(roles=[]):
def decorate(func):
def call(request, *args, **kwargs):
@ -46,6 +47,7 @@ def role_required(roles=[]):
return call
return decorate
def get_AppUser_objects(request):
''' Zkontroluje, že všechny objekty v 'objs' vyhovují přiděleným rolím.
Nevyhovující vyřadí.
@ -57,14 +59,12 @@ def get_AppUser_objects(request):
if 'sso_admin' in sp:
return models.AppUser.objects.all()
objs = models.AppUser.objects.filter(district__in=request.session['spc']['dist'])
return models.AppUser.objects.filter(district__in=request.session['spc']['dist'])
return objs
def get_AppUser_districts(request):
'''Vrátí dostupné kraje podle rolí.'''
if 'sso_admin' in request.session['site_perms']:
return list(models.AppUser.DISTRICT_CHOICES)
@ -132,22 +132,21 @@ def eu2019(request, dist=None):
return response
template = 'people/eu2019.html'
context = {
'people' : objs,
'distAvail' : districts,
'selDist' : selDist,
}
return render(request, 'people/eu2019.html', context)
return render(request, template, context)
@ensure_csrf_cookie
@login_required(login_url="/prihlaseni")
@role_required(['sso_kodo'])
def confirmed(request, newOnly=False, dist=None):
if dist is None:
dist = int(request.POST.get('dist', -1))
""" Seznam nalodenych pasazeru """
dist = dist or int(request.POST.get('dist', -1))
doCsvExport = None != request.POST.get('doCsvExport', None)
objs = get_AppUser_objects(request).order_by('last_name', 'first_name' ,'email')
@ -226,16 +225,13 @@ def confirmed(request, newOnly=False, dist=None):
return response
template = 'people/list.html'
context = {
'people' : objs,
'newOnly' : newOnly,
'distAvail' : districts,
'selDist' : selDist,
}
return render(request, template, context)
return render(request, 'people/list.html', context)
@ensure_csrf_cookie
@ -285,14 +281,12 @@ def pending(request):
objs = objs.filter(emailToken = None)
objs = objs.order_by('etStamp')
template = 'people/pending.html'
context = {
'people' : objs,
'tokenValidAfter' : tokenValidAfter,
'show_all' : show_all,
}
return render(request, template, context)
return render(request, 'people/pending.html', context)
@ -320,7 +314,6 @@ def update(request):
return HttpResponseRedirect('/people/list-new/')
else:
messages.error(request, 'Špatný požadavek.')
return HttpResponseRedirect('/people/list/')
@ -340,12 +333,11 @@ def person_detail(request, id):
messages.error(request, 'K tomuto záznamu nemáte přístup. ')
return redirect('nalodeni:people_list')
template = 'person/detail.html'
context = {
'obj' : obj,
}
return render(request, 'person/detail.html', context)
return render(request, template, context)
@login_required(login_url="/prihlaseni")
@transaction.atomic
@ -389,13 +381,10 @@ def person_edit(request, id):
else:
form = None
template = 'person/edit.html'
context = {
'obj' : obj,
'form' : form,
'AUTH_SERVER' : appSettings.AUTH_SERVER,
}
return render(request, template, context)
return render(request, 'person/edit.html', context)

View File

@ -38,6 +38,7 @@ from . import auth as nalodeni_auth
# Logger instance
logger = logging.getLogger(__name__)
def role_required(roles=[]):
def decorate(func):
def call(request, *args, **kwargs):
@ -50,6 +51,7 @@ def role_required(roles=[]):
return call
return decorate
def get_AppUser_objects(request):
''' Zkontroluje, že všechny objekty v 'objs' vyhovují přiděleným rolím.
Nevyhovující vyřadí.
@ -65,10 +67,10 @@ def get_AppUser_objects(request):
return objs
def get_AppUser_districts(request):
'''Vrátí dostupné kraje podle rolí.'''
if 'sso_admin' in request.session['site_perms']:
return list(models.AppUser.DISTRICT_CHOICES)
@ -100,16 +102,16 @@ def reg_counts(request, dist=None):
objs = objs.annotate( month=TruncMonth('createdStamp')).values('month', 'district').annotate(c=Count('id')).order_by('district','month')
for o in objs:
o['district'] = models.AppUser.DISTRICT_CHOICES_STR[o['district']] if o['district'] is not None else "---"
#print( "%s \t %s \t %s" % (o['district'], o['month'].strftime('%Y-%m'),o['c']))
try:
o['district'] = models.AppUser.DISTRICT_CHOICES_STR[o['district']] if o['district'] is not None else "---"
except KeyError:
o['district'] ="---"
template = 'stats/reg_counts.html'
context = {
'objs' : objs,
'distAvail' : districts,
'selDist' : selDist,
}
return render(request, template, context)
return render(request, 'stats/reg_counts.html', context)

View File

@ -46,6 +46,7 @@ $(document).ready(function(){
<th>Kraj</th>
<th>Uživatel chce</th>
<th>Dovednosti</th>
<th>Datum registrace</th>
<th>Akce</th>
</tr>
{% for p in people %}
@ -59,6 +60,7 @@ $(document).ready(function(){
<td>{{p.get_district_display}}</td>
<td>{{p.get_kind_display}}</td>
<td>{{p.interestedIn|default_if_none:'-'}}</td>
<td>{{p.createdStamp}}</td>
<td>
<a href="{% url 'nalodeni:person_detail' p.id%}">detail</a>,
<a href="{% url 'nalodeni:person_edit' p.id%}">upravit</a>

View File

@ -101,6 +101,8 @@ def page_eurovolby_2019(request, reg_ok=False):
@ensure_csrf_cookie
@transaction.atomic
def join_pirates(request):
""" Zpracovani vyplneneho formulare 'Pridej se k piratum' """
template = 'join_pirates.html'
form = forms.AppRegEmailForm()
@ -180,7 +182,6 @@ def join_pirates(request):
# create registration without sending email
rt = form.instance
rt.dc_stamp = datetime.now()
#rt.etStamp = datetime.now()
rt.save()
request.session['fillFormFor'] = rt.id
@ -191,7 +192,6 @@ def join_pirates(request):
else:
rt = form.instance
rt.dc_stamp = datetime.now()
#rt.etStamp = datetime.now()
rt.save()
nalodeni_auth.sendRegisterTokenReg(rt)