banning: Add an endpoint to add a note to banned users.

This commit is contained in:
Andre D
2013-05-20 22:35:49 -07:00
committed by Roger Ostrander
parent 163f206722
commit 1e1435be14
3 changed files with 16 additions and 0 deletions

View File

@@ -303,6 +303,9 @@ def make_map():
"add_roadblock|rm_roadblock")))
mc('/api/:action', controller='apiminimal',
requirements=dict(action="new_captcha"))
mc('/api/:type', controller='api',
requirements=dict(type='wikibannednote|bannednote'),
action='relnote')
mc('/api/:action', controller='api')
mc("/api/v1/:action", controller="oauth2frontend",

View File

@@ -813,6 +813,13 @@ class ApiController(RedditController, OAuth2ResourceController):
c.user.add_friend_note(friend, note)
form.set_html('.status', _("saved"))
@validatedForm(type = VOneOf('type', ('bannednote', 'wikibannednote')),
user = VExistingUname('name'),
note = VLength('note', 300))
def POST_relnote(self, form, jquery, type, user, note):
c.site.add_rel_note(type[:-4], user, note)
form.set_html('.status', _("saved"))
@validatedForm(VUser(),
VModhash(),
ip=ValidIP())

View File

@@ -883,6 +883,12 @@ class Subreddit(Thing, Printable):
rel.update_permissions(**kwargs)
rel._commit()
def add_rel_note(self, type, user, note):
rel = getattr(self, "get_%s" % type)(user)
if not rel:
raise ValueError("User is not %s." % type)
rel.note = note
rel._commit()
class FakeSubreddit(Subreddit):
over_18 = False