Ejemplo n.º 1
0
    def post(self, request, *args, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])
        assessment = get_object_or_404(Assessment, pk=self.args[1])

        for order, condition_id in enumerate(request.POST.getlist('conditionID')):
            AssessmentCondition.objects.create(condition=Condition.objects.get(pk=condition_id),
                                               assessment=assessment, order=order)

        # set the assessment request status to be 'assessed'
        assessment.status = 'assessed'
        comment = request.POST.get('comment', '')
        if len(comment.strip()) > 0:
            assessment.comment = comment

        purpose = request.POST.get('purpose', '')
        if len(purpose.strip()) > 0:
            assessment.purpose = purpose

        assessment.save()

        # set application status process
        application.processing_status = determine_processing_status(application)
        application.save()

        send_assessment_done_email(assessment, request)

        return redirect(self.success_url)
Ejemplo n.º 2
0
    def post(self, request, *args, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])
        assessment = get_object_or_404(Assessment, pk=self.args[1])

        if self._check_read_only(assessment, request):
            return redirect('wl_applications:view_assessment', *args)

        assessment.assessmentcondition_set.all().delete()
        for order, condition_id in enumerate(
                request.POST.getlist('conditionID')):
            AssessmentCondition.objects.create(
                condition=Condition.objects.get(pk=condition_id),
                assessment=assessment,
                order=order)

        # set the assessment request status to be 'assessed' if concluding
        user_action = ApplicationUserAction.ACTION_SAVE_ASSESSMENT_
        if 'conclude' in request.POST:
            assessment.status = 'assessed'
            user_action = ApplicationUserAction.ACTION_CONCLUDE_ASSESSMENT_
        application.log_user_action(
            user_action.format(assessment.assessor_group), request)

        comment = request.POST.get('comment', '')
        if len(comment.strip()) > 0:
            assessment.comment = comment

        purpose = request.POST.get('purpose', '')
        if len(purpose.strip()) > 0:
            assessment.purpose = purpose

        assessment.save()

        # set application status process
        application.processing_status = determine_processing_status(
            application)
        application.save()

        if 'conclude' in request.POST:
            send_assessment_done_email(assessment, request)

            messages.success(
                request,
                'The application assessment has been forwarded back to the Wildlife Licensing '
                'office for review.')

            return redirect(self.success_url)
        else:
            messages.warning(request, 'The application assessment was saved.')

            return render(request, self.template_name, self.get_context_data())
Ejemplo n.º 3
0
    def post(self, request, *args, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])
        assessment = get_object_or_404(Assessment, pk=self.args[1])

        if self._check_read_only(assessment, request):
            return redirect('wl_applications:view_assessment', *args)

        assessment.assessmentcondition_set.all().delete()
        for order, condition_id in enumerate(request.POST.getlist('conditionID')):
            AssessmentCondition.objects.create(condition=Condition.objects.get(pk=condition_id),
                                               assessment=assessment, order=order)

        # set the assessment request status to be 'assessed' if concluding
        user_action = ApplicationUserAction.ACTION_SAVE_ASSESSMENT_
        if 'conclude' in request.POST:
            assessment.status = 'assessed'
            user_action = ApplicationUserAction.ACTION_CONCLUDE_ASSESSMENT_
        application.log_user_action(
            user_action.format(assessment.assessor_group),
            request)

        comment = request.POST.get('comment', '')
        if len(comment.strip()) > 0:
            assessment.comment = comment

        purpose = request.POST.get('purpose', '')
        if len(purpose.strip()) > 0:
            assessment.purpose = purpose

        assessment.save()

        # set application status process
        application.processing_status = determine_processing_status(application)
        application.save()

        if 'conclude' in request.POST:
            send_assessment_done_email(assessment, request)

            messages.success(request, 'The application assessment has been forwarded back to the Wildlife Licensing '
                                      'office for review.')

            return redirect(self.success_url)
        else:
            messages.warning(request, 'The application assessment was saved.')

            return render(request, self.template_name, self.get_context_data())