diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index 3ca6057ec..4dc998cee 100644 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -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(), diff --git a/r2/r2/models/modaction.py b/r2/r2/models/modaction.py index aa334dcf5..ba9794959 100644 --- a/r2/r2/models/modaction.py +++ b/r2/r2/models/modaction.py @@ -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): diff --git a/r2/r2/public/static/css/reddit.css b/r2/r2/public/static/css/reddit.css index 75631f1f2..0c3aecafe 100644 --- a/r2/r2/public/static/css/reddit.css +++ b/r2/r2/public/static/css/reddit.css @@ -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 */ +} diff --git a/r2/r2/public/static/modactions_distinguish.png b/r2/r2/public/static/modactions_distinguish.png new file mode 100755 index 000000000..6e0015df4 Binary files /dev/null and b/r2/r2/public/static/modactions_distinguish.png differ