def log_app_started(request, counties): applicant = ApplicantsService.get_applicant_from_request_or_session( request) return models.ApplicationEvent.log_app_started( applicant_id=applicant.id, counties=counties, referrer=applicant.visitor.referrer, source=applicant.visitor.source, user_agent=request.META.get('HTTP_USER_AGENT'))
def form_started(view, counties): event_name = 'application_started' applicant = ApplicantsService.get_applicant_from_request_or_session( view.request) log_to_mixpanel(distinct_id=applicant.get_uuid(), event_name=event_name, counties=counties, **mixpanel_applicant_data(applicant), **mixpanel_data_from_view_request_user(view))
def form_page_complete(view): """page_name should be the class name of the view instance. """ event_name = 'application_page_complete' applicant = ApplicantsService.get_applicant_from_request_or_session( view.request) log_to_mixpanel(distinct_id=applicant.get_uuid(), event_name=event_name, **mixpanel_applicant_data(applicant), **mixpanel_data_from_view_request_user(view))
def form_started(view, counties): event_name = 'application_started' applicant = ApplicantsService.get_applicant_from_request_or_session( view.request) log_to_mixpanel( distinct_id=applicant.get_uuid(), event_name=event_name, counties=counties, **mixpanel_applicant_data(applicant), **mixpanel_data_from_view_request_user(view))
def form_started(request, counties): event_name = 'application_started' applicant = ApplicantsService.get_applicant_from_request_or_session( request) log_to_mixpanel.delay(distinct_id=applicant.get_uuid(), event_name=event_name, counties=counties, referrer=applicant.visitor.referrer, source=applicant.visitor.source, user_agent=request.META.get('HTTP_USER_AGENT'))
def form_page_complete(request, page_name): """page_name should be the class name of the view instance. """ event_name = 'application_page_complete' applicant = ApplicantsService.get_applicant_from_request_or_session( request) log_to_mixpanel.delay(distinct_id=applicant.get_uuid(), event_name=event_name, url=request.path, page_name=page_name)
def dispatch(self, request, *args, **kwargs): applicant = ApplicantsService.get_applicant_from_request_or_session( request) if not applicant: return redirect(reverse('intake-home')) self.submission = \ SubmissionsService.get_latest_submission_from_applicant( applicant.id) if not self.submission: return redirect(reverse('intake-home')) return super().dispatch(request, *args, **kwargs)
def form_started(request, counties): event_name = 'application_started' applicant = ApplicantsService.get_applicant_from_request_or_session( request) log_to_mixpanel.delay( distinct_id=applicant.get_uuid(), event_name=event_name, counties=counties, referrer=applicant.visitor.referrer, source=applicant.visitor.source, user_agent=request.META.get('HTTP_USER_AGENT'))
def form_page_complete(request, page_name): """page_name should be the class name of the view instance. """ event_name = 'application_page_complete' applicant = ApplicantsService.get_applicant_from_request_or_session( request) log_to_mixpanel.delay( distinct_id=applicant.get_uuid(), event_name=event_name, url=request.path, page_name=page_name)
def form_page_complete(view): """page_name should be the class name of the view instance. """ event_name = 'application_page_complete' applicant = ApplicantsService.get_applicant_from_request_or_session( view.request) log_to_mixpanel( distinct_id=applicant.get_uuid(), event_name=event_name, **mixpanel_applicant_data(applicant), **mixpanel_data_from_view_request_user(view))
def dispatch(self, request, *args, **kwargs): self.session_data = utils.get_form_data_from_session( request, self.session_key) self.applicant = \ ApplicantsService.get_applicant_from_request_or_session(request) response = self.check_for_session_based_redirects() if response: return response self.county_slugs = self.session_data.getlist('counties', []) self.counties = models.County.objects.order_by_name_or_not_listed( ).filter(slug__in=self.county_slugs) self.formatted_county_names = [county.name for county in self.counties] return super().dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): self.session_data = utils.get_form_data_from_session( request, self.session_key) self.applicant = \ ApplicantsService.get_applicant_from_request_or_session(request) response = self.check_for_session_based_redirects() if response: return response self.county_slugs = self.session_data.getlist('counties', []) self.counties = models.County.objects.order_by_name_or_not_listed( ).filter(slug__in=self.county_slugs) self.formatted_county_names = [ county.name for county in self.counties] return super().dispatch(request, *args, **kwargs)
def get_context_data(self): context = super().get_context_data() applicant = ApplicantsService.get_applicant_from_request_or_session( self.request) if applicant: submission = \ SubmissionsService.get_latest_submission_from_applicant( applicant.id) if submission: context['organizations'] = submission.organizations.all() context['qualifies_for_fee_waiver'] = \ submission.qualifies_for_fee_waiver() clear_form_session_data(self.request) return context
def form_validation_failed(view, errors): """ security concerns addressed here: MP gets just keys (avoid PII) std_out gets k-v pair for errors, but misses application identifiers """ event_name = 'application_errors' applicant = ApplicantsService.get_applicant_from_request_or_session( view.request) for error_key, errors in errors.items(): log_to_mixpanel.delay( distinct_id=applicant.get_uuid(), event_name=event_name, error=error_key, **mixpanel_applicant_data(applicant), **mixpanel_data_from_view_request_user(view)) LoggingService.format_and_log( event_name, url=view.request.path, view_name=view.__class__.__name__, field=error_key, errors=errors)
def form_validation_failed(view, request, errors): """ security concerns addressed here: MP gets just keys (avoid PII) std_out gets k-v pair for errors, but misses application identifiers """ event_name = 'application_errors' applicant = ApplicantsService.get_applicant_from_request_or_session( request) for error_key, errors in errors.items(): log_to_mixpanel.delay( distinct_id=applicant.get_uuid(), event_name=event_name, url=request.path, view_name=view.__class__.__name__, error=error_key) LoggingService.format_and_log( event_name, url=request.path, view_name=view.__class__.__name__, field=error_key, errors=errors)
def get_app_id(request): return ApplicantsService.get_applicant_from_request_or_session(request).id