def __init__(self, system, subject): self.chat_channel = quote(g.live_config['chat_channel_name_prefix'] + subject + g.live_config['chat_channel_name_suffix']) # CUSTOM - chat plugin upgrade script if c.user_is_loggedin and c.user.pref_chat_client_user == "guest": # g.log.warning("!!! chat plugin: upgrading chat preferences for user: %s" % c.user.name) prefs = { 'pref_chat_client_user': "".join(random.choice(string.ascii_letters+string.digits) for i in range(20)), 'pref_chat_client_password': "".join(random.choice(string.ascii_letters+string.digits) for i in range(20)) } if c.user.pref_chat_user == "guest": # g.log.warning("!!! chat plugin: upgrading chat user for user: %s" % c.user.name) prefs["pref_chat_user"] = c.user.name set_prefs(c.user, prefs) c.user._commit() self.chat_user = c.user.pref_chat_user self.chat_client_user = c.user.pref_chat_client_user self.chat_client_password = c.user.pref_chat_client_password self.chat_client = g.live_config['chat_client'] self.chat_client_url = g.live_config['chat_client_url'] self.user_is_loggedin = c.user_is_loggedin Templated.__init__(self)
def PATCH_prefs(self, validated_prefs): user_prefs = c.user.preferences() for short_name, new_value in validated_prefs.iteritems(): pref_name = "pref_" + short_name user_prefs[pref_name] = new_value vprefs.filter_prefs(user_prefs, c.user) vprefs.set_prefs(c.user, user_prefs) c.user._commit() return self.api_wrapper(PrefsJsonTemplate().data(c.user))
def POST_options(self, all_langs, **prefs): filter_prefs(prefs, c.user) if c.errors.errors: return abort(BadRequestError(errors.INVALID_PREF)) set_prefs(c.user, prefs) c.user._commit() u = UrlParser(c.site.path + "prefs") u.update_query(done = 'true') if c.cname: u.put_in_frame() return self.redirect(u.unparse())
def POST_options(self, all_langs, **prefs): filter_prefs(prefs, c.user) if c.errors.errors: return abort(BadRequestError(errors.INVALID_PREF)) set_prefs(c.user, prefs) c.user._commit() u = UrlParser(c.site.path + "prefs") u.update_query(done='true') if c.cname: u.put_in_frame() return self.redirect(u.unparse())
def POST_bpoptions(self, all_langs, **prefs): u = UrlParser(c.site.path + "prefs") bpfilter_prefs(prefs, c.user) if c.errors.errors: for error in c.errors.errors: if error[1] == 'stylesheet_override': u.update_query(error_style_override=error[0]) else: u.update_query(generic_error=error[0]) return self.redirect(u.unparse()) set_prefs(c.user, prefs) c.user._commit() u.update_query(done='true') return self.redirect(u.unparse())
def POST_options(self, all_langs, **prefs): if feature.is_enabled("autoexpand_media_previews"): validator = VOneOf('media_preview', ('on', 'off', 'subreddit')) value = request.params.get('media_preview') prefs["pref_media_preview"] = validator.run(value) u = UrlParser(c.site.path + "prefs") filter_prefs(prefs, c.user) if c.errors.errors: for error in c.errors.errors: if error[1] == 'stylesheet_override': u.update_query(error_style_override=error[0]) else: u.update_query(generic_error=error[0]) return self.redirect(u.unparse()) set_prefs(c.user, prefs) c.user._commit() u.update_query(done='true') return self.redirect(u.unparse())
def POST_unlogged_options(self, all_langs, pref_lang): prefs = {"pref_lang": pref_lang} set_prefs(c.user, prefs) c.user._commit() return self.redirect(request.referer)
def POST_unlogged_options(self, all_langs, pref_lang): content_langs = self._langs_from_post(all_langs) prefs = {"pref_content_lang": content_langs, "pref_lang": pref_lang} set_prefs(c.user, prefs) c.user._commit() return self.redirect(request.referer)
def POST_unlogged_options(self, all_langs, pref_lang): prefs = {"pref_lang": pref_lang} set_prefs(c.user, prefs) c.user._commit() return self.redirect(request.referer, 302, False)