当前位置: 首页>>代码示例>>Python>>正文


Python helpers.is_officer函数代码示例

本文整理汇总了Python中wildlifelicensing.apps.main.helpers.is_officer函数的典型用法代码示例。如果您正苦于以下问题:Python is_officer函数的具体用法?Python is_officer怎么用?Python is_officer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了is_officer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _set_submitted

    def _set_submitted(self, ret):
        ret.lodgement_number = '%s-%s' % (str(ret.licence.licence_type.pk).zfill(LICENCE_TYPE_NUM_CHARS),
                                          str(ret.pk).zfill(LODGEMENT_NUMBER_NUM_CHARS))

        ret.lodgement_date = datetime.date.today()

        if is_officer(self.request.user):
            ret.proxy_customer = self.request.user

        # assume that all the amendment requests has been solved.
        pending_amendments = ret.pending_amendments_qs
        if pending_amendments:
            pending_amendments.update(status='amended')
            ret.status = 'amended'
        else:
            ret.status = 'submitted'
        ret.save()

        message = 'Return successfully submitted.'

        # update next return in line's status to become the new current return
        next_ret = Return.objects.filter(licence=ret.licence, status='future').order_by('due_date').first()

        if next_ret is not None:
            next_ret.status = 'current'
            next_ret.save()

            message += ' The next return for this licence can now be entered and is due on {}.'. \
                format(next_ret.due_date.strftime(DATE_FORMAT))

        return_submitted.send(sender=self.__class__, ret=ret)

        messages.success(self.request, message)
开发者ID:wilsonc86,项目名称:ledger,代码行数:33,代码来源:views.py

示例2: get_context_data

    def get_context_data(self, **kwargs):
        with open('%s/json/%s.json' % (APPLICATION_SCHEMA_PATH, self.args[0])) as data_file:
            form_structure = json.load(data_file)

        licence_type = WildlifeLicenceType.objects.get(code=self.args[0])

        application = get_object_or_404(Application, pk=self.args[1]) if len(self.args) > 1 else None

        if is_app_session_data_set(self.request.session, 'profile_pk'):
            profile = get_object_or_404(Profile, pk=get_app_session_data(self.request.session, 'profile_pk'))
        else:
            profile = application.applicant_profile

        kwargs['licence_type'] = licence_type
        kwargs['profile'] = profile
        kwargs['structure'] = form_structure

        kwargs['is_proxy_applicant'] = is_officer(self.request.user)

        if len(self.args) > 1:
            kwargs['application_pk'] = self.args[1]

        if is_app_session_data_set(self.request.session, 'data'):
            data = get_app_session_data(self.request.session, 'data')

            temp_files_url = settings.MEDIA_URL + \
                os.path.basename(os.path.normpath(get_app_session_data(self.request.session, 'temp_files_dir')))

            prepend_url_to_application_data_files(form_structure, data, temp_files_url)

            kwargs['data'] = data

        return super(PreviewView, self).get_context_data(**kwargs)
开发者ID:rockychen-dpaw,项目名称:ledger,代码行数:33,代码来源:entry.py

示例3: get_context_data

    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = append_app_document_to_schema_data(
                application.licence_type.application_schema, application.data, application.hard_copy.file.url
            )

        convert_documents_to_url(
            application.licence_type.application_schema, application.data, application.documents.all()
        )

        kwargs["application"] = application

        if is_officer(self.request.user):
            kwargs["customer"] = application.applicant_profile.user

            if application.proxy_applicant is None:
                to = application.applicant_profile.user.email
            else:
                to = application.proxy_applicant.email

            kwargs["log_entry_form"] = CommunicationsLogEntryForm(to=to, fromm=self.request.user.email)

        return super(ViewReadonlyView, self).get_context_data(**kwargs)
开发者ID:serge-gaia,项目名称:ledger,代码行数:25,代码来源:view.py

示例4: get_user_home_url

def get_user_home_url(user):
    if accounts_helpers.is_officer(user):
        return '/dashboard/officer'
    elif accounts_helpers.is_assessor(user):
        return '/dashboard/tables/assessor'

    return '/dashboard/tables/customer'
开发者ID:gaiaresources,项目名称:ledger,代码行数:7,代码来源:helpers.py

示例5: _set_submitted

    def _set_submitted(self, ret):
        ret.lodgement_number = "%s-%s" % (
            str(ret.licence.licence_type.pk).zfill(LICENCE_TYPE_NUM_CHARS),
            str(ret.pk).zfill(LODGEMENT_NUMBER_NUM_CHARS),
        )

        ret.lodgement_date = datetime.date.today()

        if is_officer(self.request.user):
            ret.proxy_customer = self.request.user

        ret.status = "submitted"
        ret.save()

        message = "Return successfully submitted."

        # update next return in line's status to become the new current return
        next_ret = Return.objects.filter(licence=ret.licence, status="future").order_by("due_date").first()

        if next_ret is not None:
            next_ret.status = "current"
            next_ret.save()

            message += " The next return for this licence can now be entered and is due on {}.".format(
                next_ret.due_date.strftime(DATE_FORMAT)
            )

        return_submitted.send(sender=self.__class__, ret=ret)

        messages.success(self.request, message)
