diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index 88106809f..c74417f92 100755 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -2878,16 +2878,25 @@ class ApiController(RedditController, OAuth2ResourceController): client=VOAuth2ClientDeveloper(), account=VExistingUnameNotSelf('name')) def POST_adddeveloper(self, form, jquery, client, account): - if client and not form.has_error('name'): - client.add_developer(account) - form.set_html('.status', _('developer added')) + if not client: + form.set_html('.status', _('error')) + return + if form.has_errors('name', errors.USER_DOESNT_EXIST, errors.NO_USER): + form.set_html('.status', _('invalid user')) + return + if client.has_developer(account): + form.set_html('.status', _('already added')) + return + client.add_developer(account) + form.set_html('.status', _('developer added')) @validatedForm(VUser(), VModhash(), client=VOAuth2ClientDeveloper(), account=VExistingUnameNotSelf('name')) def POST_removedeveloper(self, form, jquery, client, account): - if client and not form.has_error('name'): + if client and account and not form.has_errors('name'): + g.log.debug('removing developer: %s', account.name) client.remove_developer(account) form.set_html('.status', _('developer removed')) diff --git a/r2/r2/lib/js.py b/r2/r2/lib/js.py index e60528c23..66a2a2090 100755 --- a/r2/r2/lib/js.py +++ b/r2/r2/lib/js.py @@ -277,6 +277,7 @@ module["reddit"] = LocalizedModule("reddit.js", "flair.js", "interestbar.js", "reddit.js", + "apps.js", ) module["mobile"] = LocalizedModule("mobile.js", diff --git a/r2/r2/public/static/css/reddit.css b/r2/r2/public/static/css/reddit.css index e2044b5c7..b125c6352 100755 --- a/r2/r2/public/static/css/reddit.css +++ b/r2/r2/public/static/css/reddit.css @@ -5835,3 +5835,58 @@ tr.gold-accent + tr > td { color: gray; font-weight: bold; } + +.developed-app { + border: solid 1px black; + margin-left: 20px; + margin-bottom: 0.5em; + padding: 7px; + position: relative; + width: 880px; +} + +.developed-app .collapsed { display: none; } +.developed-app img { + height: 64px; + width: 64px; +} + +.app-details { + position: absolute; + top: 7px; + left: 80px; + height: 64px; + margin-left: 0.5em; + vertical-align: top; +} + +.app-details h2 { font-size: medium; } +.app-details h3 { font-size: x-small; } + +.app-description { + font-size: small; + position: absolute; + top: 0px; + left: 200px; + width: 600px; +} + +.edit-app-button { + position: absolute; + bottom: 0px; +} + +.edit-app { display: none; } +.edit-app-form, .edit-app-form form { display: inline-block; } +.edit-app-form input, .edit-app-form textarea { margin: 0px; width: 50ex; } +.edit-app-form input[name="name"] { width: 20ex !important; } +.edit-app-form input[type="submit"] { + margin-left: 10px; + width: auto !important; +} + +.delete-app-button { + position: absolute; + bottom: 7px; + left: 100px; +} diff --git a/r2/r2/public/static/js/apps.js b/r2/r2/public/static/js/apps.js new file mode 100644 index 000000000..dfe0e1359 --- /dev/null +++ b/r2/r2/public/static/js/apps.js @@ -0,0 +1,7 @@ +$(function() { + $(".edit-app-button").click( + function() { + $(this).toggleClass("collapsed"); + $(this).parent().parent().find(".edit-app").slideToggle(); + }); +}); diff --git a/r2/r2/templates/oauth2authorization.html b/r2/r2/templates/oauth2authorization.html index 82ba08428..e2781b025 100644 --- a/r2/r2/templates/oauth2authorization.html +++ b/r2/r2/templates/oauth2authorization.html @@ -26,8 +26,13 @@ <%namespace file="utils.html" import="_md" />
+ %endfor %else:are you a developer? create an app...
%endif -