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)
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"))
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"))
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')) archives = get_paginated_archives("google_contacts_app", page, per_page) return render_template("google_contacts_app/archives.html",