def compo_edit(request, sel_event_id, compo_id): # CHeck for permissions if not request.user.has_perm('kompomaatti.change_compo'): raise Http403 # Get compo compo = get_object_or_404(Compo, pk=compo_id) # Handle form if request.method == "POST": editform = AdminCompoForm(request.POST, instance=compo) if editform.is_valid(): c = editform.save() logger.info('Compo "{}" edited.'.format(c.name), extra={ 'user': request.user, 'event_id': sel_event_id }) return HttpResponseRedirect( reverse('manage-kompomaatti:compos', args=(sel_event_id, ))) else: editform = AdminCompoForm(instance=compo) # Render response return admin_render( request, "admin_kompomaatti/compo_edit.html", { 'compo': compo, 'editform': editform, 'selected_event_id': int(sel_event_id), })
def compo_edit(request, sel_event_id, compo_id): # CHeck for permissions if not request.user.has_perm('kompomaatti.change_compo'): raise Http403 # Get compo compo = get_object_or_404(Compo, pk=compo_id) # Handle form if request.method == "POST": editform = AdminCompoForm(request.POST, instance=compo) if editform.is_valid(): c = editform.save() logger.info('Compo "{}" edited.'.format(c.name), extra={'user': request.user, 'event_id': sel_event_id}) return HttpResponseRedirect(reverse('manage-kompomaatti:compos', args=(sel_event_id,))) else: editform = AdminCompoForm(instance=compo) # Render response return admin_render(request, "admin_kompomaatti/compo_edit.html", { 'compo': compo, 'editform': editform, 'selected_event_id': int(sel_event_id), })
def compo_browse(request, sel_event_id): # Get compos compos = Compo.objects.filter(event_id=int(sel_event_id)) if request.method == "POST" and 'submit-clone' in request.POST: if not request.user.has_perm('kompomaatti.add_compo'): raise Http403 clonecompoform = CloneCompoForm(request.POST) if clonecompoform.is_valid(): clonecompoform.save(event_id=sel_event_id) logger.info('Compos from other event cloned.', extra={ 'user': request.user, 'event_id': sel_event_id }) return HttpResponseRedirect( reverse('manage-kompomaatti:compos', args=(sel_event_id, ))) else: clonecompoform = CloneCompoForm() # Form handling if request.method == "POST" and 'submit-compo' in request.POST: # CHeck for permissions if not request.user.has_perm('kompomaatti.add_compo'): raise Http403 # Handle form compoform = AdminCompoForm(request.POST) if compoform.is_valid(): data = compoform.save(commit=False) data.event_id = int(sel_event_id) data.save() logger.info('Compo "{}" added.'.format(data.name), extra={ 'user': request.user, 'event_id': sel_event_id }) return HttpResponseRedirect( reverse('manage-kompomaatti:compos', args=(sel_event_id, ))) else: compoform = AdminCompoForm() # Render response return admin_render( request, "admin_kompomaatti/compo_browse.html", { 'compos': compos, 'compoform': compoform, 'clonecompoform': clonecompoform, 'selected_event_id': int(sel_event_id), })
def compo_browse(request, sel_event_id): # Get compos compos = Compo.objects.filter(event_id=int(sel_event_id)) if request.method == "POST" and 'submit-clone' in request.POST: if not request.user.has_perm('kompomaatti.add_compo'): raise Http403 clonecompoform = CloneCompoForm(request.POST) if clonecompoform.is_valid(): clonecompoform.save(event_id=sel_event_id) logger.info('Compos from other event cloned.', extra={'user': request.user, 'event_id': sel_event_id}) return HttpResponseRedirect(reverse('manage-kompomaatti:compos', args=(sel_event_id,))) else: clonecompoform = CloneCompoForm() # Form handling if request.method == "POST" and 'submit-compo' in request.POST: # CHeck for permissions if not request.user.has_perm('kompomaatti.add_compo'): raise Http403 # Handle form compoform = AdminCompoForm(request.POST) if compoform.is_valid(): data = compoform.save(commit=False) data.event_id = int(sel_event_id) data.save() logger.info('Compo "{}" added.'.format(data.name), extra={'user': request.user, 'event_id': sel_event_id}) return HttpResponseRedirect(reverse('manage-kompomaatti:compos', args=(sel_event_id,))) else: compoform = AdminCompoForm() # Render response return admin_render(request, "admin_kompomaatti/compo_browse.html", { 'compos': compos, 'compoform': compoform, 'clonecompoform': clonecompoform, 'selected_event_id': int(sel_event_id), })