def purpose_add(request, provider_id, service_id, policy_id): if request.method == 'POST': try: policy = ServicePrivacyPolicyRule.objects.get(pk=policy_id) except ServicePrivacyPolicyRule.DoesNotExist: policy = None form = PurposeForm(policy, request.POST) if form.is_valid() and policy: form.save() return HttpResponseRedirect(reverse('service_index', kwargs={'provider_id': provider_id, 'service_id': service_id})) else: form = PurposeForm(ServicePrivacyPolicyRule.objects.get(pk=policy_id)) return render(request, 'add.html', {'form': form, 'cancel': reverse('service_index', kwargs={'provider_id': provider_id, 'service_id': service_id})})
def purpose_add(request, request_id, target, target_id): rqst = get_object_or_404(Request, id=request_id) if target == "pref": policy = get_object_or_404(UserPrivacyPrefRule,id=target_id) else: policy = get_object_or_404(UserPrivacyPolicyRule,id=target_id) if request.method == 'POST': form = PurposeForm(policy, request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('request_index', kwargs={'request_id': request_id})) else: form = PurposeForm(policy) return render(request, 'add.html', {'form': form, 'cancel': reverse('request_index', kwargs={'request_id': request_id})})