mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 15:58:06 -05:00
Add ModAction for distinguishing links and comments.
This commit is contained in:
committed by
Neil Williams
parent
b14b73e109
commit
8eef6e1cd3
@@ -1418,12 +1418,30 @@ class ApiController(RedditController):
|
||||
how = VOneOf('how', ('yes','no','admin','special')))
|
||||
def POST_distinguish(self, form, jquery, thing, how):
|
||||
if not thing:return
|
||||
|
||||
log_modaction = True
|
||||
log_kw = {}
|
||||
original = thing.distinguished if hasattr(thing, 'distinguished') else 'no'
|
||||
if how == original:
|
||||
log_modaction = False # Distinguish unchanged
|
||||
elif how in ('admin', 'special'):
|
||||
log_modaction = False # Add admin/special
|
||||
elif original in ('admin', 'special') and how == 'no':
|
||||
log_modaction = False # Remove admin/special
|
||||
elif how == 'no':
|
||||
log_kw['details'] = 'remove' # yes --> no
|
||||
else:
|
||||
pass # no --> yes
|
||||
|
||||
thing.distinguished = how
|
||||
thing._commit()
|
||||
wrapper = default_thing_wrapper(expand_children = True)
|
||||
w = wrap_links(thing, wrapper)
|
||||
jquery(".content").replace_things(w, True, True)
|
||||
jquery(".content .link .rank").hide()
|
||||
if log_modaction:
|
||||
sr = thing.subreddit_slow
|
||||
ModAction.create(sr, c.user, 'distinguish', target=thing, **log_kw)
|
||||
|
||||
@noresponse(VUser(),
|
||||
VModhash(),
|
||||
|
||||
@@ -26,7 +26,7 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
|
||||
actions = ('banuser', 'unbanuser', 'removelink', 'approvelink',
|
||||
'removecomment', 'approvecomment', 'addmoderator',
|
||||
'removemoderator', 'addcontributor', 'removecontributor',
|
||||
'editsettings', 'editflair')
|
||||
'editsettings', 'editflair', 'distinguish')
|
||||
|
||||
_menu = {'banuser': _('ban user'),
|
||||
'unbanuser': _('unban user'),
|
||||
@@ -39,20 +39,22 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
|
||||
'addcontributor': _('add contributor'),
|
||||
'removecontributor': _('remove contributor'),
|
||||
'editsettings': _('edit settings'),
|
||||
'editflair': _('edit user flair')}
|
||||
'editflair': _('edit user flair'),
|
||||
'distinguish': _('distinguish')}
|
||||
|
||||
_text = {'banuser': _('banned'),
|
||||
'unbanuser': _('unbanned'),
|
||||
'removelink': _('removed post'),
|
||||
'approvelink': _('approved post'),
|
||||
'removecomment': _('removed comment'),
|
||||
'approvecomment': _('approved comment'),
|
||||
'removelink': _('removed'),
|
||||
'approvelink': _('approved'),
|
||||
'removecomment': _('removed'),
|
||||
'approvecomment': _('approved'),
|
||||
'addmoderator': _('added moderator'),
|
||||
'removemoderator': _('removed moderator'),
|
||||
'addcontributor': _('added approved contributor'),
|
||||
'removecontributor': _('removed approved contributor'),
|
||||
'editsettings': _('edited settings'),
|
||||
'editflair': _('edited user flair')}
|
||||
'editflair': _('edited user flair'),
|
||||
'distinguish': _('distinguished')}
|
||||
|
||||
_details_text = {# approve comment/link
|
||||
'unspam': _('unspam'),
|
||||
@@ -224,9 +226,11 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
|
||||
short_title = title[:TITLE_MAX_WIDTH] + '...'
|
||||
else:
|
||||
short_title = title
|
||||
text = '"%(title)s" %(by)s %(author)s' % {'title': short_title,
|
||||
'by': _('by'),
|
||||
'author': author.name}
|
||||
text = '%(link)s "%(title)s" %(by)s %(author)s' % {
|
||||
'link': _('link'),
|
||||
'title': short_title,
|
||||
'by': _('by'),
|
||||
'author': author.name}
|
||||
path = target.make_permalink(subreddits[target.sr_id])
|
||||
target_links[fullname] = (text, path, title)
|
||||
elif isinstance(target, Comment):
|
||||
@@ -237,10 +241,12 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
|
||||
short_title = title[:TITLE_MAX_WIDTH] + '...'
|
||||
else:
|
||||
short_title = title
|
||||
text = '%(by)s %(author)s %(on)s "%(title)s"' % {'by': _('by'),
|
||||
'author': author.name,
|
||||
'on': _('on'),
|
||||
'title': short_title}
|
||||
text = '%(comment)s %(by)s %(author)s %(on)s "%(title)s"' % {
|
||||
'comment': _('comment'),
|
||||
'by': _('by'),
|
||||
'author': author.name,
|
||||
'on': _('on'),
|
||||
'title': short_title}
|
||||
path = target.make_permalink(link, subreddits[link.sr_id])
|
||||
target_links[fullname] = (text, path, title)
|
||||
elif isinstance(target, Account):
|
||||
|
||||
@@ -5009,7 +5009,8 @@ tr.gold-accent + tr > td {
|
||||
.modactions.addcontributor,
|
||||
.modactions.removecontributor,
|
||||
.modactions.editsettings,
|
||||
.modactions.editflair {
|
||||
.modactions.editflair,
|
||||
.modactions.distinguish {
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
display: block;
|
||||
@@ -5053,3 +5054,6 @@ tr.gold-accent + tr > td {
|
||||
.modactions.editflair {
|
||||
background-image: url(../modactions_editflair.png); /* SPRITE */
|
||||
}
|
||||
.modactions.distinguish {
|
||||
background-image: url(../modactions_distinguish.png); /* SPRITE */
|
||||
}
|
||||
|
||||
BIN
r2/r2/public/static/modactions_distinguish.png
Executable file
BIN
r2/r2/public/static/modactions_distinguish.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 789 B |
Reference in New Issue
Block a user