예제 #1
0
def screendisplay(template, screenname):
    '''
        The actual output screen view.
    '''
    try:
        screen = Screen.get(urlname=screenname)
    except Screen.DoesNotExist:
        # return first screen, if you can't find the one we really want.
        # this stops us from ending up with screens which 'die' due to misnaming.
        # They may show the wrong screen - but it's better than not showing
        # a screen at all.
        # TODO: add an config_var to decide what to do in this circumstance.
        screen = Screen.get()

    return render_template('screens/' + template + '.html',
                           screen=screen)
예제 #2
0
def screendisplay(template, screenname):
    '''
        The actual output screen view.
    '''
    try:
        screen = Screen.get(urlname=screenname)
    except Screen.DoesNotExist:
        # return first screen, if you can't find the one we really want.
        # this stops us from ending up with screens which 'die' due to misnaming.
        # They may show the wrong screen - but it's better than not showing
        # a screen at all.
        # TODO: add an config_var to decide what to do in this circumstance.
        screen = Screen.get()

    return render_template('screens/' + template + '.html',
                           screen=screen,
                           site_mode=app.config['MODE'])
예제 #3
0
def screen_json(screenid, old_md5):
    '''
        When you edit a screen, it saves most of the data as JSON.  This
        requests the MD5sum of that data, (and that data).  You can then
        compare against what you're already displaying, and only update
        if it's changed.
    '''

    try:
        screen = Screen.get(id=int(screenid))
    except:
        screen = Screen()  # pylint: disable=no-value-for-parameter

    screen_md5 = screen.md5()

    if screen_md5 == old_md5:
        return jsonify(screenid=screenid, md5=screen_md5)
    else:
        return jsonify(screenid=screenid,
                       md5=screen_md5,
                       screen=screen.to_dict())
예제 #4
0
def screen_json(screenid, old_md5):
    '''
        When you edit a screen, it saves most of the data as JSON.  This
        requests the MD5sum of that data, (and that data).  You can then
        compare against what you're already displaying, and only update
        if it's changed.
    '''

    try:
        screen = Screen.get(id=int(screenid))
    except:
        screen = Screen() # pylint: disable=no-value-for-parameter

    screen_md5 = screen.md5()

    if screen_md5 == old_md5:
        return jsonify(screenid=screenid, md5=screen_md5)
    else:
        return jsonify(screenid=screenid,
                       md5=screen_md5,
                       screen=screen.to_dict())