From f67eeee8c897f678963970d1852a3663b9e72d61 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 2 Apr 2015 16:34:41 -0400 Subject: [PATCH] Start conversion of the user admin/view --- endpoints/api/user.py | 22 +- endpoints/web.py | 1 + .../directives/ui/authorized-apps-manager.css | 3 + .../directives/ui/external-login-button.css | 3 + .../directives/ui/external-logins-manager.css | 11 + static/css/pages/user-view.css | 50 ++++ .../directives/authorized-apps-manager.html | 56 +++++ static/directives/convert-user-to-org.html | 102 +++++++++ static/directives/external-login-button.html | 4 +- .../directives/external-logins-manager.html | 63 +++++ static/directives/robots-manager.html | 4 +- static/js/app.js | 5 +- .../directives/ui/authorized-apps-manager.js | 41 ++++ .../js/directives/ui/convert-user-to-org.js | 62 +++++ .../js/directives/ui/external-login-button.js | 1 + .../directives/ui/external-logins-manager.js | 55 +++++ static/js/pages/user-admin.js | 6 +- static/js/pages/user-view.js | 113 +++++++++ static/partials/user-admin.html | 1 - static/partials/user-view.html | 215 ++++++++++++++++++ 20 files changed, 804 insertions(+), 14 deletions(-) create mode 100644 static/css/directives/ui/authorized-apps-manager.css create mode 100644 static/css/directives/ui/external-login-button.css create mode 100644 static/css/directives/ui/external-logins-manager.css create mode 100644 static/css/pages/user-view.css create mode 100644 static/directives/authorized-apps-manager.html create mode 100644 static/directives/convert-user-to-org.html create mode 100644 static/directives/external-logins-manager.html create mode 100644 static/js/directives/ui/authorized-apps-manager.js create mode 100644 static/js/directives/ui/convert-user-to-org.js create mode 100644 static/js/directives/ui/external-logins-manager.js create mode 100644 static/js/pages/user-view.js create mode 100644 static/partials/user-view.html diff --git a/endpoints/api/user.py b/endpoints/api/user.py index c3812e717..93e77f47c 100644 --- a/endpoints/api/user.py +++ b/endpoints/api/user.py @@ -2,7 +2,7 @@ import logging import json from random import SystemRandom -from flask import request +from flask import request, abort from flask.ext.login import logout_user from flask.ext.principal import identity_changed, AnonymousIdentity from peewee import IntegrityError @@ -59,7 +59,6 @@ def user_view(user): logins = model.list_federated_logins(user) user_response = { - 'verified': user.verified, 'anonymous': False, 'username': user.username, 'avatar': avatar.get_data_for_user(user) @@ -68,6 +67,8 @@ def user_view(user): user_admin = UserAdminPermission(user.username) if user_admin.can(): user_response.update({ + 'is_me': True, + 'verified': user.verified, 'email': user.email, 'organizations': [org_view(o) for o in organizations], 'logins': [login_view(login) for login in logins], @@ -77,7 +78,7 @@ def user_view(user): 'tag_expiration': user.removed_tag_expiration_s, }) - if features.SUPER_USERS: + if features.SUPER_USERS and SuperUserPermission().can(): user_response.update({ 'super_user': user and user == get_authenticated_user() and SuperUserPermission().can() }) @@ -788,6 +789,7 @@ class StarredRepositoryList(ApiResource): 'repository': repository, }, 201 + @resource('/v1/user/starred/') @path_param('repository', 'The full path of the repository. e.g. namespace/name') class StarredRepository(RepositoryParamResource): @@ -802,3 +804,17 @@ class StarredRepository(RepositoryParamResource): if repo: model.unstar_repository(user, repo) return 'Deleted', 204 + + +@resource('/v1/users/') +class Users(ApiResource): + """ Operations related to retrieving information about other users. """ + @nickname('getUserInformation') + def get(self, username): + """ Get user information for the specified user. """ + user = model.get_user(username) + if user is None or user.organization or user.robot: + abort(404) + + return user_view(user) + diff --git a/endpoints/web.py b/endpoints/web.py index 1359fd3bc..9b4640c6c 100644 --- a/endpoints/web.py +++ b/endpoints/web.py @@ -39,6 +39,7 @@ STATUS_TAGS = app.config['STATUS_TAGS'] @web.route('/', methods=['GET'], defaults={'path': ''}) @web.route('/organization/', methods=['GET']) +@web.route('/user/', methods=['GET']) @no_cache def index(path, **kwargs): return render_page_template('index.html', **kwargs) diff --git a/static/css/directives/ui/authorized-apps-manager.css b/static/css/directives/ui/authorized-apps-manager.css new file mode 100644 index 000000000..f3a74c8f7 --- /dev/null +++ b/static/css/directives/ui/authorized-apps-manager.css @@ -0,0 +1,3 @@ +.authorized-apps-manager .avatar { + margin-right: 4px; +} \ No newline at end of file diff --git a/static/css/directives/ui/external-login-button.css b/static/css/directives/ui/external-login-button.css new file mode 100644 index 000000000..390eda57d --- /dev/null +++ b/static/css/directives/ui/external-login-button.css @@ -0,0 +1,3 @@ +.external-login-button i.fa { + margin-right: 4px; +} \ No newline at end of file diff --git a/static/css/directives/ui/external-logins-manager.css b/static/css/directives/ui/external-logins-manager.css new file mode 100644 index 000000000..2c5ca7302 --- /dev/null +++ b/static/css/directives/ui/external-logins-manager.css @@ -0,0 +1,11 @@ +.external-logins-manager .empty { + color: #ccc; +} + +.external-logins-manager .external-auth-provider td:first-child { + font-size: 18px; +} + +.external-logins-manager .external-auth-provider td:first-child i.fa { + margin-right: 6px; +} \ No newline at end of file diff --git a/static/css/pages/user-view.css b/static/css/pages/user-view.css new file mode 100644 index 000000000..56c2b0a68 --- /dev/null +++ b/static/css/pages/user-view.css @@ -0,0 +1,50 @@ +.user-view .user-name { + vertical-align: middle; + margin-left: 6px; +} + +.user-view h3 { + margin-bottom: 20px; + margin-top: 0px; +} + +.user-view .section-description-header { + padding-left: 40px; + position: relative; + margin-bottom: 20px; +} + +.user-view .section-description-header:before { + font-family: FontAwesome; + content: "\f05a"; + position: absolute; + top: 2px; + left: 6px; + font-size: 27px; + color: #888; +} + +.user-view .user-settings-form .row { + padding: 10px; + margin: 0px; +} + +.user-view .co-panel { + position: relative; + min-height: 50px; +} + +.user-view .co-panel .panel-body { + position: relative; +} + +.user-view .co-panel .row { + margin: 10px; +} + +.user-view .co-panel .row .panel { + margin-bottom: 20px; + border-bottom: 0px; + box-shadow: none; +} + diff --git a/static/directives/authorized-apps-manager.html b/static/directives/authorized-apps-manager.html new file mode 100644 index 000000000..cc050346b --- /dev/null +++ b/static/directives/authorized-apps-manager.html @@ -0,0 +1,56 @@ +
+
+

Authorized Applications

+
+ +
+ The authorized applications panel lists applications you have authorized to view information and perform actions on your behalf. You can revoke any of your authorizations here by clicking the gear icon and clicking "Revoke Authorization". +
+ +
+ +
+
You have not authorized any external applications.
+
+ + + + + + + + + + + + + +
Application NameAuthorized Permissions
+ + + {{ authInfo.application.name }} + + + {{ authInfo.application.name }} + + {{ authInfo.application.organization.name }} + + + {{ scopeInfo.scope }} + + + + + Revoke Authorization + + +
+
+ \ No newline at end of file diff --git a/static/directives/convert-user-to-org.html b/static/directives/convert-user-to-org.html new file mode 100644 index 000000000..8011ecf50 --- /dev/null +++ b/static/directives/convert-user-to-org.html @@ -0,0 +1,102 @@ +
+ +
+
+
+ Cannot convert this account into an organization, as it is a member of {{user.organizations.length}} other + organization{{user.organizations.length > 1 ? 's' : ''}}. Please leave + {{user.organizations.length > 1 ? 'those organizations' : 'that organization'}} first. +
+
+ +
+
+ Note: Converting a user account into an organization cannot be undone +
+ + +
+
+ + +
+

Convert to organization

+ +
+
+ +
+ + {{ user.username }}
+ This will continue to be the namespace for your repositories +
+ +
+ + + + + The username and password for the account that will become an administrator of the organization. + Note that this account must be a separate registered account from the account that you are + trying to convert, and must already exist. + +
+ + +
+ +
+
+ +
+ +
+
+
+ + + + + + + + +
\ No newline at end of file diff --git a/static/directives/external-login-button.html b/static/directives/external-login-button.html index 10701f941..edf81a36a 100644 --- a/static/directives/external-login-button.html +++ b/static/directives/external-login-button.html @@ -1,6 +1,6 @@