Exemplo n.º 1
0
def register():
    access_token = request.values.get("access_token", None)
    if not access_token or access_token == "None":
        return render_template("facebook_app/register.html")
    try:
        graph = facebook.GraphAPI(access_token)
        profile = graph.get_object('me')
        settings = {
                'events': True,
                'friends': True,
                'notes': True,
                'albums': True,
                'links': True,
                'statuses': True,
                'photos': True}

        schedule = {
                'interval': 'daily',
                'timeofday': '0700'}
        schedule.update(schedule_to_form_time('0700'))

        save_settings("facebook_app",
                {'settings': settings,
                    'schedule': schedule,
                    'tokens': access_token,
                    'profile': profile})

        reload_schedules()

        return render_template("facebook_app/register.html")
    except Exception, e:
        logger.debug("%r", e)
Exemplo n.º 2
0
def do_preferences():
    preference = get_settings("facebook_app")

    if not preference:
        logger.debug('no preference found. redirecting to setup')
        return redirect(url_for('setup'))

    schedule_form = ScheduleForm(request.form, prefix='schedule')
    settings_form = SettingsForm(request.form, prefix='settings')

    preference['settings'] = {
        'statuses': settings_form.statuses.data,
        'events': settings_form.events.data,
        'albums': settings_form.albums.data,
        'notes': settings_form.notes.data,
        'links': settings_form.links.data,
        'friends': settings_form.friends.data,
        'photos': settings_form.photos.data}

    preference['schedule'] = {
        'interval': schedule_form.interval.data,
        'dayofmonth': schedule_form.dayofmonth.data,
        'dayofweek': schedule_form.dayofweek.data,
        'timeofday': schedule_form.timeofday.data,
        'hourofday': schedule_form.hourofday.data,
        'minuteofhour': schedule_form.minuteofhour.data,
        'ampm': schedule_form.ampm.data}

    save_settings("facebook_app", preference)
    reload_schedules() 
    flash("Facebook settings updated.")
    return redirect(url_for("preferences"))
Exemplo n.º 3
0
    def do_app_settings():
        """
        Update application settings
        """
        from flask import request, flash, redirect

        preference = get_settings("global")
        new_preference = AppSettingsForm(request.form)
        preference["run_at_startup"] = new_preference.run_at_startup.data

        backup_dir = new_preference.backup_dir.data

        home_dir = get_home_dir()
        logger.debug("home dir is: %r", home_dir)
        logger.debug("backup dir is: %r", backup_dir)
        if not backup_dir.startswith(home_dir):
            flash("Invalid Backup Directory path", "error")
            return redirect(url_for(".app_settings"))

        preference["backup_dir"] = backup_dir

        need_restart = False
        if not is_same_path(BACKUP_DIR, backup_dir):
            move_backup_dir(backup_dir)
            need_restart = True

        save_settings("global", preference)
        run_at_startup(preference["run_at_startup"])
        save_config("backup_dir", backup_dir)
        flash("Application settings updated!")
        if need_restart:
            return redirect(url_for(".restarting"))
        return redirect(url_for(".app_settings"))
Exemplo n.º 4
0
def do_preferences():
    preference = get_settings('google_contacts_app')

    if not preference:
        logger.debug('no preference found. redirecting to setup')
        return redirect(url_for('setup'))

    schedule_form = ScheduleForm(request.form, prefix='schedule')
    
    preference['schedule'] = {
        'interval': schedule_form.interval.data,
        'dayofmonth': schedule_form.dayofmonth.data,
        'dayofweek': schedule_form.dayofweek.data,
        'timeofday': schedule_form.timeofday.data,
        'hourofday': schedule_form.hourofday.data,
        'minuteofhour': schedule_form.minuteofhour.data,
        'ampm': schedule_form.ampm.data}
    save_settings('google_contacts_app', preference)

    reload_schedules()
    flash("Google Contacts settings updated.")
    return redirect(url_for("preferences"))
Exemplo n.º 5
0
    except Exception, e:
        logger.debug("authentication error: %r", e)
        flash("There was a problem authenticating you with Google. Please try again.", "error")
        return render_template("google_contacts_app/register.html")

    access_token = {'access_token': token.key,
            'access_token_secret': token.secret}

    schedule = {
            'interval': 'daily',
            'timeofday': '0700'}

    schedule.update(schedule_to_form_time('0700'))
    
    save_settings('google_contacts_app',
            {'schedule': schedule,
                'tokens': access_token,
                'profile': profile})

    reload_schedules()
    return render_template("google_contacts_app/register.html")
    

@module.route("/archives")
def archives():
    page, per_page = get_pagination_params(request)
    profile = get_settings("google_contacts_app")

    if not profile:
        logger.debug("no profile found. google_contacts_app was not setup")
        return redirect(url_for('preferences'))
Exemplo n.º 6
0
    except Exception, e:
        logger.debug('authentication error: %r', e)
        flash('There was a problem authenticating you with Google. Please try again.', 'error')
        return render_template('picasaweb_app/register.html')

    access_token = {'access_token': token.key,
            'access_token_secret': token.secret}
    
    schedule = {
            'interval': 'daily',
            'timeofday': '0700'}

    schedule.update(schedule_to_form_time('0700'))

    save_settings('picasaweb_app',
            {'schedule': schedule,
                'tokens': access_token,
                'profile': profile})

    reload_schedules()
    return render_template('picasaweb_app/register.html')

@module.route('/archives')
def archives():
    page, per_page = get_pagination_params(request)
    profile = get_settings('picasaweb_app')

    if not profile:
        logger.debug('no profile found. picasaweb was not setup')
        return redirect(url_for('preferences'))

    archives = get_paginated_archives('picasaweb_app', page, per_page)