def save(self): privacy = request.POST.getone('fb_privacy') if privacy in dict(fb.get_privacy_options()): UserSetting.set(UserSettingConst.FB_PRIVACY, privacy) flickr_settings = self.settings.get(UserSettingConst.FLICKR_SET_SYNCING, {}) flickr_settings['select_sets'] = bool(request.POST.get('select_sets')) flickr_settings['selected_sets'] = request.POST.getall('selected_sets') UserSetting.set(UserSettingConst.FLICKR_SET_SYNCING, flickr_settings) h.flash("Your settings have been updated.") redirect(url('index'))
def save(self): privacy = request.POST.getone('fb_privacy') if privacy in dict(fb.get_privacy_options()): UserSetting.set(UserSettingConst.FB_PRIVACY, privacy) flickr_settings = self.settings.get( UserSettingConst.FLICKR_SET_SYNCING, {}) flickr_settings['select_sets'] = bool(request.POST.get('select_sets')) flickr_settings['selected_sets'] = request.POST.getall('selected_sets') UserSetting.set(UserSettingConst.FLICKR_SET_SYNCING, flickr_settings) h.flash("Your settings have been updated.") redirect(url('index'))
def run(self, user_id): self.user = User.get_by_id(user_id) if not self.user.verify_user(): # not really much we can do about this... log.info("Missing tokens for user %r", self.user) self.set_status(0, 0, "You need to log out and log back in again.") return self.fk = flickr.FlickrAPI(self.user.flickr_token) self.fb_user = fb.GraphUser(access_token=self.user.fb_access_token) photosets = self.fk.photosets_getList()[0] self.synced_photos = 0 self.total_photos = sum(int(pset.get("photos")) for pset in photosets) self.set_status(self.synced_photos, self.total_photos, "syncing Flickr photos to Facebook") settings = UserSetting.multiget( user_id=user_id, settings=[UserSettingConst.FB_PRIVACY, UserSettingConst.FLICKR_SET_SYNCING] ) self.fb_privacy = settings.get(UserSettingConst.FB_PRIVACY, "FB_DEFAULT") self.flickr_settings = settings.get(UserSettingConst.FLICKR_SET_SYNCING, {}) select_sets = self.flickr_settings.get("select_sets", False) selected_sets = self.flickr_settings.get("selected_sets", []) for photoset in photosets: if not select_sets or photoset.get("id") in selected_sets: self.sync_photoset(photoset) log.info("Finished job %r for user %r", self.job.jid, self.user.id) # once we are all done, let's submit the task to rerun in an hour. self.resubmit(delay=60 * 60)
def run(self, user_id): self.user = User.get_by_id(user_id) if not self.user.verify_user(): # not really much we can do about this... log.info("Missing tokens for user %r", self.user) self.set_status(0, 0, "You need to log out and log back in again.") return self.fk = flickr.FlickrAPI(self.user.flickr_token) self.fb_user = fb.GraphUser(access_token=self.user.fb_access_token) photosets = self.fk.photosets_getList()[0] self.synced_photos = 0 self.total_photos = sum(int(pset.get('photos')) for pset in photosets) self.set_status( self.synced_photos, self.total_photos, "syncing Flickr photos to Facebook") settings = UserSetting.multiget( user_id=user_id, settings=[UserSettingConst.FB_PRIVACY, UserSettingConst.FLICKR_SET_SYNCING]) self.fb_privacy = settings.get(UserSettingConst.FB_PRIVACY, 'FB_DEFAULT') self.flickr_settings = settings.get(UserSettingConst.FLICKR_SET_SYNCING, {}) select_sets = self.flickr_settings.get('select_sets', False) selected_sets = self.flickr_settings.get('selected_sets', []) for photoset in photosets: if not select_sets or photoset.get('id') in selected_sets: self.sync_photoset(photoset) log.info("Finished job %r for user %r", self.job.jid, self.user.id) # once we are all done, let's submit the task to rerun in an hour. self.resubmit(delay=60*60)
def settings(self): return UserSetting.multiget( settings=[UserSettingConst.FB_PRIVACY, UserSettingConst.FLICKR_SET_SYNCING])
def settings(self): return UserSetting.multiget(settings=[ UserSettingConst.FB_PRIVACY, UserSettingConst.FLICKR_SET_SYNCING ])