Ejemplo n.º 1
0
def admin_meta_blueprint():
    if only_admin() != None:
        return only_admin()

    bioform = BioForm(csrf_enabled=False)
    msg = ''

    if bioform.validate_on_submit():
        if get_option('bio') != None:
            get_option('bio').value = bioform.bio.data
        else:
            create_option('bio', bioform.bio.data)

        if get_option('bio_heading') != None:
            get_option('bio_heading').value = bioform.heading.data
        else:
            create_option('bio_heading', bioform.heading.data)

        sess.commit()
    else:
        if get_option('bio_heading') != None:
            bioform.heading.data = get_option('bio_heading').value

        if get_option('bio') != None:
            bioform.bio.data = get_option('bio').value

    return render_template('admin_meta.html', bioform=bioform, msg=msg)
Ejemplo n.º 2
0
def admin_flickr_favourites_blueprint(page=1):
    if only_admin() != None:
        return only_admin()

    flickr = get_flickr()
    
    print(flickr.get_nsid(get_option('flickr_user').value))

    photos = flickr.get_favourites(flickr.get_nsid(get_option('flickr_user').value), page, 128)

    return render_template('admin_flickr_favourites.html',photos=photos, page=page, base_url='/admin/flickr-favourites/')
Ejemplo n.º 3
0
def admin_options_blueprint(page=0):
    if only_admin() != None:
        return only_admin()

    optionsform = OptionsForm(csrf_enabled=False)
    options = get_options(offset=int(page)*10, limit=10)

    delete = request.form.get('delete')

    msg = ''

    if delete != None:
        delete_option(request.form.get('selected_option'))

    if optionsform.validate_on_submit():
        if optionsform.key.data != None and optionsform.value.data != None and delete == None:
            create_option(key=optionsform.key.data, value=optionsform.value.data)
            msg = 'Option was created!'

    return render_template('admin_options.html', options=options, page=page, optionsform=optionsform, msg=msg)
Ejemplo n.º 4
0
def admin_users_blueprint(page=0):
    if only_admin() != None:
        return only_admin()

    users = get_users(offset=int(page)*10, limit=10)

    selected_user = request.form.get('selected_user')
    mk_admin = request.form.get('make_admin')
    rm_admin = request.form.get('remove_admin')
    delete = request.form.get('delete')

    if mk_admin != None:
        make_admin(selected_user)

    if rm_admin != None:
        remove_admin(selected_user)

    if delete != None:
        unregister(selected_user)


    return render_template('admin_users.html', users=users, page=page)
Ejemplo n.º 5
0
def admin_flickr_blueprint():
    if only_admin() != None:
        return only_admin()

    flickrform = FlickrForm(csrf_enabled=False)
    msg = ''

    if flickrform.validate_on_submit():
        get_option('flickr_api_key').value = flickrform.apikey.data
        get_option('flickr_api_secret').value = flickrform.apisecret.data
        get_option('flickr_farm').value = flickrform.farm.data
        get_option('flickr_user').value = flickrform.flickruser.data

        sess.commit()
    else:
        flickrform.apikey.data = get_option('flickr_api_key').value
        flickrform.apisecret.data = get_option('flickr_api_secret').value
        flickrform.farm.data = int(get_option('flickr_farm').value)
        flickrform.flickruser.data = get_option('flickr_user').value


    return render_template('admin_flickr.html', flickrform=flickrform)
Ejemplo n.º 6
0
def admin_blueprint():
    if only_admin() != None:
        return only_admin()
        
    return render_template('admin.html')