bug fix to language preferences for unlogged in users. Also JS fix to all language pref pages.

This commit is contained in:
KeyserSosa
2009-08-12 11:28:05 -07:00
parent dd686f1f97
commit 9bc275c140
3 changed files with 19 additions and 5 deletions

View File

@@ -121,7 +121,8 @@ class UnloggedUser(FakeAccount):
def _commit(self):
if self._dirty:
self._t.update(self._dirties)
for k, (oldv, newv) in self._dirties.iteritems():
self._t[k] = newv
self._to_cookie(self._t)
def _load(self):
@@ -488,8 +489,13 @@ class RedditController(BaseController):
c.user_is_loggedin = True
else:
c.user = UnloggedUser(get_browser_langs())
c.user._load()
# patch for fixing mangled language preferences
if (not isinstance(c.user.pref_lang, basestring) or
not all(isinstance(x, basestring)
for x in c.user.pref_content_langs)):
c.user.pref_lang = g.lang
c.user.pref_content_langs = [g.lang]
c.user._commit()
if c.user_is_loggedin:
if not c.user._loaded:
c.user._load()

View File

@@ -1036,6 +1036,14 @@ var toolbar_p = function(expanded_size, collapsed_size) {
};
};
function clear_all_langs(elem) {
$(elem).parents("form").find("input[type=checkbox]").attr("checked", false);
}
function check_some_langs(elem) {
$(elem).parents("form").find("#some-langs").attr("checked", true);
}
/* The ready method */
$(function() {
/* set function to be called on thing creation/replacement,

View File

@@ -194,7 +194,7 @@ ${unsafe(txt)}
all_checked, some_checked = some_checked, all_checked
%>
<input type="radio" name="all-langs" id="all-langs" value="all"
onclick="clear_all(this)" ${all_checked}/>
onclick="clear_all_langs(this)" ${all_checked}/>
<label for="all-langs">${_("all languages")}</label>
<br/>
<input type="radio" name="all-langs" id="some-langs" value="some"
@@ -217,7 +217,7 @@ ${unsafe(txt)}
checked = ""
%>
<input type="checkbox" name="${idname}" id="${idname}"
onclick="check_some()" ${checked}/>
onclick="check_some_langs(this)" ${checked}/>
<label for="${idname}">${g.lang_name[lang]}</label>
</td>
%endfor