def _new_comm(self, request, foia, test, success_msg, appeal=False, thanks=False): """Helper function for sending a new comm""" # pylint: disable=too-many-arguments text = request.POST.get('text') comm_sent = False if text and test: save_foia_comm(foia, foia.user.get_full_name(), text, appeal=appeal, thanks=thanks) messages.success(request, success_msg) comm_sent = True return comm_sent
def admin_fix(request, jurisdiction, jidx, slug, idx): """Send an email from the requests auto email address""" foia = _get_foia(jurisdiction, jidx, slug, idx) if request.method == 'POST': form = FOIAAdminFixForm(request.POST) if form.is_valid(): if form.cleaned_data['email']: foia.email = form.cleaned_data['email'] if form.cleaned_data['other_emails']: foia.other_emails = form.cleaned_data['other_emails'] if form.cleaned_data['from_email']: from_who = form.cleaned_data['from_email'] else: from_who = foia.user.get_full_name() save_foia_comm( foia, from_who, form.cleaned_data['comm'], request.user, snail=form.cleaned_data['snail_mail'], subject=form.cleaned_data['subject'], ) messages.success(request, 'Admin Fix submitted') return redirect(foia) else: form = FOIAAdminFixForm( instance=foia, initial={'subject': foia.default_subject()}, ) context = { 'form': form, 'foia': foia, 'heading': 'Email from Request Address', 'action': 'Submit', 'MAX_ATTACHMENT_NUM': settings.MAX_ATTACHMENT_NUM, 'MAX_ATTACHMENT_SIZE': settings.MAX_ATTACHMENT_SIZE, 'AWS_STORAGE_BUCKET_NAME': settings.AWS_STORAGE_BUCKET_NAME, 'AWS_ACCESS_KEY_ID': settings.AWS_ACCESS_KEY_ID, } return render_to_response( 'forms/foia/admin_fix.html', context, context_instance=RequestContext(request) )
def admin_fix(request, jurisdiction, jidx, slug, idx): """Send an email from the requests auto email address""" foia = _get_foia(jurisdiction, jidx, slug, idx) if request.method == 'POST': form = FOIAAdminFixForm(request.POST) formset = FOIAFileFormSet(request.POST, request.FILES) if form.is_valid() and formset.is_valid(): if form.cleaned_data['email']: foia.email = form.cleaned_data['email'] if form.cleaned_data['other_emails']: foia.other_emails = form.cleaned_data['other_emails'] if form.cleaned_data['from_email']: from_who = form.cleaned_data['from_email'] else: from_who = foia.user.get_full_name() save_foia_comm( foia, from_who, form.cleaned_data['comm'], formset, snail=form.cleaned_data['snail_mail'], subject=form.cleaned_data['subject'], ) messages.success(request, 'Admin Fix submitted') return redirect(foia) else: form = FOIAAdminFixForm( instance=foia, initial={'subject': foia.default_subject()}, ) formset = FOIAFileFormSet(queryset=FOIAFile.objects.none()) context = { 'form': form, 'foia': foia, 'heading': 'Email from Request Address', 'formset': formset, 'action': 'Submit' } return render_to_response('forms/foia/admin_fix.html', context, context_instance=RequestContext(request))