本文整理汇总了Python中packages.bin.bin.Page.script_head方法的典型用法代码示例。如果您正苦于以下问题:Python Page.script_head方法的具体用法?Python Page.script_head怎么用?Python Page.script_head使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类packages.bin.bin.Page
的用法示例。
在下文中一共展示了Page.script_head方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import script_head [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+''';
#.........这里部分代码省略.........