def addeditorgs(request, org_id=None): """ internal form for adding/editing an org Clients should not have access to this page. The accounts field autocomplete exposes ALL funds, and this form also allows the owner of the org to be changed without the email verification done by the org transfer form. Clients should use the much less confusing 'orgedit' view. """ if not request.user.has_perm('events.view_org'): raise PermissionDenied context = {} if org_id: instance = get_object_or_404(Organization, pk=org_id) msg = "Edit Client" else: instance = None msg = "New Client" if request.method == 'POST': form = IOrgForm(request.user, request.POST, instance=instance) if form.is_valid(): org = form.save() messages.add_message(request, messages.SUCCESS, 'Changes saved.') # return HttpResponseRedirect(reverse("home", kwargs={'msg':SUCCESS_MSG_ORG})) return HttpResponseRedirect(reverse('orgs:detail', kwargs={'org_id': org.pk})) else: context['form'] = form messages.add_message(request, messages.WARNING, 'Invalid Data. Please try again.') else: form = IOrgForm(request.user, instance=instance) context['form'] = form context['msg'] = msg return render(request, 'form_crispy.html', context)
def addeditorgs(request, org_id=None): """form for adding an org """ # need to fix this context = {} edit_perms = ('events.edit_org',) # mk_perms = ('events.add_org',) if org_id: instance = get_object_or_404(Organization, pk=org_id) msg = "Edit Client" if not (request.user.has_perms(edit_perms) or request.user.has_perms(edit_perms, instance)): raise PermissionDenied else: instance = None msg = "New Client" if not request.user.has_perms(edit_perms): raise PermissionDenied if request.method == 'POST': formset = IOrgForm(request.POST, instance=instance) if formset.is_valid(): org = formset.save() messages.add_message(request, messages.SUCCESS, 'Changes saved.') # return HttpResponseRedirect(reverse('events.views.admin', kwargs={'msg':SUCCESS_MSG_ORG})) return HttpResponseRedirect(reverse('orgs:detail', kwargs={'org_id': org.pk})) else: context['formset'] = formset messages.add_message(request, messages.WARNING, 'Invalid Data. Please try again.') else: formset = IOrgForm(instance=instance) context['formset'] = formset context['msg'] = msg return render(request, 'form_crispy.html', context)
def addeditorgs(request,id=None): """form for adding an org """ # need to fix this context = RequestContext(request) if id: instance = get_object_or_404(Organization,pk=id) msg = "Edit Client" else: instance= None msg = "New Client" if request.method == 'POST': formset = IOrgForm(request.POST,instance=instance) if formset.is_valid(): formset.save() #return HttpResponseRedirect(reverse('events.views.admin', kwargs={'msg':SUCCESS_MSG_ORG})) return HttpResponseRedirect(reverse('events.views.orgs.vieworgs')) else: context['formset'] = formset else: formset = IOrgForm(instance=instance) context['formset'] = formset context['msg'] = msg return render_to_response('form_crispy.html', context)
def addeditorgs(request, org_id=None): """ internal form for adding/editing an org Clients should not have access to this page. The accounts field autocomplete exposes ALL funds, and this form also allows the owner of the org to be changed without the email verification done by the org transfer form. Clients should use the much less confusing 'orgedit' view. """ if not request.user.has_perm('events.view_org'): raise PermissionDenied context = {} if org_id: instance = get_object_or_404(Organization, pk=org_id) msg = "Edit Client" if not request.user.has_perm('events.edit_org'): raise PermissionDenied else: instance = None msg = "New Client" if not request.user.has_perm('events.list_org_members') \ or not request.user.has_perm('events.transfer_org_ownership'): raise PermissionDenied if request.method == 'POST': form = IOrgForm(request.user, request.POST, instance=instance) if form.is_valid(): if instance: set_revision_comment('Edited', form) else: set_revision_comment('Created client', None) org = form.save() messages.add_message(request, messages.SUCCESS, 'Changes saved.') # return HttpResponseRedirect(reverse("home", kwargs={'msg':SUCCESS_MSG_ORG})) return HttpResponseRedirect( reverse('orgs:detail', kwargs={'org_id': org.pk})) else: context['form'] = form messages.add_message(request, messages.WARNING, 'Invalid Data. Please try again.') else: form = IOrgForm(request.user, instance=instance) context['form'] = form context['msg'] = msg return render(request, 'form_crispy.html', context)
def addeditorgs(request, id=None): """form for adding an org """ # need to fix this context = {} edit_perms = ('events.edit_org', ) mk_perms = ('events.add_org', ) if id: instance = get_object_or_404(Organization, pk=id) msg = "Edit Client" if not (request.user.has_perms(edit_perms) or request.user.has_perms(edit_perms, instance)): raise PermissionDenied else: instance = None msg = "New Client" if not request.user.has_perms(edit_perms): raise PermissionDenied if request.method == 'POST': formset = IOrgForm(request.POST, instance=instance) if formset.is_valid(): org = formset.save() messages.add_message(request, messages.SUCCESS, 'Changes saved.') # return HttpResponseRedirect(reverse('events.views.admin', kwargs={'msg':SUCCESS_MSG_ORG})) return HttpResponseRedirect( reverse('events.views.orgs.orgdetail', kwargs={'id': org.pk})) else: context['formset'] = formset messages.add_message(request, messages.WARNING, 'Invalid Data. Please try again.') else: formset = IOrgForm(instance=instance) context['formset'] = formset context['msg'] = msg return render(request, 'form_crispy.html', context)