本文整理汇总了Python中wildlifelicensing.apps.main.helpers.is_officer函数的典型用法代码示例。如果您正苦于以下问题:Python is_officer函数的具体用法?Python is_officer怎么用?Python is_officer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_officer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: get
def get(self, request, *args, **kwargs):
utils.remove_temp_applications_for_user(request.user)
previous_application = get_object_or_404(Application, licence=args[0])
# check if there is already a renewal, otherwise create one
try:
application = Application.objects.get(previous_application=previous_application)
if application.customer_status == 'under_review':
messages.warning(request, 'A renewal for this licence has already been lodged and is awaiting review.')
return redirect('wl_dashboard:home')
except Application.DoesNotExist:
application = utils.clone_application_with_status_reset(previous_application)
application.application_type = 'renewal'
if is_officer(request.user):
application.proxy_applicant = request.user
application.save()
utils.set_session_application(request.session, application)
return redirect('wl_applications:enter_details')
开发者ID:wilsonc86,项目名称:ledger,代码行数:21,代码来源:entry.py
示例17: 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,
related={
'applicant': {'exclude': ['residential_address','postal_address','billing_address']},
'applicant_profile':{'fields':['email','id','institution','name']},
'previous_application':{'exclude':['applicant','applicant_profile','previous_application','licence']},
'licence':{'related':{
'holder':{'exclude': ['residential_address','postal_address','billing_address']},
'issuer':{'exclude': ['residential_address','postal_address','billing_address']},
'profile':{'related': {'user': {'exclude': ['residential_address','postal_address','billing_address']}},
'exclude': ['postal_address']}
},'exclude':['holder','issuer','profile','licence_ptr']}
})
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))
if application.processing_status == 'declined':
message = "This application has been declined."
details = ApplicationDeclinedDetails.objects.filter(application=application).first()
if details and details.reason:
message += "<br/>Reason:<br/>{}".format(details.reason.replace('\n', '<br/>'))
kwargs['application']['declined_reason'] = details.reason
messages.error(self.request, message)
return super(ViewReadonlyView, self).get_context_data(**kwargs)
开发者ID:wilsonc86,项目名称:ledger,代码行数:40,代码来源:view.py
示例18: get
def get(self, request, *args, **kwargs):
application = get_object_or_404(Application, pk=args[0])
product = get_product(generate_product_title(application))
user = application.applicant.id
error_url = request.build_absolute_uri(reverse('wl_applications:preview'))
success_url = request.build_absolute_uri(reverse('wl_applications:complete'))
basket_params = {
'products': [
{'id': product.id if product is not None else None}
],
'vouchers': [],
'system': PAYMENT_SYSTEM_ID
}
# senior discount
if application.is_senior_offer_applicable:
basket_params['vouchers'].append({'code': SENIOR_VOUCHER_CODE})
basket, basket_hash = create_basket_session(request, basket_params)
checkout_params = {
'system': PAYMENT_SYSTEM_ID,
'basket_owner': user,
'associate_invoice_with_token': True,
'fallback_url': error_url,
'return_url': success_url,
'force_redirect': True,
'template': 'wl/payment_information.html',
'proxy': is_officer(request.user),
}
create_checkout_session(request, checkout_params)
if checkout_params['proxy']:
response = place_order_submission(request)
else:
response = HttpResponseRedirect(reverse('checkout:index'))
return response
开发者ID:wilsonc86,项目名称:ledger,代码行数:37,代码来源:views.py
示例19: get
def get(self, request, *args, **kwargs):
application = get_object_or_404(Application, pk=args[0])
product = get_product(generate_product_code(application))
user = application.applicant.id
error_url = request.build_absolute_uri(reverse('wl_applications:preview'))
success_url = request.build_absolute_uri(reverse('wl_applications:complete'))
parameters = {
'system': PAYMENT_SYSTEM_ID,
'basket_owner': user,
'associateInvoiceWithToken': True,
'checkoutWithToken': True,
'fallback_url': error_url,
'return_url': success_url,
'forceRedirect': True,
'template': 'wl/payment_information.html',
'proxy': is_officer(request.user),
"products": [
{"id": product.id if product is not None else None}
],
"vouchers": []
}
# senior discount
if application.is_senior_offer_applicable:
parameters['vouchers'].append({'code': SENIOR_VOUCHER_CODE})
url = request.build_absolute_uri(
reverse('payments:ledger-initial-checkout')
)
response = requests.post(url, headers=JSON_REQUEST_HEADER_PARAMS, cookies=request.COOKIES,
data=json.dumps(parameters))
return HttpResponse(response.content)
开发者ID:brendanc-dpaw,项目名称:ledger,代码行数:36,代码来源:views.py
示例20: post
def post(self, request, *args, **kwargs):
if len(args) > 1:
application = get_object_or_404(Application, pk=args[1])
else:
application = Application()
if is_officer(request.user):
application.proxy_applicant = request.user
application.data = utils.get_app_session_data(self.request.session, 'data')
application.licence_type = get_object_or_404(WildlifeLicenceType, code_slug=args[0])
application.correctness_disclaimer = request.POST.get('correctnessDisclaimer', '') == 'on'
application.further_information_disclaimer = request.POST.get('furtherInfoDisclaimer', '') == 'on'
application.applicant_profile = get_object_or_404(Profile, pk=utils.get_app_session_data(request.session,
'profile_pk'))
application.lodgement_sequence += 1
application.lodgement_date = datetime.now().date()
if application.customer_status == 'amendment_required':
# this is a 're-lodged' application after some amendment were required.
# from this point we assume that all the amendments have been amended.
AmendmentRequest.objects.filter(application=application).filter(status='requested').update(status='amended')
application.review_status = 'amended'
application.processing_status = 'ready_for_action'
else:
if application.processing_status != 'renewal':
application.processing_status = 'new'
application.customer_status = 'under_review'
# need to save application in order to get its pk
if not application.lodgement_number:
application.save(no_revision=True)
application.lodgement_number = '%s-%s' % (str(application.licence_type.pk).zfill(LICENCE_TYPE_NUM_CHARS),
str(application.pk).zfill(LODGEMENT_NUMBER_NUM_CHARS))
application.documents.clear()
# if attached files were saved temporarily, add each to application as part of a Document
temp_files_dir = utils.get_app_session_data(request.session, 'temp_files_dir')
try:
for filename in utils.get_all_filenames_from_application_data(application.licence_type.application_schema,
utils.get_app_session_data(request.session, 'data')):
document = Document.objects.create(name=filename)
with open(os.path.join(temp_files_dir, filename), 'rb') as doc_file:
document.file.save(filename, File(doc_file), save=True)
application.documents.add(document)
if utils.is_app_session_data_set(request.session, 'application_document'):
filename = utils.get_app_session_data(request.session, 'application_document')
document = Document.objects.create(name=filename)
with open(os.path.join(utils.get_app_session_data(request.session, 'temp_files_dir'), filename), 'rb') as doc_file:
document.file.save(filename, File(doc_file), save=True)
application.hard_copy = document
messages.success(request, 'The application was successfully lodged.')
except Exception as e:
messages.error(request, 'There was a problem creating the application: %s' % e)
application.save(version_user=application.applicant_profile.user, version_comment='Details Modified')
try:
utils.delete_app_session_data(request.session)
except Exception as e:
messages.warning(request, 'There was a problem deleting session data: %s' % e)
return redirect('wl_dashboard:home')
开发者ID:serge-gaia,项目名称:ledger,代码行数:69,代码来源:entry.py
注:本文中的wildlifelicensing.apps.main.helpers.is_officer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论