本文整理汇总了Python中packages.bin.bin.Page.icon方法的典型用法代码示例。如果您正苦于以下问题:Python Page.icon方法的具体用法?Python Page.icon怎么用?Python Page.icon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类packages.bin.bin.Page
的用法示例。
在下文中一共展示了Page.icon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: auth_error
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import icon [as 别名]
def auth_error(request, error=None):
s = Auth().is_auth(request)
if not s:
return Auth.routeLogin
base_template = 'system/'
second_base = 'error/'
page = Page(request)
page.title = _('Page Error')
page.icon = 'glyphicons glyphicons-ban'
page.breadcrumbs = [_('System'), _('Page Error'), _(error)]
page.body_class = 'error-page sb-l-o sb-r-c'
try:
page.route_to = request.session['error-route']
except KeyError:
page.route_to = "/"
return render_to_response(
base_template+second_base+'%s.html' % error,
{'s': s, 'page': page},
context_instance=RequestContext(request)
)
示例2: index
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import icon [as 别名]
def index(request):
page = Page(request)
page.title = _('View Privileges')
page.icon = 'fa fa-key'
page.body_class = 'error-page sb-l-o sb-r-c'
template = "system/privilege/privileges.html"
return render_to_response(
template,
{'data': page},
context_instance=RequestContext(request)
)
示例3: email_view
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import icon [as 别名]
def email_view(request, method=None):
page = Page(request)
page.title = _('Page Email Preview')
page.icon = 'glyphicons glyphicons-ban'
page.body_class = 'error-page sb-l-o sb-r-c'
template = "email/en-gb/%s.html" % method
return render_to_response(
template,
{'data': page},
context_instance=RequestContext(request)
)
示例4: asset
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import icon [as 别名]
def asset(request, pk=None, method=None):
s = Auth().isAuth(request)
if not s:
return Auth.routeLogin
page = Page(request)
page.title = 'Assets'
page.icon = 'glyphicons glyphicons-display'
page.form_name = 'geoIndex'
template = 'asset.html'
page.body = '''
<iframe name='geo-map' src="/geo/" seamless='true' frameborder=0 scrolling='o'
height='100%' style='margin:-20px 0 0 -23px;'>
</iframe>
<script>
$(window).resize(function() {
resizeGeo();
});
function resizeGeo(){
var map = $("[name='geo-map']");
var x = map.offset().left;
var y = map.offset().top;
var windowW = $(window).width();
var windowH = $(window).height();
var newWidth = windowW - x;
var newHeight = windowH - y;
map.width(newWidth);
map.height(newHeight);
}
resizeGeo();
</script>
'''
# render to browser
return render_to_response(template,
{'s': s, 'page': page},
context_instance=RequestContext(request)
)
示例5: system_license
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import icon [as 别名]
def system_license(request, pk=None, method=None):
# check if root login
if request.session['auth_username'] != 'root':
return HttpResponse(response_success(route='#hr/personnel/'))
s = request.session
base_url = '/pp-license/'
second_base = ''
base_template = 'system/'
page = Page(request)
page.title = 'License Management'
page.icon = 'fa fa-unlock-alt'
page.form_name = 'licenseForm'
page.breadcrumbs = ['License Management', 'Manage']
errors = []
page.user = request.session['auth_username']
# query table list
obj_list = License.objects.all()
# search logic
q = request.GET.get('q')
if q:
search_query = get_query(q, ['company__name', 'company_name', 'sys', 'lid'])
obj_list = obj_list.filter(search_query)
# build pagination
page, obj = paginate(page, obj_list, request, q)
# login url processing
if method is None or (method != 'new' and method != 'update'):
instance = License()
form = FormLicense()
template = base_template + 'snippets/list.html'
elif pk is not None:
instance = License.objects.get(pk=pk)
form = FormLicense(instance=instance, data=model_to_dict(instance))
page.form_action = base_url + 'update/'+str(pk)+'/'
template = base_template + 'snippets/manage.html'
else:
instance = License()
form = FormLicense(instance=instance)
page.form_action = base_url + 'new/'
template = base_template + 'snippets/manage.html'
obj_settings = [
{'link': base_url+'update/', 'icon': ActionButton.edit},
{'link': base_url+'delete/', 'icon': ActionButton.delete},
]
table = Table()
table.cols = ['Company', 'Company Secret Key', 'License Number', 'Expiry']
table.rows = []
for val in obj:
try:
expiry = val.license_subscription.filter(status=1)[0]
except IndexError:
expiry = None
expiry = "<a href='#pp-license/subscription/new/{pk}/'>{expiry}</a>".format(expiry=expiry, pk=val.pk)
table.rows.append({
'id': val.id,
'fields': [
{'field': val.company_name},
{'field': val.sys},
{'field': val.lid},
{'field': expiry}
]
})
# maintain autocomplete state
try:
instance_var = instance.modules.all()
except (AttributeError, ValueError):
instance_var = []
# script for autocomplete
page.script = autocomplete_state(
instance_var=instance_var,
queryset=Module.objects.all(),
url='/bin/json/system/modules/',
element='id_modules',
token=20,
)
# CREATE & UPDATE
if request.method == "POST":
form = FormLicense(request.POST, request.FILES, instance=instance)
modules = []
if form.is_valid():
# do method to process
posts = request.POST
#.........这里部分代码省略.........
示例6: uc_user
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import icon [as 别名]
def uc_user(request):
s = Auth().is_auth(request)
if not s:
return Auth.routeLogin
second_base = 'uc_user/'
page = Page(request)
page.title = 'Users\' Class'
page.icon = 'fa fa-list-alt'
page.form_name = 'usersClass'
page.breadcrumbs = ['Privileges', 'Associated User Class']
obj = UserClassTies.pp.filter(status__exact=1)
#url processing
instance = UserClassTies()
form = forms.FormUserClassTies(instance=instance)
page.form_action = base_url + second_base + 'new/'
template = base_template + 'manage.html'
#script for form
page.script = '''
<script>
$(document).ready(function(){
$('#id_user_class').tokenInput('/bin/json/system/privilege/user_class/',
{theme: 'wit', tokenLimit: 100, hintText: 'Start typing name'});
$('#id_user').tokenInput('/bin/json/system/user/',
{theme: 'wit', tokenLimit: 100, hintText: 'Start typing name'});
});
</script>'''
# CREATE & UPDATE
if request.method == "POST":
errors = []
# check for errors
if request.POST['user_class'] == "":
errors.append("Please select at least one user class")
if request.POST['user'] == "":
errors.append("Please select at least one users")
# conclude
if not errors:
# iterate through values and save individually
for x in request.POST['user_class'].split(','):
c_user_class = UserClass.objects.get(pk=x)
for y in request.POST['user'].split(','):
c_user = Users.pp.get(pk=y)
UserClassTies.pp.filter(user=c_user, user_class__module=c_user_class.module).delete()
UserClassTies.pp.create(user_class=c_user_class, user=c_user)
response = 'Saved successfully'
return HttpResponse(response_success(route=base_url + 'user_class/', response=response))
else:
return HttpResponse(response_error(response=[errors]))
#render to browser
return render_to_response(
template,
{'s': s, 'form': form, 'page': page, 'obj': obj},
context_instance=RequestContext(request)
)
示例7: manifest
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import icon [as 别名]
def manifest(request, pk=None, method=None):
s = Auth().is_auth(request)
if not s:
return Auth.routeLogin
second_base = 'manifest/'
page = Page(request)
page.title = 'Privilege Manifest'
page.icon = 'fa fa-list-alt'
page.form_name = 'privilegeManifest'
page.breadcrumbs = ['Privileges', 'Manifest']
errors = []
obj_list = PrivilegeManifest.objects.filter(status__exact=1).order_by('module__name', 'name')
#search logic
q = request.GET.get('q')
if q:
search_query = get_query(q, ['name'])
obj_list = obj_list.filter(search_query)
#build pagination
page, obj = paginate(page, obj_list, request, q)
#login url processing
if method is None or method == 'index':
instance = PrivilegeManifest()
form = forms.FormUserClass()
template = base_template + 'list.html'
elif pk is not None:
instance = PrivilegeManifest.objects.get(pk=pk)
form = forms.FormPrivilegeManifest(instance=instance, data=model_to_dict(instance))
page.form_action = base_url + second_base + 'update/'+str(pk)+'/'
template = base_template + 'manage.html'
else:
instance = PrivilegeManifest()
form = forms.FormPrivilegeManifest(instance=instance)
page.form_action = base_url + second_base + 'new/'
template = base_template + 'manage.html'
obj_settings = [
{'link': base_url+second_base+'update/', 'icon': ActionButton.edit},
{'link': base_url+'manifest-delete/', 'icon': ActionButton.delete},
]
table = Table()
table.cols = ['Module', 'Name', 'Associated User Classes']
table.rows = []
for val in obj:
tmp = val.manifest_privilege.all()
assoc = ""
for x in tmp:
assoc += "%s<br/>" % x.user_class.name
table.rows.append({
'id': val.id,
'fields': [
{'field': val.module.name},
{'field': val.name},
{'field': assoc}
]
})
# CREATE & UPDATE
if request.method == "POST":
form = forms.FormPrivilegeManifest(request.POST, instance=instance)
if form.is_valid():
#do method to process
posts = request.POST
for post in posts:
if hasattr(instance, post):
setattr(instance, post, form.cleaned_data[post])
# non field specific errors
page.non_field_errors = errors
errors += format_form_error(form)
if not errors:
instance.save()
response = 'Saved successfully'
return HttpResponse(response_success(route=base_url + second_base, response=response))
else:
return HttpResponse(response_error(response=[errors]))
#render to browser
return render_to_response(
template,
{'s': s, 'form': form, 'page': page, 'table': table, 'obj': obj, 'settings': obj_settings},
context_instance=RequestContext(request)
)
示例8: user_class
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import icon [as 别名]
def user_class(request, pk=None, method=None):
s = Auth().is_auth(request)
if not s:
return Auth.routeLogin
second_base = 'user_class/'
page = Page(request)
page.title = 'User Class'
page.icon = 'glyphicons glyphicons-parents'
page.form_name = 'applicationUserClass'
page.breadcrumbs = ['Privileges', 'User Class']
errors = []
obj_list = UserClass.objects.filter(status__exact=1)
#search logic
q = request.GET.get('q')
if q:
search_query = get_query(q, ['name'])
obj_list = obj_list.filter(search_query)
#build pagination
page, obj = paginate(page, obj_list, request, q)
#login url processing
if method is None or method == 'index':
instance = UserClass()
form = forms.FormUserClass()
template = base_template + 'list.html'
elif pk is not None:
instance = UserClass.objects.get(pk=pk)
form = forms.FormUserClass(instance=instance, data=model_to_dict(instance))
page.form_action = base_url + second_base + 'update/'+str(pk)+'/'
template = base_template + 'manage.html'
else:
instance = UserClass()
form = forms.FormUserClass(instance=instance)
page.form_action = base_url + second_base + 'new/'
template = base_template + 'manage.html'
obj_settings = [
{'link': base_url+second_base+'update/', 'icon': ActionButton.edit},
{'link': base_url+'user_class-delete/', 'icon': ActionButton.delete},
]
table = Table()
table.cols = ['Module', 'Name', 'Privilege', 'Users']
table.rows = []
for val in obj:
# fetch privileges
tmp = val.user_class_users.filter(sys=request.session['sys'], lid=request.session['lid'])[: 25]
assoc_users = ""
for x in tmp:
assoc_users += "<a href='#"+base_url+"uc_user-delete/%s/' class='text-danger'>%s</a>, " % \
(x.id, "%s [%s %s]" % (x.user.username, x.user.profile.firstname, x.user.profile.lastname))
# fetch associated users
tmp = val.user_class_privilege.all()
assoc = ""
for x in tmp:
assoc += "<a href='#"+base_url+"flush/%s/' class='text-danger'>%s</a><br/>" % (x.id, x.manifest.name)
table.rows.append({
'id': val.id,
'fields': [
{'field': val.module.name},
{'field': val.name},
{'field': assoc},
{'field': assoc_users}
]
})
# CREATE & UPDATE
if request.method == "POST":
form = forms.FormUserClass(request.POST, instance=instance)
if form.is_valid():
#do method to process
posts = request.POST
for post in posts:
if hasattr(instance, post):
setattr(instance, post, form.cleaned_data[post])
# non field specific errors
page.non_field_errors = errors
errors += format_form_error(form)
if not errors:
instance.save()
response = 'Saved successfully'
return HttpResponse(response_success(route=base_url + second_base, response=response))
else:
return HttpResponse(response_error(response=[errors]))
#render to browser
#.........这里部分代码省略.........
示例9: practitioner
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import icon [as 别名]
def practitioner(request, pk=None, method=None, cat=None):
s = Auth().isAuth(request)
if not s:
return Auth.routeLogin
second_base = 'index/'
page = Page(request)
page.title = 'Practitioner Management'
page.icon = 'glyphicons glyphicons-notes'
page.form_name = 'practitionerIndex'
template = base_template + second_base + 'snippets/list.html'
errors = []
if cat is not None:
cat = cat.replace("_", " ")
obj_list = Practitioner.objects.filter(status__exact=1).filter(type=cat)
else:
obj_list = Practitioner.objects.filter(status__exact=1)
#search logic
q = request.GET.get('q')
if q:
sQuery = get_query(q, ['name', 'contact_person', 'email', 'phone', 'website', 'state', 'city', 'country'])
obj_list = obj_list.filter(sQuery)
#build pagination
page, obj = paginate(page, obj_list, request, q)
#form processing
if method is None or method == 'index':
form = forms.FormPractitioner()
template = base_template + second_base + 'snippets/list.html'
elif pk is not None:
print pk
instance = Practitioner.objects.get(pk=pk)
form = forms.FormPractitioner(instance=instance, data=model_to_dict(instance))
page.form_action = base_url + second_base + 'update/'+str(pk)+'/'
template = base_template + second_base + 'snippets/manage.html'
else:
instance = Practitioner()
form = forms.FormPractitioner(instance=instance)
page.form_action = base_url + second_base + 'new/'
template = base_template + second_base + 'snippets/manage.html'
obj_settings = [
{'link': base_url + second_base + 'update/', 'icon': Actions().Icon.edit},
{'link': base_url + 'delete/', 'icon': Actions().Icon.delete},
]
table = Table()
table.cols = ['Name', 'Practitioner Type', 'Phone', 'Email', 'Country']
table.rows = []
for val in obj:
practitioner_link = "<a href='%s' class='text-danger'>%s</a>" % ('/practitioner/asset/%s/'%val.id, val.name)
table.rows.append({
'id': val.id,
'fields': [
{'field': practitioner_link},
{'field': val.type},
{'field': val.mobile1},
{'field': val.email},
{'field': val.country}
]
})
# SCRIPT
page.script = '''
<script>
$('#id_phone').mask('(234)-0-99999999');
$('#id_mobile1').mask('(234) 999-999-9999');
$('#id_mobile2').mask('(234) 999-999-9999');
</script>
'''
# CREATE & UPDATE
if request.method == "POST":
template = base_template + second_base + 'snippets/manage.html'
form = forms.FormPractitioner(request.POST, instance=instance)
if form.is_valid():
#do method to process
posts = request.POST
for post in posts:
if hasattr(instance, post):
setattr(instance, post, form.cleaned_data[post])
# non field specific errors
for f in form.errors:
errors.append(f)
page.non_field_errors = errors
if not errors and not form.errors:
instance.save()
return HttpResponseRedirect(base_url + second_base)
#.........这里部分代码省略.........
示例10: cim
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import icon [as 别名]
def cim(request, pk=None, method=None):
s = Auth().isAuth(request)
if not s:
return Auth.routeLogin
second_base = 'cim/'
page = Page(request)
page.title = 'CRM - Customer Information Management'
page.icon = 'glyphicons glyphicons-notes'
page.form_name = 'crmIndex'
template = base_template + 'snippets/list.html'
errors = []
obj_list = CIM.objects.filter(status__exact=1)
#search logic
q = request.GET.get('q')
if q:
sQuery = get_query(q, ['name', 'contact_person', 'email', 'phone', 'website', 'state', 'city', 'country'])
obj_list = obj_list.filter(sQuery)
#build pagination
page, obj = paginate(page, obj_list, request, q)
#form processing
if method is None or method == 'index':
form = forms.FormCIM()
template = base_template + 'snippets/list.html'
elif pk is not None:
instance = CIM.objects.get(pk=pk)
form = forms.FormCIM(instance=instance, data=model_to_dict(instance))
page.form_action = base_url + second_base + 'update/'+str(pk)+'/'
template = base_template + 'snippets/manage.html'
else:
instance = CIM()
form = forms.FormCIM(instance=instance)
page.form_action = base_url + second_base + 'new/'
template = base_template + 'snippets/manage.html'
obj_settings = [
{'link': base_url + second_base + 'update/', 'icon': Actions().Icon.edit},
{'link': base_url + second_base + 'delete/index/', 'icon': Actions().Icon.delete},
]
table = Table()
table.cols = ['Name', 'Corporate?', 'Phone', 'Email', 'Country']
table.rows = []
for val in obj:
table.rows.append({
'id': val.id,
'fields': [
{'field': val.name},
{'field': val.is_coy},
{'field': val.phone},
{'field': val.email},
{'field': val.country}
]
})
# CREATE & UPDATE
if request.method == "POST":
template = base_template + 'snippets/manage.html'
form = forms.FormCIM(request.POST, instance=instance)
if form.is_valid():
#do method to process
posts = request.POST
for post in posts:
if hasattr(instance, post):
setattr(instance, post, form.cleaned_data[post])
# non field specific errors
for f in form.errors:
errors.append(f)
page.non_field_errors = errors
if not errors and not form.errors:
instance.save()
return HttpResponseRedirect(base_url)
#render to browser
return render_to_response(template,
{'s': s, 'form': form, 'page': page, 'table': table, 'obj': obj, 'settings': obj_settings},
context_instance=RequestContext(request)
)
示例11: index
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import icon [as 别名]
def index(request, pk=None, method=None):
s = Auth().isAuth(request)
if not s:
return Auth.routeLogin
page = Page(request)
page.title = 'Assets'
page.icon = 'glyphicons glyphicons-display'
page.form_name = 'geoIndex'
# GET ASSETS
if pk is None:
obj = Asset.objects.all()
else:
obj = Asset.objects.filter(practitioner__pk=pk)
images = {
1: '/static/img/geo-tags/markers-active.png',
2: '/static/img/geo-tags/markers-amber.png',
3: '/static/img/geo-tags/markers-expired.png',
4: '/static/img/geo-tags/markers-illegal.png',
5: '/static/img/geo-tags/markers-new.png',
}
status_dict = {
1: 'Active',
2: 'Warning',
3: 'Expired',
4: 'Illegal',
5: 'New',
}
# ASSET LOCATIONS
locations = []
marker_images = []
info_window_content = []
for instance in obj:
locations.append(['%s' % instance.line1, float(instance.latitude), float(instance.longitude)])
marker_images.append(['%s' % images[instance.c_status]])
no_asset_image = "/static/img/no-asset-image.jpg"
image_src = ""
try:
image_src = get_thumb(instance.photo1.url, '256x256')
except Exception as e:
image_src = get_thumb(no_asset_image, '256x256')
info = '''
<div class='row' style='overflow-x:hidden;'>
<div class='col-md-12'>
<img src='%s' height='120' />
<p>Verified by: <b>%s</b></p>
</div>
<div class='col-md-12'>
<h3>Practitioner: %s</h3>
<span class='text-primary'>Phone:</span> <span>%s</span><br/>
<span class='text-primary'>Email:</span> <span>%s</span><br/>
<span class='text-primary'>Lng:</span> <b>%s</b><br/>
<span class='text-primary'>Lat:</span> <b>%s</b><br/>
<span class='text-primary'>Category:</span> <span>%s</span><br/>
<span class='text-primary'>Type:</span> <span>%s</span><br/>
<span class='text-primary'>Address:</span> <span>%s</span><br/>
<span class='text-primary'>Expiry:</span> <span>%s</span><br/>
<span class='text-primary'>Status:</span> <b class='text-info'>%s</b>
</div>
</div>
''' % (
image_src,
instance.get_inspector(),
instance.practitioner.name,
"%s, %s" % (instance.practitioner.mobile1, instance.practitioner.mobile2),
instance.practitioner.email,
instance.longitude,
instance.latitude,
"",
"",
"%s, %s" % (instance.line1, instance.line2),
"",
status_dict[instance.c_status]
)
info_window_content.append(['%s' % info])
locations = json.dumps(locations)
marker_images = json.dumps(marker_images)
info_window_content = json.dumps(info_window_content)
# BUILD MAP
page.script_head = '''
<style type="text/css">
#map-canvas { height: 100%; width:100%; margin: 0; padding: 0;}
</style>
<script type="text/javascript">
// map marker content
var info_window_content = '''+info_window_content+''';
#.........这里部分代码省略.........
示例12: statement_log
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import icon [as 别名]
def statement_log(request, qk=None, pk=None, method=None):
if qk is None:
HttpResponseRedirect('/404/hack/')
s = Auth().isAuth(request)
if not s:
return Auth.routeLogin
second_base = 'asset/'
#practitioner factory
obj_practitioner = Practitioner.objects.get(pk=qk)
# asset factory
page = Page(request)
page.title = 'Practitioner\'s Asset Financial Record - Log'
page.icon = 'glyphicons glyphicons-credit_card'
page.form_name = 'practitionerFR'
template = base_template + second_base + 'snippets/list-financial.html'
page.q = str(qk) + '/'
errors = []
obj = Asset.objects.filter(status__exact=1, practitioner__id=qk)
# display financial log
table = Table()
table.cols = ['Photo', 'Asset Detail', 'Billing Start', 'Billing End', 'Amount', 'Running Balance']
table.rows = []
running_balance = 0
for val in AssetFR.objects.filter(txn_date=pk):
running_balance += val.amount
asset_name = "<b>[%s - %s]</b><br/>%s,<br/>%s" % (val.asset.longitude, val.asset.latitude, val.asset.line1,
val.asset.line2)
try:
tmp_image = "<a href='%s'><img src='%s' class='img-responsive' alt='...'></a>" % \
(get_thumb(val.asset.photo1.url, '512x512'), get_thumb(val.asset.photo1.url, '64x64'))
except (ValueError):
tmp_image = ""
table.rows.append({
'id': val.id,
'fields': [
{'field': tmp_image},
{'field': asset_name},
{'field': val.billing_start},
{'field': val.billing_end},
{'field': format(val.amount, ',.2f')},
{'field': format(running_balance, ',.2f')}
]
})
# SCRIPT
page.script = '''
<script>
</script>
'''
#render to browser
return render_to_response(template,
{'s': s, 'page': page, 'table': table, 'obj': obj,
'practitioner': obj_practitioner},
context_instance=RequestContext(request)
)
示例13: statement
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import icon [as 别名]
def statement(request, qk=None, pk=None, method=None):
if qk is None:
HttpResponseRedirect('/404/hack/')
s = Auth().isAuth(request)
if not s:
return Auth.routeLogin
second_base = 'asset/'
#practitioner factory
obj_practitioner = Practitioner.objects.get(pk=qk)
# asset factory
page = Page(request)
page.title = 'Practitioner\'s Asset Financial Record'
page.icon = 'glyphicons glyphicons-credit_card'
page.form_name = 'practitionerFR'
template = base_template + second_base + 'snippets/list-financial.html'
page.q = str(qk) + '/'
errors = []
obj = Asset.objects.filter(status__exact=1, practitioner__id=qk)
# reproduce practitioners billing by checking individual board and adding up its financials to the account statement
# this is entirely based on the billing period on the asset table. Skip suspended boards
# billing date is 26th of every month and first month is pro-rated
today = datetime.date.today()
year = today.year
month = today.month
day = today.day
# lets retrieve the date object for 60 days ahead of now
today + timedelta(60)
if today.day >= 26:
# place billing period as 26th of current month
billing_date = datetime.date(year, month, 26)
else:
# place billing period as 26th of the previous month except if month is january
if month == 1:
billing_date = datetime.date(year-1, 12, 26)
else:
billing_date = datetime.date(year, month-1, 26)
boards = Asset.objects.filter(status__exact=1, practitioner__id=qk)
aggregate = 0
for board in boards:
billing_start = board.billing_date
if billing_start is not None and billing_start != "" and billing_start < billing_date:
# check the days between today and the last billing date and do the deductions
fee_days = board.fee/365
billing_period = billing_date - billing_start
amount = billing_period.days * fee_days
aggregate += amount
# process data and save to database
# AssetFR
asset_fr = AssetFR(asset=board, practitioner=obj_practitioner, amount=amount, billing_start=billing_start,
billing_end=billing_date, txn_date=today)
asset_fr.save()
# change the billing date to current billing date
board.billing_date = billing_date
board.save()
#record summarized data to customer billing page
if(aggregate != 0):
comment = 'Debit on assets; Billing as at %s' % str(billing_date)
fr_summary = FRSummary(practitioner=obj_practitioner, debit=aggregate, balance=(-1 * aggregate),
txn_date=today, comment=comment)
fr_summary.save()
# process expiry status (if total credit/total debits is less than 0.6)
from django.db.models import Sum
fr_credit = FRSummary.objects.filter(practitioner=obj_practitioner).aggregate(Sum('credit'))
fr_debit = FRSummary.objects.filter(practitioner=obj_practitioner).aggregate(Sum('debit'))
fr_fraction = fr_credit['credit__sum']/fr_debit['debit__sum']
# give allowance for 3rd party practitioners
if obj_practitioner.type == '3rd Party':
if fr_fraction < 0.6:
boards.update(c_status=3)
elif fr_fraction < 0.8 and fr_fraction >= 0.6:
boards.update(c_status=2)
else:
boards.update(c_status=1)
# no allowance for other practitioners
else:
if fr_fraction < 1:
boards.update(c_status=3)
elif fr_fraction < 1.2 and fr_fraction >= 1:
boards.update(c_status=2)
else:
#.........这里部分代码省略.........
示例14: credit
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import icon [as 别名]
def credit(request, qk=None, pk=None, method=None):
if qk is None:
HttpResponseRedirect('/404/hack/')
s = Auth().isAuth(request)
if not s:
return Auth.routeLogin
second_base = 'asset/'
#practitioner factory
obj_practitioner = Practitioner.objects.get(pk=qk)
# asset factory
page = Page(request)
page.title = 'Practitioner\'s Deposit Form'
page.icon = 'glyphicons glyphicons-display'
page.form_name = 'practitionerFR'
template = base_template + second_base + 'snippets/manage-financial.html'
page.q = str(qk) + '/'
errors = []
#form processing
if pk is not None:
instance = FRSummary.objects.get(pk=pk)
form = forms.FormPractitionerFR(instance=instance, data=model_to_dict(instance))
page.form_action = base_url + 'credit/' + str(qk)+'/'+str(pk)+'/'
template = base_template + second_base + 'snippets/manage-financial.html'
else:
instance = FRSummary()
form = forms.FormPractitionerFR(instance=instance)
page.form_action = base_url + 'credit/' + str(qk)+'/'
template = base_template + second_base + 'snippets/manage-financial.html'
# SCRIPT
page.script = '''
<script>
</script>
'''
# CREATE & UPDATE
if request.method == "POST":
template = base_template + second_base + 'snippets/manage-financial.html'
form = forms.FormPractitionerFR(request.POST, instance=instance)
if form.is_valid():
#do method to process
posts = request.POST
for post in posts:
if hasattr(instance, post):
setattr(instance, post, form.cleaned_data[post])
# non field specific errors
if instance.credit < 100:
errors.append('Amount entered is too low')
page.non_field_errors = errors
if not errors and not form.errors:
instance.balance = instance.credit
instance.practitioner = obj_practitioner
instance.save()
return HttpResponseRedirect(base_url + 'statement/' + '%s/' % qk)
#render to browser
return render_to_response(template,
{'s': s, 'form': form, 'page': page, 'obj': instance,
'practitioner': obj_practitioner},
context_instance=RequestContext(request)
)
示例15: subscription
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import icon [as 别名]
def subscription(request, pk=None, method=None):
# check if root login
if request.session['auth_username'] != 'root':
return HttpResponse(response_success(route='#hr/personnel/'))
s = request.session
base_url = '/pp-license/'
second_base = 'subscription/'
base_template = 'system/'
page = Page(request)
page.title = 'License Management'
page.icon = 'fa fa-unlock-alt'
page.form_name = 'subscriptionForm'
page.breadcrumbs = ['License Management', 'Subscription']
errors = []
page.user = request.session['auth_username']
# query table list
obj = Subscription.objects.filter(license__id=pk)
# login url processing
if method is None or (method != 'new' and method != 'update'):
instance = Subscription()
form = FormSubscription()
template = base_template + 'snippets/list.html'
else:
instance = Subscription()
instance.license = License.objects.get(pk=pk)
form = FormSubscription(instance=instance)
page.form_action = base_url + second_base + 'new/' + str(pk) + '/'
template = base_template + 'snippets/manage.html'
obj_settings = [
{'link': base_url+'update/', 'icon': ActionButton.edit},
{'link': base_url+'delete/', 'icon': ActionButton.delete},
]
table = Table()
table.cols = ['License', 'Expiry']
table.rows = []
for val in obj:
table.rows.append({
'id': val.id,
'fields': [
{'field': val.license},
{'field': val.expiry}
]
})
# CREATE & UPDATE
if request.method == "POST":
form = FormSubscription(request.POST, instance=instance)
if form.is_valid():
# do method to process
posts = request.POST
for post in posts:
# skip the many to many fields
if hasattr(instance, post):
setattr(instance, post, form.cleaned_data[post])
# non field specific errors
page.non_field_errors = errors
errors += format_form_error(form)
# if not errors and not form.errors:
if not errors:
Subscription.objects.filter(license__id=pk).update(status=0)
instance.save()
return HttpResponse(response_success(route=base_url+second_base))
else:
return HttpResponse(response_error(response=[errors]))
# render to browser
return render_to_response(
template,
{'s': s, 'form': form, 'page': page, 'table': table, 'obj': obj, 'settings': obj_settings},
context_instance=RequestContext(request)
)