mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 07:48:16 -05:00
Add sr setting for flair self-assignment.
This commit is contained in:
@@ -2006,13 +2006,17 @@ class ApiController(RedditController):
|
||||
c.user._commit()
|
||||
jquery.refresh()
|
||||
|
||||
@validatedForm(VFlairManager(),
|
||||
VModhash(),
|
||||
flair_enabled = VBoolean("flair_enabled"),
|
||||
flair_position = VOneOf("flair_position", ("left", "right")))
|
||||
def POST_flairconfig(self, form, jquery, flair_enabled, flair_position):
|
||||
@validatedForm(
|
||||
VFlairManager(),
|
||||
VModhash(),
|
||||
flair_enabled = VBoolean("flair_enabled"),
|
||||
flair_position = VOneOf("flair_position", ("left", "right")),
|
||||
flair_self_assign_enabled = VBoolean("flair_self_assign_enabled"))
|
||||
def POST_flairconfig(self, form, jquery, flair_enabled, flair_position,
|
||||
flair_self_assign_enabled):
|
||||
c.site.flair_enabled = flair_enabled
|
||||
c.site.flair_position = flair_position
|
||||
c.site.flair_self_assign_enabled = flair_self_assign_enabled
|
||||
c.site._commit()
|
||||
jquery.refresh()
|
||||
|
||||
@@ -2083,6 +2087,11 @@ class ApiController(RedditController):
|
||||
flair_template_id, c.site._id)
|
||||
return
|
||||
|
||||
if not c.site.flair_self_assign_enabled:
|
||||
# TODO: serve error to client
|
||||
g.log.debug('flair self-assignment not permitted')
|
||||
return
|
||||
|
||||
text = flair_template.text
|
||||
css_class = flair_template.css_class
|
||||
|
||||
|
||||
@@ -2421,7 +2421,8 @@ class FlairPane(Templated):
|
||||
self,
|
||||
tabs=TabbedPane(tabs),
|
||||
flair_enabled=c.site.flair_enabled,
|
||||
flair_position=c.site.flair_position)
|
||||
flair_position=c.site.flair_position,
|
||||
flair_self_assign_enabled=c.site.flair_self_assign_enabled)
|
||||
|
||||
class FlairList(Templated):
|
||||
"""List of users who are tagged with flair within a subreddit."""
|
||||
@@ -2541,11 +2542,16 @@ class FlairPrefs(CachedTemplate):
|
||||
sr_flair_enabled = getattr(c.site, 'flair_enabled', True)
|
||||
user_flair_enabled = getattr(c.user, 'flair_%s_enabled' % c.site._id,
|
||||
True)
|
||||
sr_flair_self_assign_enabled = getattr(
|
||||
c.site, 'flair_self_assign_enabled', True)
|
||||
wrapped_user = WrappedUser(c.user, subreddit=c.site,
|
||||
force_show_flair=True)
|
||||
CachedTemplate.__init__(self, sr_flair_enabled=sr_flair_enabled,
|
||||
user_flair_enabled=user_flair_enabled,
|
||||
wrapped_user=wrapped_user)
|
||||
CachedTemplate.__init__(
|
||||
self,
|
||||
sr_flair_enabled=sr_flair_enabled,
|
||||
sr_flair_self_assign_enabled=sr_flair_self_assign_enabled,
|
||||
user_flair_enabled=user_flair_enabled,
|
||||
wrapped_user=wrapped_user)
|
||||
|
||||
class FlairSelector(CachedTemplate):
|
||||
"""Provide user with flair options according to subreddit settings."""
|
||||
|
||||
@@ -75,6 +75,7 @@ class Subreddit(Thing, Printable):
|
||||
link_type = 'any', # one of ('link', 'self', 'any')
|
||||
flair_enabled = True,
|
||||
flair_position = 'right', # one of ('left', 'right')
|
||||
flair_self_assign_enabled = False,
|
||||
)
|
||||
_essentials = ('type', 'name', 'lang')
|
||||
_data_int_props = Thing._data_int_props + ('mod_actions', 'reported')
|
||||
|
||||
@@ -688,6 +688,13 @@ ul.flat-vert {text-align: left;}
|
||||
|
||||
.flairselector { font-size: x-small; position: absolute; width: 400px; }
|
||||
|
||||
.flairselector h2 {
|
||||
background: #cee3f8;
|
||||
padding-bottom: 2px;
|
||||
margin-bottom: 3px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.flairselector.drop-choices.active {
|
||||
border: 1px solid gray;
|
||||
display: block;
|
||||
|
||||
@@ -67,7 +67,7 @@ $(function() {
|
||||
.css("left",
|
||||
($(button).position().left + $(button).width() - width)
|
||||
+ "px");
|
||||
$(".flairselector li").click(postFlairSelection);
|
||||
$(".flairselector li:not(.error)").click(postFlairSelection);
|
||||
}
|
||||
|
||||
$(".flairselector").html('<img src="/static/throbber.gif" />');
|
||||
|
||||
@@ -35,7 +35,20 @@
|
||||
checked="checked"
|
||||
%endif
|
||||
/>
|
||||
<label for="sr_flair_enabled">${_("enable user flair in this subreddit")}</label>
|
||||
<label for="sr_flair_enabled">
|
||||
${_("enable user flair in this subreddit")}
|
||||
</label>
|
||||
<br>
|
||||
<input type="checkbox"
|
||||
id="sr_flair_self_assign_enabled"
|
||||
name="flair_self_assign_enabled"
|
||||
%if thing.flair_self_assign_enabled:
|
||||
checked="checked"
|
||||
%endif
|
||||
/>
|
||||
<label for="sr_flair_self_assign_enabled">
|
||||
${_("allow users to assign their own flair")}
|
||||
</label>
|
||||
</%utils:line_field>
|
||||
<%utils:line_field title="${_('flair position')}">
|
||||
<table class="small-field">
|
||||
|
||||
@@ -30,8 +30,10 @@
|
||||
>
|
||||
${_("Show my flair on this reddit. It looks like:")}
|
||||
<div>${thing.wrapped_user}</div>
|
||||
<a class="flairselectbtn" href="javascript://">select</a>
|
||||
<div class="flairselector drop-choices"></div>
|
||||
%if thing.sr_flair_self_assign_enabled:
|
||||
<a class="flairselectbtn" href="javascript://">select</a>
|
||||
<div class="flairselector drop-choices"></div>
|
||||
%endif
|
||||
</form>
|
||||
%endif
|
||||
|
||||
|
||||
@@ -20,15 +20,22 @@
|
||||
## CondeNet, Inc. All Rights Reserved.
|
||||
################################################################################
|
||||
|
||||
<h2>${_("select flair")}</h2>
|
||||
<ul>
|
||||
%for choice in thing.choices:
|
||||
<%
|
||||
c = 'flairsample-%s' % thing.position
|
||||
if choice.flair_template_id == thing.matching_template:
|
||||
c += ' selected'
|
||||
%>
|
||||
<li class="${c}" id="${choice.flair_template_id}">
|
||||
${choice}
|
||||
%if c.site.flair_self_assign_enabled:
|
||||
%for choice in thing.choices:
|
||||
<%
|
||||
li_class = 'flairsample-%s' % thing.position
|
||||
if choice.flair_template_id == thing.matching_template:
|
||||
li_class += ' selected'
|
||||
%>
|
||||
<li class="${li_class}" id="${choice.flair_template_id}">
|
||||
${choice}
|
||||
</li>
|
||||
%endfor
|
||||
%else:
|
||||
<li class="error">
|
||||
${_("flair selection unavailable")}
|
||||
</li>
|
||||
%endfor
|
||||
%endif
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user