Commit 427df6dadcb9594532cf04160a8559056cb9caee
Persist user authorization of an app
- Add authorized_clients table, a normalized table to store authorization
done by user for an app. Now when a user authorizes an app(grants
permission), it is remembered by swtstore and it does not ask the user to allow
the app every time.
- Add route /users/me/authorized_apps to list all the apps authorized by
current user, and an interface to revoke access to specific apps.
- Structured the templates folder.
| | | | 20 | | 20 | |
---|
21 | # Import all modules which represents a SQLAlchemy model; | 21 | # Import all modules which represents a SQLAlchemy model; |
---|
22 | # they have corresponding tables that are needed to be created | 22 | # they have corresponding tables that are needed to be created |
---|
23 | from swtstore.classes.models import Sweet, Context, Client | | from swtstore.classes.models import Sweet, Context, Client |
---|
| | 23 | from swtstore.classes.models import Sweet, Context, Client, AuthorizedClients | 24 | from swtstore.classes.models.um import User, Group, Membership | 24 | from swtstore.classes.models.um import User, Group, Membership |
---|
25 | | 25 | |
---|
26 | # Create them! | 26 | # Create them! |
---|
| | | | 19 | # Run the server if this script is directly executed | 19 | # Run the server if this script is directly executed |
---|
20 | # Presumably, this is development mode | 20 | # Presumably, this is development mode |
---|
21 | if __name__ == '__main__': | 21 | if __name__ == '__main__': |
---|
22 | app.run(host='0.0.0.0', port=5001) | | app.run(host='0.0.0.0', port=5001) |
---|
| | 22 | app.run(debug=True, host='0.0.0.0', port=5001) |
| | | | 1 | from context import Context | 1 | from context import Context |
---|
2 | from sweet import Sweet | 2 | from sweet import Sweet |
---|
3 | from client import Client | | from client import Client |
---|
| | 3 | from client import Client, AuthorizedClients |
| | | | 219 | @oauth.usergetter | 219 | @oauth.usergetter |
---|
220 | def getUser(): | 220 | def getUser(): |
---|
221 | return User.getCurrentUser() | 221 | return User.getCurrentUser() |
---|
| | 222 | |
---|
| | 223 | |
---|
| | 224 | |
---|
| | 225 | # Authorized Clients |
---|
| | 226 | class AuthorizedClients(db.Model): |
---|
| | 227 | """ |
---|
| | 228 | The clients authorized by users |
---|
| | 229 | """ |
---|
| | 230 | |
---|
| | 231 | __tablename__ = 'authorized_clients' |
---|
| | 232 | |
---|
| | 233 | id = db.Column(db.Integer, primary_key=True) |
---|
| | 234 | |
---|
| | 235 | client_id = db.Column(db.String(40), db.ForeignKey('clients.id'), |
---|
| | 236 | nullable=False) |
---|
| | 237 | client = db.relationship('Client') |
---|
| | 238 | |
---|
| | 239 | user_id = db.Column(db.Integer, db.ForeignKey('users.id')) |
---|
| | 240 | user = db.relationship('User') |
---|
| | 241 | |
---|
| | 242 | def persist(self): |
---|
| | 243 | db.session.add(self) |
---|
| | 244 | db.session.commit() |
---|
| | 245 | |
---|
| | 246 | @staticmethod |
---|
| | 247 | def revoke(**kwargs): |
---|
| | 248 | user = kwargs.get('user') |
---|
| | 249 | client = kwargs.get('client') |
---|
| | 250 | authorization = AuthorizedClients.query.filter_by(user_id=user.id, |
---|
| | 251 | client_id=client.client_id).first() |
---|
| | 252 | current_app.logger.debug('authorization to be revoked-- %s', |
---|
| | 253 | authorization) |
---|
| | 254 | db.session.delete(authorization) |
---|
| | 255 | db.session.commit() |
---|
| | 256 | |
---|
| | 257 | @staticmethod |
---|
| | 258 | def getByUser(user): |
---|
| | 259 | authorized_clients = [row.client for row in \ |
---|
| | 260 | AuthorizedClients.query.filter_by(user_id=user.id).all()] |
---|
| | 261 | |
---|
| | 262 | current_app.logger.debug('authorized clients %s', authorized_clients) |
---|
| | 263 | |
---|
| | 264 | return authorized_clients |
---|
| | | | 22 | return redirect(url_for('frontend.index')) | 22 | return redirect(url_for('frontend.index')) |
---|
23 | | 23 | |
---|
24 | if request.method == 'GET': | 24 | if request.method == 'GET': |
---|
25 | return render_template('register_app.html') | | return render_template('register_app.html') |
---|
| | 25 | return render_template('app/register.html') | 26 | | 26 | |
---|
27 | elif request.method == 'POST': | 27 | elif request.method == 'POST': |
---|
28 | req_fields = ['name', 'host_url', 'redirect_uris', 'scopes'] | 28 | req_fields = ['name', 'host_url', 'redirect_uris', 'scopes'] |
---|
| | | | 17 | return redirect(url_for('frontend.index')) | 17 | return redirect(url_for('frontend.index')) |
---|
18 | | 18 | |
---|
19 | if request.method == 'GET': | 19 | if request.method == 'GET': |
---|
20 | return render_template('register_context.html') | | return render_template('register_context.html') |
---|
| | 20 | return render_template('context/register.html') | 21 | | 21 | |
---|
22 | if request.method == 'POST': | 22 | if request.method == 'POST': |
---|
23 | if not request.form.get('name') or not request.form.get('defn'): | 23 | if not request.form.get('name') or not request.form.get('defn'): |
---|
| | | | 19 | | 19 | |
---|
20 | user = User.getCurrentUser() | 20 | user = User.getCurrentUser() |
---|
21 | | 21 | |
---|
22 | return render_template('index.html', sweets=sweets) | | return render_template('index.html', sweets=sweets) |
---|
| | 22 | return render_template('frontend/index.html', sweets=sweets) | 23 | | 23 | |
---|
24 | | 24 | |
---|
25 | # Create a new sweet context | 25 | # Create a new sweet context |
---|
| | | | 3 | | 3 | |
---|
4 | from flask import Module, jsonify, request, render_template, redirect,\ | 4 | from flask import Module, jsonify, request, render_template, redirect,\ |
---|
5 | url_for, current_app | 5 | url_for, current_app |
---|
| | 6 | import requests |
---|
6 | | 7 | |
---|
7 | from swtstore.classes import oauth | 8 | from swtstore.classes import oauth |
---|
8 | from swtstore.classes.models.um import User | 9 | from swtstore.classes.models.um import User |
---|
9 | from swtstore.classes.models import Client | | from swtstore.classes.models import Client |
---|
| | 10 | from swtstore.classes.models import Client, AuthorizedClients | 10 | | 11 | |
---|
11 | | 12 | |
---|
12 | Oauth = Module(__name__) | 13 | Oauth = Module(__name__) |
---|
13 | | 14 | |
---|
| | 15 | |
---|
14 | @Oauth.route('/authorize', methods=['GET', 'POST']) | 16 | @Oauth.route('/authorize', methods=['GET', 'POST']) |
---|
15 | @oauth.authorize_handler | 17 | @oauth.authorize_handler |
---|
16 | def authorize(*args, **kwargs): | 18 | def authorize(*args, **kwargs): |
---|
17 | current_user = User.getCurrentUser() | 19 | current_user = User.getCurrentUser() |
---|
18 | if current_user is None: | 20 | if current_user is None: |
---|
19 | return render_template('oauth_login.html') | | return render_template('oauth_login.html') |
---|
| | 21 | return render_template('oauth/login.html') | 20 | | 22 | |
---|
21 | if request.method == 'GET': | 23 | if request.method == 'GET': |
---|
22 | client_id = kwargs.get('client_id') | 24 | client_id = kwargs.get('client_id') |
---|
… | | … | |
---|
27 | kwargs['client'] = client | 27 | kwargs['client'] = client |
---|
28 | kwargs['user'] = current_user | 28 | kwargs['user'] = current_user |
---|
29 | current_app.logger.debug('kwargs %s', kwargs) | 29 | current_app.logger.debug('kwargs %s', kwargs) |
---|
30 | return render_template('authorize.html', **kwargs) | | return render_template('authorize.html', **kwargs) |
---|
31 | | 30 | |
---|
| | 31 | # See if this client is already authorized by user. If not then return |
---|
| | 32 | # a HTML to allow access. |
---|
| | 33 | authorized_clients = AuthorizedClients.getByUser(current_user) |
---|
| | 34 | if client in authorized_clients: |
---|
| | 35 | return render_template('oauth/authorized.html', **kwargs) |
---|
| | 36 | else: |
---|
| | 37 | return render_template('oauth/authorize.html', **kwargs) |
---|
| | 38 | |
---|
| | 39 | |
---|
32 | confirm = request.form.get('confirm', 'no') | 40 | confirm = request.form.get('confirm', 'no') |
---|
| | 41 | authorized = request.form.get('authorized', 'no') |
---|
33 | current_app.logger.debug('confirm authorize from user: %s', confirm) | 42 | current_app.logger.debug('confirm authorize from user: %s', confirm) |
---|
34 | return confirm == 'yes' | | return confirm == 'yes' |
---|
| | 43 | client = Client.query.get(request.form.get('client_id')) | | | 44 | |
---|
| | 45 | if authorized == 'yes': |
---|
| | 46 | return True |
---|
| | 47 | else: |
---|
| | 48 | if confirm == 'yes': |
---|
| | 49 | authorization = AuthorizedClients(user=current_user, client=client) |
---|
| | 50 | authorization.persist() |
---|
| | 51 | return True |
---|
| | 52 | else: |
---|
| | 53 | return False |
---|
| | 54 | |
---|
35 | | 55 | |
---|
36 | @Oauth.route('/token', methods=['GET', 'POST']) | 56 | @Oauth.route('/token', methods=['GET', 'POST']) |
---|
37 | @oauth.token_handler | 57 | @oauth.token_handler |
---|
| | | | 23 | sweet = Sweet.query.get(id) | 23 | sweet = Sweet.query.get(id) |
---|
24 | if sweet: | 24 | if sweet: |
---|
25 | print "sweet found " + str(sweet) | 25 | print "sweet found " + str(sweet) |
---|
26 | return render_template('specific_sweet.html', sweet=sweet) | | return render_template('specific_sweet.html', sweet=sweet) |
---|
| | 26 | return render_template('sweet/specific.html', sweet=sweet) | 27 | else: | 27 | else: |
---|
28 | abort(404) | 28 | abort(404) |
---|
| | | | 9 | | 9 | |
---|
10 | # swtstore imports | 10 | # swtstore imports |
---|
11 | from swtstore.classes.models.um import User | 11 | from swtstore.classes.models.um import User |
---|
12 | from swtstore.classes.models import Sweet, Context, Client | | from swtstore.classes.models import Sweet, Context, Client |
---|
| | 12 | from swtstore.classes.models import Sweet, Context, Client, AuthorizedClients | 13 | | 13 | |
---|
14 | from swtstore.classes.utils.httputils import makeCORSHeaders | 14 | from swtstore.classes.utils.httputils import makeCORSHeaders |
---|
15 | from swtstore.config import DefaultConfig | 15 | from swtstore.config import DefaultConfig |
---|
… | | … | |
---|
89 | return redirect(url_for('frontend.index')) | 89 | return redirect(url_for('frontend.index')) |
---|
90 | | 90 | |
---|
91 | if request.method == 'GET': | 91 | if request.method == 'GET': |
---|
92 | return render_template('me.html', user=current_user) | | return render_template('me.html', user=current_user) |
---|
| | 92 | return render_template('user/me.html', user=current_user) | 93 | | 93 | |
---|
| | 94 | # else POST request |
---|
94 | username = request.form.get('username') | 95 | username = request.form.get('username') |
---|
95 | | 96 | |
---|
96 | current_app.logger.debug('Updating username of %s to %s', | 97 | current_app.logger.debug('Updating username of %s to %s', |
---|
… | | … | |
---|
110 | return redirect(url_for('frontend.index')) | 110 | return redirect(url_for('frontend.index')) |
---|
111 | | 111 | |
---|
112 | swts = Sweet.getByCreator(user) | 112 | swts = Sweet.getByCreator(user) |
---|
113 | return render_template('my_sweets.html', sweets=swts) | | return render_template('my_sweets.html', sweets=swts) |
---|
| | 113 | return render_template('user/sweets.html', sweets=swts) | 114 | | 114 | |
---|
115 | | 115 | |
---|
116 | @user.route('/me/contexts', methods=['GET']) | 116 | @user.route('/me/contexts', methods=['GET']) |
---|
… | | … | |
---|
121 | return redirect(url_for('frontend.index')) | 121 | return redirect(url_for('frontend.index')) |
---|
122 | | 122 | |
---|
123 | contexts = Context.getByCreator(user.id) | 123 | contexts = Context.getByCreator(user.id) |
---|
124 | return render_template('my_contexts.html', contexts=contexts) | | return render_template('my_contexts.html', contexts=contexts) |
---|
| | 124 | return render_template('user/contexts.html', contexts=contexts) | 125 | | 125 | |
---|
126 | | 126 | |
---|
127 | @user.route('/me/apps', methods=['GET']) | 127 | @user.route('/me/apps', methods=['GET']) |
---|
… | | … | |
---|
133 | return redirect(url_for('frontend.index')) | 133 | return redirect(url_for('frontend.index')) |
---|
134 | | 134 | |
---|
135 | apps = Client.getClientsByCreator(user.id) | 135 | apps = Client.getClientsByCreator(user.id) |
---|
136 | return render_template('my_apps.html', apps=apps) | | return render_template('my_apps.html', apps=apps) |
---|
| | 136 | return render_template('user/apps.html', apps=apps) | | | 137 | |
---|
| | 138 | @user.route('/me/authorized_apps', methods=['GET', 'POST']) |
---|
| | 139 | def authorizedApps(): |
---|
| | 140 | |
---|
| | 141 | user = User.getCurrentUser() |
---|
| | 142 | if user is None: |
---|
| | 143 | return redirect(url_for('frontend.index')) |
---|
| | 144 | |
---|
| | 145 | if request.method == 'GET': |
---|
| | 146 | authorized_clients = AuthorizedClients.getByUser(user) |
---|
| | 147 | return render_template('user/authorized_apps.html', |
---|
| | 148 | authorized_clients=authorized_clients) |
---|
| | 149 | |
---|
| | 150 | # else POST request |
---|
| | 151 | client_id = request.form.get('revoke-id', '') |
---|
| | 152 | if client_id: |
---|
| | 153 | client = Client.query.get(client_id) |
---|
| | 154 | current_app.logger.info('user %s revoking access to %s', user, client) |
---|
| | 155 | AuthorizedClients.revoke(user=user, client=client) |
---|
| | 156 | |
---|
| | 157 | return redirect(url_for('authorizedApps')) |
---|
| | | | | | 1 | {% extends "layout.html" %} |
---|
| | 2 | {% block body %} |
---|
| | 3 | <div> |
---|
| | 4 | {% if apps|length > 0 %} |
---|
| | 5 | <ul> |
---|
| | 6 | {% for app in apps %} |
---|
| | 7 | <div class="well"> |
---|
| | 8 | <div class="pull-right"> |
---|
| | 9 | <span class="glyphicon glyphicon-trash"></span> |
---|
| | 10 | </div> |
---|
| | 11 | <div><h4> {{ app.name }} </h4></div> |
---|
| | 12 | <div><h5> {{ app.description }} </h5></div> |
---|
| | 13 | <div>APP ID: {{ app.id }} </div> |
---|
| | 14 | <div> APP Secret: {{ app.client_secret }} </div> |
---|
| | 15 | <div>Host URL: {{ app.host_url }} </div> |
---|
| | 16 | <div>Redirect URL: {{ app.redirect_uris|join(', ') }} </div> |
---|
| | 17 | <div>Scopes: {{ app.default_scopes|join(', ') }} </div> |
---|
| | 18 | </div> |
---|
| | 19 | {% endfor %} |
---|
| | 20 | </ul> |
---|
| | 21 | {% else %} |
---|
| | 22 | <em> You haven't registered any apps yet! </em> |
---|
| | 23 | {% endif %} |
---|
| | 24 | </div> |
---|
| | 25 | {% endblock %} |
---|
| | | | | | 1 | {% extends "layout.html" %} |
---|
| | 2 | {% block body %} |
---|
| | 3 | <h4> Register a new app with the <i>swt web</i> platform </h4> |
---|
| | 4 | <p class="text-muted"> Please fill in the details below and click Register button </p> |
---|
| | 5 | |
---|
| | 6 | <form role="form" method="POST" action="{{ url_for('app.register') }}"> |
---|
| | 7 | <div class="form-group"> |
---|
| | 8 | <label for="name">Name </label> |
---|
| | 9 | <input type="text" class="form-control" name="name" id="name" placeholder="Name of the application"> |
---|
| | 10 | </div> |
---|
| | 11 | <div class="form-group"> |
---|
| | 12 | <label for="desc">Description</label> |
---|
| | 13 | <p class="help-block"> Brief description of your application. (Optional)</p> |
---|
| | 14 | <textarea class="form-control" rows="4" id="desc" name="desc"> |
---|
| | 15 | </textarea> |
---|
| | 16 | </div> |
---|
| | 17 | <div class="form-group"> |
---|
| | 18 | <label for="host_url">Host URL</label> |
---|
| | 19 | <p class="help-block">URL where your app is deployed</p> |
---|
| | 20 | <input type="text" class="form-control" name="host_url" id="host_url" placeholder="host URL"> |
---|
| | 21 | </div> |
---|
| | 22 | <div class="form-group"> |
---|
| | 23 | <label for="redirect_uris">Redirect URLs</label> |
---|
| | 24 | <p class="help-block">Your app URL where it should be redirected once the user is authorized.</p> |
---|
| | 25 | <input type="text" class="form-control" name="redirect_uris" id="redirect_uris" placeholder="redirect URLs"> |
---|
| | 26 | </div> |
---|
| | 27 | <div class="form-group"> |
---|
| | 28 | <label for="scopes">Scopes</label> |
---|
| | 29 | <input type="text" class="form-control" name="scopes" id="scopes" value="email"> |
---|
| | 30 | </div> |
---|
| | 31 | <button type="submit" class="btn btn-primary">Register</button> |
---|
| | 32 | </form> |
---|
| | 33 | {% endblock %} |
---|
| | 34 | {% block scripts %} |
---|
| | 35 | <script> |
---|
| | 36 | // form validation |
---|
| | 37 | /*$('form').on('submit', function(event) { |
---|
| | 38 | console.log('here..'); |
---|
| | 39 | if(!$('#name').val()) { |
---|
| | 40 | event.preventDefault(); |
---|
| | 41 | $('#name').parent().addClass('has-feedback'); |
---|
| | 42 | $('#name').parent().addClass('has-error'); |
---|
| | 43 | return false; |
---|
| | 44 | } |
---|
| | 45 | if(!$('#host_url').val()) { |
---|
| | 46 | event.preventDefault(); |
---|
| | 47 | $('#host_url').parent().addClass('has-feedback'); |
---|
| | 48 | $('#name').parent().addClass('has-error'); |
---|
| | 49 | return false; |
---|
| | 50 | } |
---|
| | 51 | if(!$('#redirect_uris').val()) { |
---|
| | 52 | event.preventDefault(); |
---|
| | 53 | $('#redirect_uris').parent().addClass('has-feedback'); |
---|
| | 54 | $('#name').parent().addClass('has-error'); |
---|
| | 55 | return false; |
---|
| | 56 | } |
---|
| | 57 | if(!$('#scopes').val()) { |
---|
| | 58 | event.preventDefault(); |
---|
| | 59 | $('#scopes').parent().addClass('has-feedback'); |
---|
| | 60 | $('#name').parent().addClass('has-error'); |
---|
| | 61 | return false; |
---|
| | 62 | } |
---|
| | 63 | });*/ |
---|
| | 64 | </script> |
---|
| | 65 | {% endblock %} |
---|
| | | | 1 | {% extends "layout.html" %} | | {% extends "layout.html" %} |
---|
2 | {% block body %} | | {% block body %} |
---|
3 | <h4> Allow Access ?</h4> | | <h4> Allow Access ?</h4> |
---|
4 | <p class="text-muted"> | | <p class="text-muted"> |
---|
5 | The following application wants to get permission to do stuff(?) on the <i>swt | | The following application wants to get permission to do stuff(?) on the <i>swt |
---|
6 | web</i> platform on your behalf. | | web</i> platform on your behalf. |
---|
7 | </p> | | </p> |
---|
8 | | | |
---|
9 | <form role="form" method="POST" action="{{ url_for('oauth.authorize') }}"> | | <form role="form" method="POST" action="{{ url_for('oauth.authorize') }}"> |
---|
10 | <div class="form-group"> | | <div class="form-group"> |
---|
11 | <p class="form-control-static text-primary"> | | <p class="form-control-static text-primary"> |
---|
12 | {{ client.name }} at {{ client.host_url }} wants | | {{ client.name }} at {{ client.host_url }} wants |
---|
13 | to get permission to post data to swt store | | to get permission to post data to swt store |
---|
14 | </p> | | </p> |
---|
15 | </div> | | </div> |
---|
16 | <div class="form-group"> | | <div class="form-group"> |
---|
17 | <label class="control-label">Scopes</label> | | <label class="control-label">Scopes</label> |
---|
18 | <div class=""> | | <div class=""> |
---|
19 | <p class="form-control-static">{{ scopes|join(',') }}</p> | | <p class="form-control-static">{{ scopes|join(',') }}</p> |
---|
20 | </div> | | </div> |
---|
21 | </div> | | </div> |
---|
22 | <input type="hidden" name="client_id" value="{{ client.id }}"> | | <input type="hidden" name="client_id" value="{{ client.id }}"> |
---|
23 | <input type="hidden" name="scope" value="{{ scopes|join(' ') }}"> | | <input type="hidden" name="scope" value="{{ scopes|join(' ') }}"> |
---|
24 | <input type="hidden" name="response_type" value="{{ response_type }}"> | | <input type="hidden" name="response_type" value="{{ response_type }}"> |
---|
25 | {% if state %} | | {% if state %} |
---|
26 | <input type="hidden" name="state" value="{{ state }}"> | | <input type="hidden" name="state" value="{{ state }}"> |
---|
27 | {% endif %} | | {% endif %} |
---|
28 | <button type="submit" name="confirm" value="yes" class="btn btn-primary">Allow</button> | | <button type="submit" name="confirm" value="yes" class="btn btn-primary">Allow</button> |
---|
29 | <button type="submit" name="confirm" value="no" class="btn btn-default">Deny</button> | | <button type="submit" name="confirm" value="no" class="btn btn-default">Deny</button> |
---|
30 | </form> | | </form> |
---|
31 | | | |
---|
32 | {% endblock %} | | {% endblock %} |
---|
33 | | | |
---|
34 | {% block scripts %} | | {% block scripts %} |
---|
35 | | | |
---|
36 | <script> | | <script> |
---|
37 | var created = new Date("{{ user.created }}"); | | var created = new Date("{{ user.created }}"); |
---|
38 | window.onload = function() { | | window.onload = function() { |
---|
39 | $('#user-created').html(created.toString()); | | $('#user-created').html(created.toString()); |
---|
40 | }; | | }; |
---|
41 | </script> | | </script> |
---|
42 | | | |
---|
43 | {% endblock %} | | {% endblock %} |
---|
| | | | | | 1 | {% extends "layout.html" %} |
---|
| | 2 | {% block body %} |
---|
| | 3 | <div> |
---|
| | 4 | {% if contexts|length > 0 %} |
---|
| | 5 | <ul> |
---|
| | 6 | {% for context in contexts %} |
---|
| | 7 | <div class="well"> |
---|
| | 8 | <div class="pull-right"> |
---|
| | 9 | <span class="glyphicon glyphicon-trash"></span> |
---|
| | 10 | </div> |
---|
| | 11 | <div> {{ context.name }} </div> |
---|
| | 12 | <div> {{ context.definition }} </div> |
---|
| | 13 | </div> |
---|
| | 14 | {% endfor %} |
---|
| | 15 | </ul> |
---|
| | 16 | {% else %} |
---|
| | 17 | <em> You haven't registered any contexts yet! </em> |
---|
| | 18 | {% endif %} |
---|
| | 19 | </div> |
---|
| | 20 | {% endblock %} |
---|
| | | | | | 1 | {% extends "layout.html" %} |
---|
| | 2 | {% block body %} |
---|
| | 3 | <h4> Register a new context with the <i>swt web</i> platform </h4> |
---|
| | 4 | <p class="text-muted"> Please fill in the details below and click Register button </p> |
---|
| | 5 | |
---|
| | 6 | <form role="form" method="POST" action="{{ url_for('context.register') }}"> |
---|
| | 7 | <div class="form-group"> |
---|
| | 8 | <label for="name">Name </label> |
---|
| | 9 | <input type="text" class="form-control" name="name" id="name" placeholder="Name of the context"> |
---|
| | 10 | </div> |
---|
| | 11 | <div class="form-group"> |
---|
| | 12 | <label for="defn">Definition</label> |
---|
| | 13 | <p class="help-block"> JSON-LD definition. Insert a JSON-LD.</p> |
---|
| | 14 | <textarea class="form-control" rows="4" id="defn" name="defn"> |
---|
| | 15 | </textarea> |
---|
| | 16 | </div> |
---|
| | 17 | <button type="submit" class="btn btn-primary">Register</button> |
---|
| | 18 | </form> |
---|
| | 19 | {% endblock %} |
---|
| | | | | | 1 | {% extends "layout.html" %} |
---|
| | 2 | |
---|
| | 3 | {% block body %} |
---|
| | 4 | <div id="store-stats"> |
---|
| | 5 | </div> |
---|
| | 6 | |
---|
| | 7 | {% if sweets|length > 0 %} |
---|
| | 8 | |
---|
| | 9 | <ul class="entries unstyled"> |
---|
| | 10 | {% for sweet in sweets %} |
---|
| | 11 | <li> |
---|
| | 12 | <span class="who"> |
---|
| | 13 | <a href="#"> |
---|
| | 14 | @{{ sweet.who.username }} |
---|
| | 15 | </a> |
---|
| | 16 | </span> |
---|
| | 17 | <span class="what"> |
---|
| | 18 | <b> #{{ sweet.what.name }} </b> |
---|
| | 19 | </span> |
---|
| | 20 | <span class="where"> |
---|
| | 21 | {{ sweet.where }} |
---|
| | 22 | </span> |
---|
| | 23 | <p></p> |
---|
| | 24 | <span class="how"> |
---|
| | 25 | {{ sweet.how|escape|safe }} |
---|
| | 26 | </span> |
---|
| | 27 | |
---|
| | 28 | <small><i>created: {{sweet.created }}</i></small> |
---|
| | 29 | |
---|
| | 30 | <span class="pull-right permalink"> |
---|
| | 31 | <a href="{{ url_for('sweet.showSweet', id=sweet.id) }}"> |
---|
| | 32 | <i class="glyphicon glyphicon-share"></i> |
---|
| | 33 | </a> |
---|
| | 34 | </li> |
---|
| | 35 | {% endfor %} |
---|
| | 36 | </ul> |
---|
| | 37 | |
---|
| | 38 | {% else %} |
---|
| | 39 | <div class="row"> |
---|
| | 40 | <div class="col-md-5"> |
---|
| | 41 | <h4><em>Unbelievable! No sweets yet!!</em></h4> |
---|
| | 42 | </div> |
---|
| | 43 | </div> |
---|
| | 44 | {% endif %} |
---|
| | 45 | |
---|
| | 46 | {% endblock %} |
---|
| | | | 1 | {% extends "layout.html" %} | | {% extends "layout.html" %} |
---|
2 | | | |
---|
3 | {% block body %} | | {% block body %} |
---|
4 | <div id="store-stats"> | | <div id="store-stats"> |
---|
5 | </div> | | </div> |
---|
6 | | | |
---|
7 | {% if sweets|length > 0 %} | | {% if sweets|length > 0 %} |
---|
8 | | | |
---|
9 | <ul class="entries unstyled"> | | <ul class="entries unstyled"> |
---|
10 | {% for sweet in sweets %} | | {% for sweet in sweets %} |
---|
11 | <li> | | <li> |
---|
12 | <span class="who"> | | <span class="who"> |
---|
13 | <a href="#"> | | <a href="#"> |
---|
14 | @{{ sweet.who.username }} | | @{{ sweet.who.username }} |
---|
15 | </a> | | </a> |
---|
16 | </span> | | </span> |
---|
17 | <span class="what"> | | <span class="what"> |
---|
18 | <b> #{{ sweet.what.name }} </b> | | <b> #{{ sweet.what.name }} </b> |
---|
19 | </span> | | </span> |
---|
20 | <span class="where"> | | <span class="where"> |
---|
21 | {{ sweet.where }} | | {{ sweet.where }} |
---|
22 | </span> | | </span> |
---|
23 | <p></p> | | <p></p> |
---|
24 | <span class="how"> | | <span class="how"> |
---|
25 | {{ sweet.how|escape|safe }} | | {{ sweet.how|escape|safe }} |
---|
26 | </span> | | </span> |
---|
27 | | | |
---|
28 | <small><i>created: {{sweet.created }}</i></small> | | <small><i>created: {{sweet.created }}</i></small> |
---|
29 | | | |
---|
30 | <span class="pull-right permalink"> | | <span class="pull-right permalink"> |
---|
31 | <a href="{{ url_for('sweet.showSweet', id=sweet.id) }}"> | | <a href="{{ url_for('sweet.showSweet', id=sweet.id) }}"> |
---|
32 | <i class="glyphicon glyphicon-share"></i> | | <i class="glyphicon glyphicon-share"></i> |
---|
33 | </a> | | </a> |
---|
34 | </li> | | </li> |
---|
35 | {% endfor %} | | {% endfor %} |
---|
36 | </ul> | | </ul> |
---|
37 | | | |
---|
38 | {% else %} | | {% else %} |
---|
39 | <div class="row"> | | <div class="row"> |
---|
40 | <div class="col-md-5"> | | <div class="col-md-5"> |
---|
41 | <h4><em>Unbelievable! No sweets yet!!</em></h4> | | <h4><em>Unbelievable! No sweets yet!!</em></h4> |
---|
42 | </div> | | </div> |
---|
43 | </div> | | </div> |
---|
44 | {% endif %} | | {% endif %} |
---|
45 | | | |
---|
46 | {% endblock %} | | {% endblock %} |
---|
| | | | 51 | {{ session.email }} | 51 | {{ session.email }} |
---|
52 | </small></a> | 52 | </small></a> |
---|
53 | </li> | 53 | </li> |
---|
| | 54 | <li> |
---|
| | 55 | <a href="{{ url_for('user.authorizedApps') }}"> |
---|
| | 56 | My authorized apps |
---|
| | 57 | </a> |
---|
| | 58 | </li> |
---|
54 | <li class="divider"></li> | 59 | <li class="divider"></li> |
---|
55 | <li> <a href="#" id="logout"> Logout </a> </li> | 60 | <li> <a href="#" id="logout"> Logout </a> </li> |
---|
56 | </ul> | 61 | </ul> |
---|
| | | | 1 | {% extends "layout.html" %} | | {% extends "layout.html" %} |
---|
2 | {% block body %} | | {% block body %} |
---|
3 | <div> | | <div> |
---|
4 | {% if apps|length > 0 %} | | {% if apps|length > 0 %} |
---|
5 | <ul> | | <ul> |
---|
6 | {% for app in apps %} | | {% for app in apps %} |
---|
7 | <div class="well"> | | <div class="well"> |
---|
8 | <div class="pull-right"> | | <div class="pull-right"> |
---|
9 | <span class="glyphicon glyphicon-trash"></span> | | <span class="glyphicon glyphicon-trash"></span> |
---|
10 | </div> | | </div> |
---|
11 | <div><h4> {{ app.name }} </h4></div> | | <div><h4> {{ app.name }} </h4></div> |
---|
12 | <div><h5> {{ app.description }} </h5></div> | | <div><h5> {{ app.description }} </h5></div> |
---|
13 | <div>APP ID: {{ app.id }} </div> | | <div>APP ID: {{ app.id }} </div> |
---|
14 | <div> APP Secret: {{ app.client_secret }} </div> | | <div> APP Secret: {{ app.client_secret }} </div> |
---|
15 | <div>Host URL: {{ app.host_url }} </div> | | <div>Host URL: {{ app.host_url }} </div> |
---|
16 | <div>Redirect URL: {{ app.redirect_uris|join(', ') }} </div> | | <div>Redirect URL: {{ app.redirect_uris|join(', ') }} </div> |
---|
17 | <div>Scopes: {{ app.default_scopes|join(', ') }} </div> | | <div>Scopes: {{ app.default_scopes|join(', ') }} </div> |
---|
18 | </div> | | </div> |
---|
19 | {% endfor %} | | {% endfor %} |
---|
20 | </ul> | | </ul> |
---|
21 | {% else %} | | {% else %} |
---|
22 | <em> You haven't registered any apps yet! </em> | | <em> You haven't registered any apps yet! </em> |
---|
23 | {% endif %} | | {% endif %} |
---|
24 | </div> | | </div> |
---|
25 | {% endblock %} | | {% endblock %} |
---|
| | | | 1 | {% extends "layout.html" %} | | {% extends "layout.html" %} |
---|
2 | {% block body %} | | {% block body %} |
---|
3 | <div> | | <div> |
---|
4 | {% if contexts|length > 0 %} | | {% if contexts|length > 0 %} |
---|
5 | <ul> | | <ul> |
---|
6 | {% for context in contexts %} | | {% for context in contexts %} |
---|
7 | <div class="well"> | | <div class="well"> |
---|
8 | <div class="pull-right"> | | <div class="pull-right"> |
---|
9 | <span class="glyphicon glyphicon-trash"></span> | | <span class="glyphicon glyphicon-trash"></span> |
---|
10 | </div> | | </div> |
---|
11 | <div> {{ context.name }} </div> | | <div> {{ context.name }} </div> |
---|
12 | <div> {{ context.definition }} </div> | | <div> {{ context.definition }} </div> |
---|
13 | </div> | | </div> |
---|
14 | {% endfor %} | | {% endfor %} |
---|
15 | </ul> | | </ul> |
---|
16 | {% else %} | | {% else %} |
---|
17 | <em> You haven't registered any contexts yet! </em> | | <em> You haven't registered any contexts yet! </em> |
---|
18 | {% endif %} | | {% endif %} |
---|
19 | </div> | | </div> |
---|
20 | {% endblock %} | | {% endblock %} |
---|
| | | | 1 | | | |
---|
2 | {% extends "layout.html" %} | | {% extends "layout.html" %} |
---|
3 | {% block body %} | | {% block body %} |
---|
4 | | | |
---|
5 | <h4> Update your profile details </h4> | | <h4> Update your profile details </h4> |
---|
6 | | | |
---|
7 | <p class="text-muted"> Please fill in the details below and click update button </p> | | <p class="text-muted"> Please fill in the details below and click update button </p> |
---|
8 | | | |
---|
9 | <form role="form" method="POST" action="{{ url_for('user.profile') }}"> | | <form role="form" method="POST" action="{{ url_for('user.profile') }}"> |
---|
10 | <div class="form-group"> | | <div class="form-group"> |
---|
11 | <label for="username">Username</label> | | <label for="username">Username</label> |
---|
12 | <input type="text" class="form-control" name="username" id="username" | | <input type="text" class="form-control" name="username" id="username" |
---|
13 | placeholder="Username you are going to use" value="{{ user.username}}"> | | placeholder="Username you are going to use" value="{{ user.username}}"> |
---|
14 | </div> | | </div> |
---|
15 | <div class="form-group"> | | <div class="form-group"> |
---|
16 | <label class="control-label">Email</label> | | <label class="control-label">Email</label> |
---|
17 | <div class=""> | | <div class=""> |
---|
18 | <p class="form-control-static">{{ user.email }}</p> | | <p class="form-control-static">{{ user.email }}</p> |
---|
19 | </div> | | </div> |
---|
20 | </div> | | </div> |
---|
21 | <div class="form-group"> | | <div class="form-group"> |
---|
22 | <label class="control-label">Account created </label> | | <label class="control-label">Account created </label> |
---|
23 | <div class=""> | | <div class=""> |
---|
24 | <p class="form-control-static" id="user-created"> | | <p class="form-control-static" id="user-created"> |
---|
25 | {{ user.created }} | | {{ user.created }} |
---|
26 | </p> | | </p> |
---|
27 | </div> | | </div> |
---|
28 | </div> | | </div> |
---|
29 | <button type="submit" class="btn btn-primary">Update</button> | | <button type="submit" class="btn btn-primary">Update</button> |
---|
30 | </form> | | </form> |
---|
31 | | | |
---|
32 | {% endblock %} | | {% endblock %} |
---|
33 | | | |
---|
34 | {% block scripts %} | | {% block scripts %} |
---|
35 | | | |
---|
36 | <script> | | <script> |
---|
37 | var created = new Date("{{ user.created }}"); | | var created = new Date("{{ user.created }}"); |
---|
38 | window.onload = function() { | | window.onload = function() { |
---|
39 | $('#user-created').html(created.toString()); | | $('#user-created').html(created.toString()); |
---|
40 | }; | | }; |
---|
41 | </script> | | </script> |
---|
42 | | | |
---|
43 | {% endblock %} | | {% endblock %} |
---|
| | | | 1 | {% extends "layout.html" %} | | {% extends "layout.html" %} |
---|
2 | {% block body %} | | {% block body %} |
---|
3 | <div> | | <div> |
---|
4 | {% if apps|length > 0 %} | | {% if apps|length > 0 %} |
---|
5 | <ul> | | <ul> |
---|
6 | {% for app in apps %} | | {% for app in apps %} |
---|
7 | <div class="well"> | | <div class="well"> |
---|
8 | <div class="pull-right"> | | <div class="pull-right"> |
---|
9 | <span class="glyphicon glyphicon-trash"></span> | | <span class="glyphicon glyphicon-trash"></span> |
---|
10 | </div> | | </div> |
---|
11 | <div><h4> {{ app.name }} </h4></div> | | <div><h4> {{ app.name }} </h4></div> |
---|
12 | <div><h5> {{ app.description }} </h5></div> | | <div><h5> {{ app.description }} </h5></div> |
---|
13 | <div>APP ID: {{ app.id }} </div> | | <div>APP ID: {{ app.id }} </div> |
---|
14 | <div> APP Secret: {{ app.client_secret }} </div> | | <div> APP Secret: {{ app.client_secret }} </div> |
---|
15 | <div>Host URL: {{ app.host_url }} </div> | | <div>Host URL: {{ app.host_url }} </div> |
---|
16 | <div>Redirect URL: {{ app.redirect_uris|join(', ') }} </div> | | <div>Redirect URL: {{ app.redirect_uris|join(', ') }} </div> |
---|
17 | <div>Scopes: {{ app.default_scopes|join(', ') }} </div> | | <div>Scopes: {{ app.default_scopes|join(', ') }} </div> |
---|
18 | </div> | | </div> |
---|
19 | {% endfor %} | | {% endfor %} |
---|
20 | </ul> | | </ul> |
---|
21 | {% else %} | | {% else %} |
---|
22 | <em> You haven't registered any apps yet! </em> | | <em> You haven't registered any apps yet! </em> |
---|
23 | {% endif %} | | {% endif %} |
---|
24 | </div> | | </div> |
---|
25 | {% endblock %} | | {% endblock %} |
---|
| | | | 1 | {% extends "layout.html" %} | | {% extends "layout.html" %} |
---|
2 | {% block body %} | | {% block body %} |
---|
3 | <div> | | <div> |
---|
4 | {% if contexts|length > 0 %} | | {% if contexts|length > 0 %} |
---|
5 | <ul> | | <ul> |
---|
6 | {% for context in contexts %} | | {% for context in contexts %} |
---|
7 | <div class="well"> | | <div class="well"> |
---|
8 | <div class="pull-right"> | | <div class="pull-right"> |
---|
9 | <span class="glyphicon glyphicon-trash"></span> | | <span class="glyphicon glyphicon-trash"></span> |
---|
10 | </div> | | </div> |
---|
11 | <div> {{ context.name }} </div> | | <div> {{ context.name }} </div> |
---|
12 | <div> {{ context.definition }} </div> | | <div> {{ context.definition }} </div> |
---|
13 | </div> | | </div> |
---|
14 | {% endfor %} | | {% endfor %} |
---|
15 | </ul> | | </ul> |
---|
16 | {% else %} | | {% else %} |
---|
17 | <em> You haven't registered any contexts yet! </em> | | <em> You haven't registered any contexts yet! </em> |
---|
18 | {% endif %} | | {% endif %} |
---|
19 | </div> | | </div> |
---|
20 | {% endblock %} | | {% endblock %} |
---|
| | | | 1 | {% extends "layout.html" %} | | {% extends "layout.html" %} |
---|
2 | | | |
---|
3 | {% block body %} | | {% block body %} |
---|
4 | | | |
---|
5 | {% if sweets|length > 0 %} | | {% if sweets|length > 0 %} |
---|
6 | | | |
---|
7 | <ul class="entries unstyled"> | | <ul class="entries unstyled"> |
---|
8 | {% for sweet in sweets %} | | {% for sweet in sweets %} |
---|
9 | <li> | | <li> |
---|
10 | <span class="who"> | | <span class="who"> |
---|
11 | <a href="#"> | | <a href="#"> |
---|
12 | @{{ sweet.who.username }} | | @{{ sweet.who.username }} |
---|
13 | </a> | | </a> |
---|
14 | </span> | | </span> |
---|
15 | <span class="what"> | | <span class="what"> |
---|
16 | <b> #{{ sweet.what.name }} </b> | | <b> #{{ sweet.what.name }} </b> |
---|
17 | </span> | | </span> |
---|
18 | <span class="where"> | | <span class="where"> |
---|
19 | {{ sweet.where }} | | {{ sweet.where }} |
---|
20 | </span> | | </span> |
---|
21 | <p></p> | | <p></p> |
---|
22 | <span class="how"> | | <span class="how"> |
---|
23 | {{ sweet.how|tojson }} | | {{ sweet.how|tojson }} |
---|
24 | </span> | | </span> |
---|
25 | | | |
---|
26 | <small><i>created: {{sweet.created }}</i></small> | | <small><i>created: {{sweet.created }}</i></small> |
---|
27 | | | |
---|
28 | <span class="pull-right permalink"> | | <span class="pull-right permalink"> |
---|
29 | <a href="#"> | | <a href="#"> |
---|
30 | <i class="glyphicon glyphicon-share"></i> | | <i class="glyphicon glyphicon-share"></i> |
---|
31 | </a> | | </a> |
---|
32 | </span> | | </span> |
---|
33 | <span class="pull-right edit-sweet" for="{{ sweet.id }}"> | | <span class="pull-right edit-sweet" for="{{ sweet.id }}"> |
---|
34 | <a href="#"> | | <a href="#"> |
---|
35 | <i class="glyphicon glyphicon-edit"></i> | | <i class="glyphicon glyphicon-edit"></i> |
---|
36 | </a> | | </a> |
---|
37 | </span> | | </span> |
---|
38 | </li> | | </li> |
---|
39 | {% endfor %} | | {% endfor %} |
---|
40 | </ul> | | </ul> |
---|
41 | | | |
---|
42 | {% else %} | | {% else %} |
---|
43 | <div class="row"> | | <div class="row"> |
---|
44 | <div class="col-md-5"> | | <div class="col-md-5"> |
---|
45 | <h4><em>Unbelievable! No sweets yet!!</em></h4> | | <h4><em>Unbelievable! No sweets yet!!</em></h4> |
---|
46 | </div> | | </div> |
---|
47 | </div> | | </div> |
---|
48 | {% endif %} | | {% endif %} |
---|
49 | | | |
---|
50 | <div class="modal fade" id="edit-sweet-modal"> | | <div class="modal fade" id="edit-sweet-modal"> |
---|
51 | <div class="modal-dialog"> | | <div class="modal-dialog"> |
---|
52 | <div class="modal-content"> | | <div class="modal-content"> |
---|
53 | <div class="modal-header"> | | <div class="modal-header"> |
---|
54 | <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | | <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> |
---|
55 | <h4 class="modal-title">Edit Sweet </h4> | | <h4 class="modal-title">Edit Sweet </h4> |
---|
56 | </div> | | </div> |
---|
57 | <div class="modal-body"></div> | | <div class="modal-body"></div> |
---|
58 | <div | | <div |
---|
59 | class="modal-footer"> | | class="modal-footer"> |
---|
60 | <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | | <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> |
---|
61 | <button type="button" class="btn btn-primary" id="save-edited-sweet">Save changes</button> | | <button type="button" class="btn btn-primary" id="save-edited-sweet">Save changes</button> |
---|
62 | </div> | | </div> |
---|
63 | </div><!-- /.modal-content --> | | </div><!-- /.modal-content --> |
---|
64 | </div><!-- /.modal-dialog --> | | </div><!-- /.modal-dialog --> |
---|
65 | </div><!-- /.modal --> | | </div><!-- /.modal --> |
---|
66 | | | |
---|
67 | {% endblock %} | | {% endblock %} |
---|
| | | | 1 | {% extends "layout.html" %} | | {% extends "layout.html" %} |
---|
2 | {% block body %} | | {% block body %} |
---|
3 | <h4> Register a new app with the <i>swt web</i> platform </h4> | | <h4> Register a new app with the <i>swt web</i> platform </h4> |
---|
4 | <p class="text-muted"> Please fill in the details below and click Register button </p> | | <p class="text-muted"> Please fill in the details below and click Register button </p> |
---|
5 | | | |
---|
6 | <form role="form" method="POST" action="{{ url_for('app.register') }}"> | | <form role="form" method="POST" action="{{ url_for('app.register') }}"> |
---|
7 | <div class="form-group"> | | <div class="form-group"> |
---|
8 | <label for="name">Name </label> | | <label for="name">Name </label> |
---|
9 | <input type="text" class="form-control" name="name" id="name" placeholder="Name of the application"> | | <input type="text" class="form-control" name="name" id="name" placeholder="Name of the application"> |
---|
10 | </div> | | </div> |
---|
11 | <div class="form-group"> | | <div class="form-group"> |
---|
12 | <label for="desc">Description</label> | | <label for="desc">Description</label> |
---|
13 | <p class="help-block"> Brief description of your application. (Optional)</p> | | <p class="help-block"> Brief description of your application. (Optional)</p> |
---|
14 | <textarea class="form-control" rows="4" id="desc" name="desc"> | | <textarea class="form-control" rows="4" id="desc" name="desc"> |
---|
15 | </textarea> | | </textarea> |
---|
16 | </div> | | </div> |
---|
17 | <div class="form-group"> | | <div class="form-group"> |
---|
18 | <label for="host_url">Host URL</label> | | <label for="host_url">Host URL</label> |
---|
19 | <p class="help-block">URL where your app is deployed</p> | | <p class="help-block">URL where your app is deployed</p> |
---|
20 | <input type="text" class="form-control" name="host_url" id="host_url" placeholder="host URL"> | | <input type="text" class="form-control" name="host_url" id="host_url" placeholder="host URL"> |
---|
21 | </div> | | </div> |
---|
22 | <div class="form-group"> | | <div class="form-group"> |
---|
23 | <label for="redirect_uris">Redirect URLs</label> | | <label for="redirect_uris">Redirect URLs</label> |
---|
24 | <p class="help-block">Your app URL where it should be redirected once the user is authorized.</p> | | <p class="help-block">Your app URL where it should be redirected once the user is authorized.</p> |
---|
25 | <input type="text" class="form-control" name="redirect_uris" id="redirect_uris" placeholder="redirect URLs"> | | <input type="text" class="form-control" name="redirect_uris" id="redirect_uris" placeholder="redirect URLs"> |
---|
26 | </div> | | </div> |
---|
27 | <div class="form-group"> | | <div class="form-group"> |
---|
28 | <label for="scopes">Scopes</label> | | <label for="scopes">Scopes</label> |
---|
29 | <input type="text" class="form-control" name="scopes" id="scopes" value="email"> | | <input type="text" class="form-control" name="scopes" id="scopes" value="email"> |
---|
30 | </div> | | </div> |
---|
31 | <button type="submit" class="btn btn-primary">Register</button> | | <button type="submit" class="btn btn-primary">Register</button> |
---|
32 | </form> | | </form> |
---|
33 | {% endblock %} | | {% endblock %} |
---|
34 | {% block scripts %} | | {% block scripts %} |
---|
35 | <script> | | <script> |
---|
36 | // form validation | | // form validation |
---|
37 | /*$('form').on('submit', function(event) { | | /*$('form').on('submit', function(event) { |
---|
38 | console.log('here..'); | | console.log('here..'); |
---|
39 | if(!$('#name').val()) { | | if(!$('#name').val()) { |
---|
40 | event.preventDefault(); | | event.preventDefault(); |
---|
41 | $('#name').parent().addClass('has-feedback'); | | $('#name').parent().addClass('has-feedback'); |
---|
42 | $('#name').parent().addClass('has-error'); | | $('#name').parent().addClass('has-error'); |
---|
43 | return false; | | return false; |
---|
44 | } | | } |
---|
45 | if(!$('#host_url').val()) { | | if(!$('#host_url').val()) { |
---|
46 | event.preventDefault(); | | event.preventDefault(); |
---|
47 | $('#host_url').parent().addClass('has-feedback'); | | $('#host_url').parent().addClass('has-feedback'); |
---|
48 | $('#name').parent().addClass('has-error'); | | $('#name').parent().addClass('has-error'); |
---|
49 | return false; | | return false; |
---|
50 | } | | } |
---|
51 | if(!$('#redirect_uris').val()) { | | if(!$('#redirect_uris').val()) { |
---|
52 | event.preventDefault(); | | event.preventDefault(); |
---|
53 | $('#redirect_uris').parent().addClass('has-feedback'); | | $('#redirect_uris').parent().addClass('has-feedback'); |
---|
54 | $('#name').parent().addClass('has-error'); | | $('#name').parent().addClass('has-error'); |
---|
55 | return false; | | return false; |
---|
56 | } | | } |
---|
57 | if(!$('#scopes').val()) { | | if(!$('#scopes').val()) { |
---|
58 | event.preventDefault(); | | event.preventDefault(); |
---|
59 | $('#scopes').parent().addClass('has-feedback'); | | $('#scopes').parent().addClass('has-feedback'); |
---|
60 | $('#name').parent().addClass('has-error'); | | $('#name').parent().addClass('has-error'); |
---|
61 | return false; | | return false; |
---|
62 | } | | } |
---|
63 | });*/ | | });*/ |
---|
64 | </script> | | </script> |
---|
65 | {% endblock %} | | {% endblock %} |
---|
| | | | 1 | {% extends "layout.html" %} | | {% extends "layout.html" %} |
---|
2 | {% block body %} | | {% block body %} |
---|
3 | <h4> Register a new context with the <i>swt web</i> platform </h4> | | <h4> Register a new context with the <i>swt web</i> platform </h4> |
---|
4 | <p class="text-muted"> Please fill in the details below and click Register button </p> | | <p class="text-muted"> Please fill in the details below and click Register button </p> |
---|
5 | | | |
---|
6 | <form role="form" method="POST" action="{{ url_for('context.register') }}"> | | <form role="form" method="POST" action="{{ url_for('context.register') }}"> |
---|
7 | <div class="form-group"> | | <div class="form-group"> |
---|
8 | <label for="name">Name </label> | | <label for="name">Name </label> |
---|
9 | <input type="text" class="form-control" name="name" id="name" placeholder="Name of the context"> | | <input type="text" class="form-control" name="name" id="name" placeholder="Name of the context"> |
---|
10 | </div> | | </div> |
---|
11 | <div class="form-group"> | | <div class="form-group"> |
---|
12 | <label for="defn">Definition</label> | | <label for="defn">Definition</label> |
---|
13 | <p class="help-block"> JSON-LD definition. Insert a JSON-LD.</p> | | <p class="help-block"> JSON-LD definition. Insert a JSON-LD.</p> |
---|
14 | <textarea class="form-control" rows="4" id="defn" name="defn"> | | <textarea class="form-control" rows="4" id="defn" name="defn"> |
---|
15 | </textarea> | | </textarea> |
---|
16 | </div> | | </div> |
---|
17 | <button type="submit" class="btn btn-primary">Register</button> | | <button type="submit" class="btn btn-primary">Register</button> |
---|
18 | </form> | | </form> |
---|
19 | {% endblock %} | | {% endblock %} |
---|
| | | | 1 | {% extends "layout.html" %} | | {% extends "layout.html" %} |
---|
2 | | | |
---|
3 | {% block body %} | | {% block body %} |
---|
4 | | | |
---|
5 | <ul class="entries unstyled"> | | <ul class="entries unstyled"> |
---|
6 | <li> | | <li> |
---|
7 | <span class="who"> | | <span class="who"> |
---|
8 | <a href="#"> | | <a href="#"> |
---|
9 | @{{ sweet.who.username }} | | @{{ sweet.who.username }} |
---|
10 | </a> | | </a> |
---|
11 | </span> | | </span> |
---|
12 | <span class="what"> | | <span class="what"> |
---|
13 | <b> #{{ sweet.what.name }} </b> | | <b> #{{ sweet.what.name }} </b> |
---|
14 | </span> | | </span> |
---|
15 | <span class="where"> | | <span class="where"> |
---|
16 | {{ sweet.where }} | | {{ sweet.where }} |
---|
17 | </span> | | </span> |
---|
18 | <p></p> | | <p></p> |
---|
19 | <span class="how"> | | <span class="how"> |
---|
20 | {{ sweet.how|escape|safe }} | | {{ sweet.how|escape|safe }} |
---|
21 | </span> | | </span> |
---|
22 | | | |
---|
23 | <small><i>created: {{sweet.created }}</i></small> | | <small><i>created: {{sweet.created }}</i></small> |
---|
24 | </li> | | </li> |
---|
25 | </ul> | | </ul> |
---|
26 | | | |
---|
27 | {% endblock %} | | {% endblock %} |
---|
| | | | | | 1 | {% extends "layout.html" %} |
---|
| | 2 | |
---|
| | 3 | {% block body %} |
---|
| | 4 | |
---|
| | 5 | <ul class="entries unstyled"> |
---|
| | 6 | <li> |
---|
| | 7 | <span class="who"> |
---|
| | 8 | <a href="#"> |
---|
| | 9 | @{{ sweet.who.username }} |
---|
| | 10 | </a> |
---|
| | 11 | </span> |
---|
| | 12 | <span class="what"> |
---|
| | 13 | <b> #{{ sweet.what.name }} </b> |
---|
| | 14 | </span> |
---|
| | 15 | <span class="where"> |
---|
| | 16 | {{ sweet.where }} |
---|
| | 17 | </span> |
---|
| | 18 | <p></p> |
---|
| | 19 | <span class="how"> |
---|
| | 20 | {{ sweet.how|escape|safe }} |
---|
| | 21 | </span> |
---|
| | 22 | |
---|
| | 23 | <small><i>created: {{sweet.created }}</i></small> |
---|
| | 24 | </li> |
---|
| | 25 | </ul> |
---|
| | 26 | |
---|
| | 27 | {% endblock %} |
---|
| | | | | | 1 | {% extends "layout.html" %} |
---|
| | 2 | {% block body %} |
---|
| | 3 | <div> |
---|
| | 4 | {% if apps|length > 0 %} |
---|
| | 5 | <ul> |
---|
| | 6 | {% for app in apps %} |
---|
| | 7 | <div class="well"> |
---|
| | 8 | <div class="pull-right"> |
---|
| | 9 | <span class="glyphicon glyphicon-trash"></span> |
---|
| | 10 | </div> |
---|
| | 11 | <div><h4> {{ app.name }} </h4></div> |
---|
| | 12 | <div><h5> {{ app.description }} </h5></div> |
---|
| | 13 | <div>APP ID: {{ app.id }} </div> |
---|
| | 14 | <div> APP Secret: {{ app.client_secret }} </div> |
---|
| | 15 | <div>Host URL: {{ app.host_url }} </div> |
---|
| | 16 | <div>Redirect URL: {{ app.redirect_uris|join(', ') }} </div> |
---|
| | 17 | <div>Scopes: {{ app.default_scopes|join(', ') }} </div> |
---|
| | 18 | </div> |
---|
| | 19 | {% endfor %} |
---|
| | 20 | </ul> |
---|
| | 21 | {% else %} |
---|
| | 22 | <em> You haven't registered any apps yet! </em> |
---|
| | 23 | {% endif %} |
---|
| | 24 | </div> |
---|
| | 25 | {% endblock %} |
---|
| | | | | | 1 | {% extends "layout.html" %} |
---|
| | 2 | {% block body %} |
---|
| | 3 | |
---|
| | 4 | {% if authorized_clients | length > 0 %} |
---|
| | 5 | <h4> Your authorized apps </h4> |
---|
| | 6 | |
---|
| | 7 | <p class="text-muted"> |
---|
| | 8 | You have given access to these apps to post sweets |
---|
| | 9 | to the swtstore on your behalf. You can revoke access to specific apps. |
---|
| | 10 | </p> |
---|
| | 11 | |
---|
| | 12 | <form role="form" method="POST" action="{{ url_for('user.authorizedApps') }}"> |
---|
| | 13 | <div class="form-group"> |
---|
| | 14 | <ul> |
---|
| | 15 | {% for client in authorized_clients %} |
---|
| | 16 | <li class="authorized_apps"> |
---|
| | 17 | <p class="form-control-static"> |
---|
| | 18 | <b>{{ client.name }}</b>: {{ client.description }} |
---|
| | 19 | <button type="submit" name="revoke-id" value="{{ client.client_id }}" |
---|
| | 20 | class="btn btn-sm btn-primary pull-right">Revoke Access</button> |
---|
| | 21 | </p> |
---|
| | 22 | </li> |
---|
| | 23 | {% endfor %} |
---|
| | 24 | </ul> |
---|
| | 25 | </div> |
---|
| | 26 | </form> |
---|
| | 27 | {% else %} |
---|
| | 28 | <i> You have not authorized any apps to access swtstore yet.</i> |
---|
| | 29 | {% endif %} |
---|
| | 30 | |
---|
| | 31 | {% endblock %} |
---|
| | 32 | |
---|
| | 33 | {% block scripts %} |
---|
| | 34 | |
---|
| | 35 | <script> |
---|
| | 36 | </script> |
---|
| | 37 | |
---|
| | 38 | {% endblock %} |
---|
| | | | | | 1 | {% extends "layout.html" %} |
---|
| | 2 | {% block body %} |
---|
| | 3 | <div> |
---|
| | 4 | {% if contexts|length > 0 %} |
---|
| | 5 | <ul> |
---|
| | 6 | {% for context in contexts %} |
---|
| | 7 | <div class="well"> |
---|
| | 8 | <div class="pull-right"> |
---|
| | 9 | <span class="glyphicon glyphicon-trash"></span> |
---|
| | 10 | </div> |
---|
| | 11 | <div> {{ context.name }} </div> |
---|
| | 12 | <div> {{ context.definition }} </div> |
---|
| | 13 | </div> |
---|
| | 14 | {% endfor %} |
---|
| | 15 | </ul> |
---|
| | 16 | {% else %} |
---|
| | 17 | <em> You haven't registered any contexts yet! </em> |
---|
| | 18 | {% endif %} |
---|
| | 19 | </div> |
---|
| | 20 | {% endblock %} |
---|
| | | | | | 1 | |
---|
| | 2 | {% extends "layout.html" %} |
---|
| | 3 | {% block body %} |
---|
| | 4 | |
---|
| | 5 | <h4> Update your profile details </h4> |
---|
| | 6 | |
---|
| | 7 | <p class="text-muted"> Please fill in the details below and click update button </p> |
---|
| | 8 | |
---|
| | 9 | <form role="form" method="POST" action="{{ url_for('user.profile') }}"> |
---|
| | 10 | <div class="form-group"> |
---|
| | 11 | <label for="username">Username</label> |
---|
| | 12 | <input type="text" class="form-control" name="username" id="username" |
---|
| | 13 | placeholder="Username you are going to use" value="{{ user.username}}"> |
---|
| | 14 | </div> |
---|
| | 15 | <div class="form-group"> |
---|
| | 16 | <label class="control-label">Email</label> |
---|
| | 17 | <div class=""> |
---|
| | 18 | <p class="form-control-static">{{ user.email }}</p> |
---|
| | 19 | </div> |
---|
| | 20 | </div> |
---|
| | 21 | <div class="form-group"> |
---|
| | 22 | <label class="control-label">Account created </label> |
---|
| | 23 | <div class=""> |
---|
| | 24 | <p class="form-control-static" id="user-created"> |
---|
| | 25 | {{ user.created }} |
---|
| | 26 | </p> |
---|
| | 27 | </div> |
---|
| | 28 | </div> |
---|
| | 29 | <button type="submit" class="btn btn-primary">Update</button> |
---|
| | 30 | </form> |
---|
| | 31 | |
---|
| | 32 | {% endblock %} |
---|
| | 33 | |
---|
| | 34 | {% block scripts %} |
---|
| | 35 | |
---|
| | 36 | <script> |
---|
| | 37 | var created = new Date("{{ user.created }}"); |
---|
| | 38 | window.onload = function() { |
---|
| | 39 | $('#user-created').html(created.toString()); |
---|
| | 40 | }; |
---|
| | 41 | </script> |
---|
| | 42 | |
---|
| | 43 | {% endblock %} |
---|
| | | | | | 1 | {% extends "layout.html" %} |
---|
| | 2 | |
---|
| | 3 | {% block body %} |
---|
| | 4 | |
---|
| | 5 | {% if sweets|length > 0 %} |
---|
| | 6 | |
---|
| | 7 | <ul class="entries unstyled"> |
---|
| | 8 | {% for sweet in sweets %} |
---|
| | 9 | <li> |
---|
| | 10 | <span class="who"> |
---|
| | 11 | <a href="#"> |
---|
| | 12 | @{{ sweet.who.username }} |
---|
| | 13 | </a> |
---|
| | 14 | </span> |
---|
| | 15 | <span class="what"> |
---|
| | 16 | <b> #{{ sweet.what.name }} </b> |
---|
| | 17 | </span> |
---|
| | 18 | <span class="where"> |
---|
| | 19 | {{ sweet.where }} |
---|
| | 20 | </span> |
---|
| | 21 | <p></p> |
---|
| | 22 | <span class="how"> |
---|
| | 23 | {{ sweet.how|tojson }} |
---|
| | 24 | </span> |
---|
| | 25 | |
---|
| | 26 | <small><i>created: {{sweet.created }}</i></small> |
---|
| | 27 | |
---|
| | 28 | <span class="pull-right permalink"> |
---|
| | 29 | <a href="#"> |
---|
| | 30 | <i class="glyphicon glyphicon-share"></i> |
---|
| | 31 | </a> |
---|
| | 32 | </span> |
---|
| | 33 | <span class="pull-right edit-sweet" for="{{ sweet.id }}"> |
---|
| | 34 | <a href="#"> |
---|
| | 35 | <i class="glyphicon glyphicon-edit"></i> |
---|
| | 36 | </a> |
---|
| | 37 | </span> |
---|
| | 38 | </li> |
---|
| | 39 | {% endfor %} |
---|
| | 40 | </ul> |
---|
| | 41 | |
---|
| | 42 | {% else %} |
---|
| | 43 | <div class="row"> |
---|
| | 44 | <div class="col-md-5"> |
---|
| | 45 | <h4><em>Unbelievable! No sweets yet!!</em></h4> |
---|
| | 46 | </div> |
---|
| | 47 | </div> |
---|
| | 48 | {% endif %} |
---|
| | 49 | |
---|
| | 50 | <div class="modal fade" id="edit-sweet-modal"> |
---|
| | 51 | <div class="modal-dialog"> |
---|
| | 52 | <div class="modal-content"> |
---|
| | 53 | <div class="modal-header"> |
---|
| | 54 | <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> |
---|
| | 55 | <h4 class="modal-title">Edit Sweet </h4> |
---|
| | 56 | </div> |
---|
| | 57 | <div class="modal-body"></div> |
---|
| | 58 | <div |
---|
| | 59 | class="modal-footer"> |
---|
| | 60 | <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> |
---|
| | 61 | <button type="button" class="btn btn-primary" id="save-edited-sweet">Save changes</button> |
---|
| | 62 | </div> |
---|
| | 63 | </div><!-- /.modal-content --> |
---|
| | 64 | </div><!-- /.modal-dialog --> |
---|
| | 65 | </div><!-- /.modal --> |
---|
| | 66 | |
---|
| | 67 | {% endblock %} |
---|