开发者ID:parksandwildlife,项目名称:ledger,代码行数:30,代码来源:views.py

示例6: setUp

 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()
开发者ID:parksandwildlife,项目名称:ledger,代码行数:8,代码来源:tests.py

示例7: test_create_default_officer

 def test_create_default_officer(self):
     user = get_or_create_default_officer()
     self.assertIsNotNone(user)
     self.assertTrue(isinstance(user, EmailUser))
     self.assertEqual(TestData.DEFAULT_OFFICER['email'], user.email)
     self.assertTrue(accounts_helpers.is_officer(user))
     # test that we can login
     self.client.login(user.email)
     is_client_authenticated(self.client)
开发者ID:gaiaresources,项目名称:ledger,代码行数:9,代码来源:helpers.py

示例8: get

    def get(self, *args, **kwargs):
        if self.request.user.is_authenticated():
            if is_officer(self.request.user):
                return redirect('wl_dashboard:tree_officer')
            elif is_assessor(self.request.user):
                return redirect('wl_dashboard:tables_assessor')

            return redirect('wl_dashboard:tables_customer')
        else:
            kwargs['form'] = LoginForm
            return super(DashBoardRoutingView, self).get(*args, **kwargs)
开发者ID:brendanc-dpaw,项目名称:ledger,代码行数:11,代码来源:base.py

示例9: test_func

 def test_func(self):
     """
     implementation of the UserPassesTestMixin test_func
     """
     user = self.request.user
     if is_officer(user):
         return True
     ret = self.get_return()
     if ret is not None:
         return ret.licence.holder == user
     else:
         return True
开发者ID:wilsonc86,项目名称:ledger,代码行数:12,代码来源:mixins.py

示例10: test_func

 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)
开发者ID:brendanc-dpaw,项目名称:ledger,代码行数:13,代码来源:mixins.py

示例11: get_context_data

    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        with open('%s/json/%s.json' % (APPLICATION_SCHEMA_PATH, application.licence_type.code)) as data_file:
            form_structure = json.load(data_file)

        kwargs['licence_type'] = application.licence_type
        kwargs['structure'] = form_structure
        kwargs['data'] = application.data

        if is_officer(self.request.user):
            kwargs['customer'] = application.applicant_profile.user

        return super(ViewReadonlyView, self).get_context_data(**kwargs)
开发者ID:rockychen-dpaw,项目名称:ledger,代码行数:14,代码来源:view.py

示例12: get

    def get(self, *args, **kwargs):
        if self.request.user.is_authenticated():
            if (not self.request.user.first_name) or (not self.request.user.last_name) or (not self.request.user.dob):
                messages.info(self.request, 'Welcome! As this is your first time using the website, please enter your full name and date of birth.')
                return redirect('wl_main:edit_account')

            if is_officer(self.request.user):
                return redirect('wl_dashboard:tree_officer')
            elif is_assessor(self.request.user):
                return redirect('wl_dashboard:tables_assessor')

            return redirect('wl_dashboard:tables_customer')
        else:
            kwargs['form'] = LoginForm
            return super(DashBoardRoutingView, self).get(*args, **kwargs)
开发者ID:wilsonc86,项目名称:ledger,代码行数:15,代码来源:base.py

示例13: get_context_data

    def get_context_data(self, **kwargs):
        kwargs['licence_type'] = get_object_or_404(WildlifeLicenceType, code_slug=self.args[0])

        if is_officer(self.request.user) and utils.is_app_session_data_set(self.request.session, 'customer_pk'):
            kwargs['customer'] = EmailUser.objects.get(pk=utils.get_app_session_data(self.request.session, 'customer_pk'))

        kwargs['is_renewal'] = False
        if len(self.args) > 1:
            try:
                application = Application.objects.get(pk=self.args[1])
                if application.processing_status == 'renewal':
                    kwargs['is_renewal'] = True
            except Exception:
                pass

        return super(ApplicationEntryBaseView, self).get_context_data(**kwargs)
开发者ID:serge-gaia,项目名称:ledger,代码行数:16,代码来源:entry.py

示例14: test_func

 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
     if is_officer(user):
         return True
     self.raise_exception = True
     application = self.get_application()
     if application is not None:
         return application.applicant_profile.user == user and application.can_user_view
     else:
         return True
开发者ID:rockychen-dpaw,项目名称:ledger,代码行数:16,代码来源:mixins.py

示例15: get_context_data

    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(), '')

        kwargs['application'] = serialize(application, posthook=format_application)

        if is_officer(self.request.user):
            kwargs['customer'] = application.applicant

            kwargs['log_entry_form'] = ApplicationLogEntryForm(to=get_log_entry_to(application), fromm=self.request.user.get_full_name())
        else:
            kwargs['payment_status'] = payment_utils.PAYMENT_STATUSES.get(payment_utils.
                                                                          get_application_payment_status(application))

        return super(ViewReadonlyView, self).get_context_data(**kwargs)
开发者ID:brendanc-dpaw,项目名称:ledger,代码行数:21,代码来源:view.py


注:本文中的wildlifelicensing.apps.main.helpers.is_officer函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。