diff --git a/r2/r2/config/routing.py b/r2/r2/config/routing.py index 3ab05823c..77289f127 100644 --- a/r2/r2/config/routing.py +++ b/r2/r2/config/routing.py @@ -118,7 +118,7 @@ def make_map(global_conf={}, app_conf={}): action='resetpassword') mc('/post/:action', controller='post', - requirements=dict(action="options|over18")) + requirements=dict(action="options|over18|unlogged_options")) mc('/api/:action', controller='api') mc('/d/:what', controller='api', action='bookmarklet') diff --git a/r2/r2/controllers/post.py b/r2/r2/controllers/post.py index 9ef5d8b02..c2101917d 100644 --- a/r2/r2/controllers/post.py +++ b/r2/r2/controllers/post.py @@ -50,24 +50,7 @@ class PostController(ApiController): # c.user._commit() # return {} - @validate(pref_frame = VBoolean('frame'), - pref_organic = VBoolean('organic'), - pref_newwindow = VBoolean('newwindow'), - pref_public_votes = VBoolean('public_votes'), - pref_hide_ups = VBoolean('hide_ups'), - pref_hide_downs = VBoolean('hide_downs'), - pref_over_18 = VBoolean('over_18'), - pref_numsites = VInt('numsites', 1, 100), - pref_lang = VLang('lang'), - pref_media = VOneOf('media', ('on', 'off', 'subreddit')), - pref_compress = VBoolean('compress'), - pref_min_link_score = VInt('min_link_score', -100, 100), - pref_min_comment_score = VInt('min_comment_score', -100, 100), - pref_num_comments = VInt('num_comments', 1, g.max_comments, - default = g.num_comments), - all_langs = nop('all-langs', default = 'all')) - def POST_options(self, all_langs, pref_lang, **kw): - #TODO + def set_options(self, all_langs, pref_lang, **kw): if c.errors.errors: print "fucker" raise "broken" @@ -95,9 +78,32 @@ class PostController(ApiController): c.user.pref_lang = pref_lang c.user._commit() - if c.user_is_loggedin: - return self.redirect("/prefs?done=true") - return self.redirect(request.referer) + + @validate(pref_lang = VLang('lang'), + all_langs = nop('all-langs', default = 'all')) + def POST_unlogged_options(self, all_langs, pref_lang): + self.set_options( all_langs, pref_lang) + return self.redirect(request.referer) + + @validate(pref_frame = VBoolean('frame'), + pref_organic = VBoolean('organic'), + pref_newwindow = VBoolean('newwindow'), + pref_public_votes = VBoolean('public_votes'), + pref_hide_ups = VBoolean('hide_ups'), + pref_hide_downs = VBoolean('hide_downs'), + pref_over_18 = VBoolean('over_18'), + pref_numsites = VInt('numsites', 1, 100), + pref_lang = VLang('lang'), + pref_media = VOneOf('media', ('on', 'off', 'subreddit')), + pref_compress = VBoolean('compress'), + pref_min_link_score = VInt('min_link_score', -100, 100), + pref_min_comment_score = VInt('min_comment_score', -100, 100), + pref_num_comments = VInt('num_comments', 1, g.max_comments, + default = g.num_comments), + all_langs = nop('all-langs', default = 'all')) + def POST_options(self, all_langs, pref_lang, **kw): + self.set_options(all_langs, pref_lang, **kw) + return self.redirect("/prefs?done=true") def GET_over18(self): return BoringPage(_("over 18?"), diff --git a/r2/r2/templates/prefoptions.html b/r2/r2/templates/prefoptions.html index 3f82f98a9..4550f3882 100644 --- a/r2/r2/templates/prefoptions.html +++ b/r2/r2/templates/prefoptions.html @@ -59,7 +59,13 @@
${_("your preferences have been updated")}
%endif -