Esempio n. 1
0
 def get(self, request, bundle_id):
     bundle = get_object_or_404(models.ApplicationBundle, pk=int(bundle_id))
     has_access = request.user.profile.should_have_access_to(bundle)
     if not bundle.bundled_pdf or not has_access:
         raise Http404(
             "There doesn't seem to be a PDF associated with these "
             "applications. If you think this is an error, please contact "
             "Code for America.")
     BundlesService.mark_opened(bundle, request.user)
     return HttpResponse(bundle.bundled_pdf, content_type="application/pdf")
Esempio n. 2
0
 def get(self, request, bundle_id):
     bundle = get_object_or_404(models.ApplicationBundle, pk=int(bundle_id))
     if bundle.organization_id != request.user.profile.organization_id:
         return not_allowed(request)
     BundlesService.mark_opened(bundle, request.user)
     filename, pdf_bytes = PDFService.get_concatenated_printout_for_bundle(
         request.user, bundle)
     response = HttpResponse(pdf_bytes, content_type='application/pdf')
     response['Content-Disposition'] = 'filename="{}"'.format(filename)
     return response
Esempio n. 3
0
 def get(self, request, bundle_id):
     bundle = get_object_or_404(models.ApplicationBundle, pk=int(bundle_id))
     has_access = request.user.profile.should_have_access_to(bundle)
     if not bundle.bundled_pdf or not has_access:
         raise Http404(
             "There doesn't seem to be a PDF associated with these "
             "applications. If you think this is an error, please contact "
             "Code for America.")
     BundlesService.mark_opened(bundle, request.user)
     return HttpResponse(bundle.bundled_pdf, content_type="application/pdf")
Esempio n. 4
0
 def get(self, request, bundle_id):
     bundle = get_object_or_404(
         models.ApplicationBundle,
         pk=int(bundle_id))
     if bundle.organization_id != request.user.profile.organization_id:
         return not_allowed(request)
     BundlesService.mark_opened(bundle, request.user)
     filename, pdf_bytes = PDFService.get_concatenated_printout_for_bundle(
         request.user, bundle)
     response = HttpResponse(
         pdf_bytes, content_type='application/pdf')
     response['Content-Disposition'] = 'filename="{}"'.format(filename)
     return response
Esempio n. 5
0
 def get(self, request, bundle_id):
     bundle = get_object_or_404(models.ApplicationBundle, pk=int(bundle_id))
     has_access = request.user.profile.should_have_access_to(bundle)
     if not has_access:
         return not_allowed(request)
     submissions = list(
         request.user.profile.filter_submissions(bundle.submissions.all()))
     forms = [
         DisplayFormService.get_display_form_for_user_and_submission(
             request.user, submission) for submission in submissions
     ]
     context = dict(bundle=bundle,
                    forms=forms,
                    count=len(submissions),
                    show_pdf=bool(bundle.bundled_pdf),
                    app_ids=[sub.id for sub in submissions],
                    bundled_pdf_url=bundle.get_pdf_bundle_url())
     BundlesService.mark_opened(bundle, request.user)
     return TemplateResponse(request, "app_bundle.jinja", context)
Esempio n. 6
0
 def get(self, request, bundle_id):
     bundle = get_object_or_404(models.ApplicationBundle, pk=int(bundle_id))
     has_access = request.user.profile.should_have_access_to(bundle)
     if not has_access:
         return not_allowed(request)
     submissions = list(
         request.user.profile.filter_submissions(bundle.submissions.all()))
     forms = [
         submission.get_display_form_for_user(request.user)
         for submission in submissions]
     context = dict(
         bundle=bundle,
         forms=forms,
         count=len(submissions),
         show_pdf=bool(bundle.bundled_pdf),
         app_ids=[sub.id for sub in submissions],
         bundled_pdf_url=bundle.get_pdf_bundle_url())
     BundlesService.mark_opened(bundle, request.user)
     return TemplateResponse(request, "app_bundle.jinja", context)
Esempio n. 7
0
 def get(self, request):
     submission_ids = self.get_ids_from_params(request)
     submissions = models.FormSubmission.objects.filter(
         pk__in=submission_ids)
     submissions = request.user.profile.filter_submissions(submissions)
     if len(submissions) < len(submission_ids):
         raise Http404(
             "Either those applications have been deleted or you don't "
             "have permission to view those applications")
     bundle = BundlesService\
         .get_or_create_for_submissions_and_user(submissions, request.user)
     forms = [
         DisplayFormService.get_display_form_for_user_and_submission(
             request.user, submission) for submission in submissions
     ]
     context = dict(bundle=bundle,
                    forms=forms,
                    count=len(submissions),
                    show_pdf=request.user.profile.should_see_pdf(),
                    app_ids=[sub.id for sub in submissions])
     BundlesService.mark_opened(bundle, request.user)
     return TemplateResponse(request, "app_bundle.jinja", context)
Esempio n. 8
0
 def get(self, request):
     submission_ids = self.get_ids_from_params(request)
     submissions = models.FormSubmission.objects.filter(
         pk__in=submission_ids)
     submissions = request.user.profile.filter_submissions(submissions)
     if len(submissions) < len(submission_ids):
         raise Http404(
             "Either those applications have been deleted or you don't "
             "have permission to view those applications")
     bundle = BundlesService\
         .get_or_create_for_submissions_and_user(submissions, request.user)
     forms = [
         submission.get_display_form_for_user(request.user)
         for submission in submissions]
     context = dict(
         bundle=bundle,
         forms=forms,
         count=len(submissions),
         show_pdf=request.user.profile.should_see_pdf(),
         app_ids=[sub.id for sub in submissions]
     )
     BundlesService.mark_opened(bundle, request.user)
     return TemplateResponse(request, "app_bundle.jinja", context)