def get_clearance(result_form, post_data, user, form): """Fetch the clearance or build it form the result form and form. :param result_form: The form get or create a clearance for. :param post_data: The post data to create a clearance form from. :param user: The user to assign this clearance to. :param form: The form to create a new clearance from. """ clearance = result_form.clearance if clearance: clearance = ClearanceForm( post_data, instance=clearance).save(commit=False) if groups.CLEARANCE_CLERK in user.groups.values_list( 'name', flat=True): clearance.user = user else: clearance.supervisor = user else: clearance = form.save(commit=False) clearance.result_form = result_form clearance.user = user if groups.CLEARANCE_CLERK in user.groups.values_list('name', flat=True): clearance.date_team_modified = now() else: clearance.date_supervisor_modified = now() return clearance
def get_clearance(result_form, post_data, user, form): """Fetch the clearance or build it form the result form and form. :param result_form: The form get or create a clearance for. :param post_data: The post data to create a clearance form from. :param user: The user to assign this clearance to. :param form: The form to create a new clearance from. """ clearance = result_form.clearance if clearance: clearance = ClearanceForm(post_data, instance=clearance).save(commit=False) if groups.CLEARANCE_CLERK in user.groups.values_list('name', flat=True): clearance.user = user else: clearance.supervisor = user else: clearance = form.save(commit=False) clearance.result_form = result_form clearance.user = user if groups.CLEARANCE_CLERK in user.groups.values_list('name', flat=True): clearance.date_team_modified = now() else: clearance.date_supervisor_modified = now() return clearance
def post(self, *args, **kwargs): post_data = self.request.POST pk = self.request.POST.get('result_form', None) result_form = get_object_or_404(ResultForm, pk=pk) if 'accept_submit' in post_data: result_form.reject(FormState.CLEARANCE) Clearance.objects.create(result_form=result_form, user=self.request.user) result_form.date_seen = now() result_form.save() return redirect(self.success_url)
def post(self, *args, **kwargs): post_data = self.request.POST tally_id = self.kwargs['tally_id'] pk = session_matches_post_result_form(post_data, self.request) result_form = get_object_or_404(ResultForm, pk=pk, tally__id=tally_id) form_in_intake_state(result_form) url = None if 'is_match' in post_data: # When result form is not assigned a center/station if not result_form.center: station_number = self.request.session.get('station_number') center_number = self.request.session.get('center_number') center = Center.objects.get(code=center_number, tally__id=tally_id) result_form.station_number = station_number result_form.center = center if 'station_number' in self.request.session: del self.request.session['station_number'] if 'center_number' in self.request.session: del self.request.session['center_number'] # send to print cover url = 'intake-printcover' elif 'is_not_match' in post_data: # send to clearance result_form.form_state = FormState.CLEARANCE url = 'intake-clearance' else: del self.request.session['result_form'] result_form.form_state = FormState.UNSUBMITTED result_form.duplicate_reviewed = False url = 'intake' result_form.date_seen = now() result_form.save() return redirect(url, tally_id=tally_id)
def post(self, *args, **kwargs): post_data = self.request.POST pk = session_matches_post_result_form(post_data, self.request) result_form = get_object_or_404(ResultForm, pk=pk) form_in_intake_state(result_form) url = None if 'is_match' in post_data: # send to print cover url = 'intake-printcover' elif 'is_not_match' in post_data: # send to clearance result_form.form_state = FormState.CLEARANCE url = 'intake-clearance' else: del self.request.session['result_form'] result_form.form_state = FormState.UNSUBMITTED url = 'intake' result_form.date_seen = now() result_form.save() return redirect(url)
def post(self, *args, **kwargs): tally_id = kwargs.get('tally_id') post_data = self.request.POST pk = self.request.POST.get('result_form', None) result_form = get_object_or_404(ResultForm, pk=pk, tally__id=tally_id) accept_submit_text_in_post_data = 'accept_submit' in post_data if accept_submit_text_in_post_data: result_form.reject(FormState.CLEARANCE) Clearance.objects.create(result_form=result_form, user=self.request.user.userprofile) result_form.date_seen = now() result_form.save() # Track clearance clerks new clearance case result form processing time if accept_submit_text_in_post_data: encoded_start_time = self.request.session.get( 'encoded_result_form_clearance_start_time') save_result_form_processing_stats(self.request, encoded_start_time, result_form) return redirect(self.success_url, tally_id=tally_id)