def fotoadmin_create_event(request): if not request.user.cached_groups_names & set(['fotocie', 'webcie']): raise PermissionDenied if request.method == 'POST': form = CreateEventForm(request.POST) if form.is_valid(): cd = form.cleaned_data giedo.fotoadmin_create_event(str(cd['date']), cd['name'], cd['fullHumanName']) else: form = CreateEventForm() events = list(map(basename, glob('%s/20*' % PHOTOS_DIR))) events.sort(reverse=True) return render_to_response('fotos/admin/create.html', {'form': form, 'events': events}, context_instance=RequestContext(request))
def fotoadmin_create_event(request): if not fEs.is_admin(request.user): raise PermissionDenied if request.method == 'POST': form = CreateEventForm(request.POST) if form.is_valid(): cd = form.cleaned_data ret = giedo.fotoadmin_create_event(str(cd['date']), cd['name'], cd['fullHumanName']) if ret.get('success', False): messages.info(request, _('Fotoalbum aangemaakt!')) else: messages.error(request, _('Er is een fout opgetreden: %s') % ret.get('error', _('geen foutmelding'))) return redirect('fotoadmin-move') else: form = CreateEventForm() return render(request, 'fotos/admin/create.html', {'form': form, 'events': list_events()})