예제 #1
0
def remove_temp_applications_for_user(user):
    if is_customer(user):
        Application.objects.filter(applicant=user,
                                   customer_status='temp').delete()
    elif is_officer(user):
        Application.objects.filter(proxy_applicant=user,
                                   customer_status='temp').delete()
예제 #2
0
    def get_context_data(self, **kwargs):
        try:
            application = utils.get_session_application(self.request.session)
        except Exception as e:
            messages.error(self.request, e.message)
            return redirect("wl_applications:new_application")

        kwargs["is_payment_required"] = (
            not is_licence_free(generate_product_code(application))
            and not application.invoice_reference
            and is_customer(self.request.user)
        )

        if application.data:
            utils.convert_documents_to_url(application.data, application.documents.all(), "")

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = utils.append_app_document_to_schema_data(
                application.licence_type.application_schema, application.data, application.hard_copy.file.url
            )
        else:
            kwargs["data"] = application.data

        kwargs["application"] = application

        return super(PreviewView, self).get_context_data(**kwargs)
예제 #3
0
파일: tests.py 프로젝트: tawazz/ledger
 def setUp(self):
     self.customer = helpers.get_or_create_default_customer()
     self.assertTrue(is_customer(self.customer))
     self.officer = helpers.get_or_create_default_officer()
     self.assertTrue(is_officer(self.officer))
     self.assessor = helpers.get_or_create_default_assessor()
     self.assertTrue(is_assessor(self.assessor))
     self.client = helpers.SocialClient()
예제 #4
0
 def create_random_customer(self):
     user = create_random_customer()
     self.assertIsNotNone(user)
     self.assertTrue(isinstance(user, EmailUser))
     self.assertEqual(TestData.DEFAULT_CUSTOMER['email'], user.email)
     self.assertTrue(accounts_helpers.is_customer(user))
     # test that we can login
     self.client.login(user.email)
     is_client_authenticated(self.client)
예제 #5
0
 def create_random_customer(self):
     user = create_random_customer()
     self.assertIsNotNone(user)
     self.assertTrue(isinstance(user, EmailUser))
     self.assertEqual(TestData.DEFAULT_CUSTOMER['email'], user.email)
     self.assertTrue(accounts_helpers.is_customer(user))
     # test that we can login
     self.client.login(user.email)
     is_client_authenticated(self.client)
예제 #6
0
    def get(self, request, *args, **kwargs):
        delete_app_session_data(request.session)

        set_app_session_data(request.session, 'temp_files_dir', tempfile.mkdtemp(dir=settings.MEDIA_ROOT))

        if is_customer(request.user):
            set_app_session_data(request.session, 'customer_pk', request.user.pk)

            return redirect('applications:select_licence_type', *args, **kwargs)
        else:
            return redirect('applications:create_select_customer')
예제 #7
0
 def test_func(self):
     """
     implementation of the UserPassesTestMixin test_func
     """
     user = self.request.user
     if not user.is_authenticated():
         self.raise_exception = False
         return False
     self.raise_exception = True
     if is_customer(user) or is_officer(user):
         return False
     assessment = self.get_assessment()
     return assessment is not None and assessment.assessor_group in get_user_assessor_groups(user)
예제 #8
0
 def test_func(self):
     """
     implementation of the UserPassesTestMixin test_func
     """
     user = self.request.user
     if not user.is_authenticated():
         self.raise_exception = False
         return False
     self.raise_exception = True
     if is_customer(user) or is_officer(user):
         return False
     assessment = self.get_assessment()
     return assessment is not None and assessment.assessor_group in get_user_assessor_groups(
         user)
예제 #9
0
파일: entry.py 프로젝트: serge-gaia/ledger
    def get(self, request, *args, **kwargs):
        try:
            utils.delete_app_session_data(request.session)
        except Exception as e:
            messages.warning(request, 'There was a problem deleting session data: %s' % e)

        utils.set_app_session_data(request.session, 'temp_files_dir', tempfile.mkdtemp(dir=settings.MEDIA_ROOT))

        if is_customer(request.user):
            utils.set_app_session_data(request.session, 'customer_pk', request.user.pk)

            return redirect('wl_applications:select_licence_type', *args, **kwargs)
        else:
            return redirect('wl_applications:create_select_customer')
예제 #10
0
    def get(self, request, *args, **kwargs):
        utils.remove_temp_applications_for_user(request.user)

        application = Application.objects.create()

        utils.set_session_application(request.session, application)

        if is_customer(request.user):
            application.applicant = request.user
            application.save()

            return redirect('wl_applications:select_licence_type', *args, **kwargs)
        else:
            application.proxy_applicant = request.user
            application.save()
            return redirect('wl_applications:create_select_customer')
예제 #11
0
    def get(self, request, *args, **kwargs):
        utils.remove_temp_applications_for_user(request.user)

        application = Application.objects.create()

        utils.set_session_application(request.session, application)

        if is_customer(request.user):
            application.applicant = request.user
            application.save()

            return redirect('wl_applications:select_licence_type', *args,
                            **kwargs)
        else:
            application.proxy_applicant = request.user
            application.save()
            return redirect('wl_applications:create_select_customer')
예제 #12
0
파일: entry.py 프로젝트: wilsonc86/ledger
    def get_context_data(self, **kwargs):
        application = utils.get_session_application(self.request.session)

        kwargs['is_payment_required'] = not is_licence_free(generate_product_title(application)) and \
            not application.invoice_reference and is_customer(self.request.user)

        if application.data:
            utils.convert_documents_to_url(application.data, application.documents.all(), '')

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = utils.\
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)
        else:
            kwargs['data'] = application.data

        kwargs['application'] = application

        return super(PreviewView, self).get_context_data(**kwargs)
예제 #13
0
    def get_context_data(self, **kwargs):
        application = utils.get_session_application(self.request.session)

        kwargs['is_payment_required'] = not is_licence_free(generate_product_title(application)) and \
            not application.invoice_reference and is_customer(self.request.user)

        if application.data:
            utils.convert_documents_to_url(application.data,
                                           application.documents.all(), '')

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = utils.\
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)
        else:
            kwargs['data'] = application.data

        kwargs['application'] = application

        return super(PreviewView, self).get_context_data(**kwargs)
예제 #14
0
 def test_func(self):
     return is_customer(self.request.user)
예제 #15
0
def is_customer(user):
    return helpers.is_customer(user)
예제 #16
0
 def test_func(self):
     return is_customer(self.request.user)
예제 #17
0
 def test_func(self):
     user = self.request.user
     return is_officer(user) or is_customer(user)
예제 #18
0
 def test_func(self):
     user = self.request.user
     return is_officer(user) or is_customer(user)
예제 #19
0
def remove_temp_applications_for_user(user):
    if is_customer(user):
        Application.objects.filter(applicant=user, customer_status="temp").delete()
    elif is_officer(user):
        Application.objects.filter(proxy_applicant=user, customer_status="temp").delete()