當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。