当前位置: 首页>>代码示例>>Python>>正文


Python Page.script_head方法代码示例

本文整理汇总了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+''';
#.........这里部分代码省略.........
开发者ID:pukonu,项目名称:doas,代码行数:103,代码来源:views.py


注:本文中的packages.bin.bin.Page.script_head方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。