本文整理汇总了Python中packages.bin.bin.Page.q方法的典型用法代码示例。如果您正苦于以下问题:Python Page.q方法的具体用法?Python Page.q怎么用?Python Page.q使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类packages.bin.bin.Page
的用法示例。
在下文中一共展示了Page.q方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: statement_log
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import q [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)
)
示例2: credit
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import q [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)
)
示例3: statement
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import q [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:
#.........这里部分代码省略.........
示例4: asset
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import q [as 别名]
def asset(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 Management'
page.icon = 'glyphicons glyphicons-display'
page.form_name = 'practitionerAsset'
template = base_template + second_base + 'snippets/list.html'
page.q = str(qk) + '/'
errors = []
obj_list = Asset.objects.filter(status__exact=1, practitioner__id=qk)
#search logic
q = request.GET.get('q')
if q:
sQuery = get_query(q, ['practitioner__name', 'category', 'type', 'longitude', 'latitude'])
obj_list = obj_list.filter(sQuery)
#build pagination
page, obj = paginate(page, obj_list, request, q)
#form processing
if method is None or method == 'asset':
form = forms.FormAsset()
template = base_template + second_base + 'snippets/list.html'
elif pk is not None:
instance = Asset.objects.get(pk=pk)
prev_instance = Asset.objects.get(pk=pk)
form = forms.FormAsset(instance=instance, data=model_to_dict(instance))
page.form_action = base_url + second_base + 'update/'+str(qk)+'/'+str(pk)+'/'
template = base_template + second_base + 'snippets/manage.html'
else:
instance = Asset()
form = forms.FormAsset(instance=instance)
page.form_action = base_url + second_base + 'new/'+str(qk)+'/'
template = base_template + second_base + 'snippets/manage.html'
obj_settings = [
{'link': base_url + second_base + 'update/'+str(qk)+'/', 'icon': Actions().Icon.edit},
{'link': base_url + 'delete/asset/'+str(qk)+'/', 'icon': Actions().Icon.delete},
]
table = Table()
table.cols = ['Photo', 'Longitude', 'Latitude', 'Category', 'Type', 'Road Clearance', 'Ground Clearance', 'Width', 'Height', 'Sides', 'Commission Date']
table.rows = []
for val in obj:
try:
tmp_image = "<a href='%s'><img src='%s' class='img-responsive' alt='...'></a>" % (get_thumb(val.photo1.url, '512x512'), get_thumb(val.photo1.url, '64x64'))
except (ValueError):
tmp_image = ""
table.rows.append({
'id': val.id,
'fields': [
{'field': tmp_image},
{'field': val.longitude},
{'field': val.latitude},
{'field': val.category},
{'field': val.type},
{'field': val.road_clearance},
{'field': val.ground_clearance},
{'field': val.width},
{'field': val.height},
{'field': val.sides},
{'field': val.commission_date},
]
})
# SCRIPT
page.script = '''
<script>
$('#id_longitude').mask('9.99999');
$('#id_latitude').mask('9.99999');
</script>
'''
# CREATE & UPDATE
if request.method == "POST":
template = base_template + second_base + 'snippets/manage.html'
form = forms.FormAsset(request.POST, request.FILES, 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])
#.........这里部分代码省略.........