本文整理汇总了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)
示例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)
示例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)
示例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'
示例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)
示例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()
示例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)
示例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)
示例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
示例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)
示例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)
示例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)
示例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)
示例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
示例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)