Commit 1e7645a320f7e5a3162fd7ea8ac49e7341e7ccd3
Update code after removing submodule
Updated the code to work w/o user management submodule.
This removes cloning the sub-module separately and configuring it.
| | | | | | 1 | from user import User |
---|
| | 2 | #from group import Group |
---|
| | 3 | #from membership import Membership |
---|
1 | from context import Context | 4 | from context import Context |
---|
2 | from sweet import Sweet | 5 | from sweet import Sweet |
---|
3 | from client import Client, AuthorizedClients | 6 | from client import Client, AuthorizedClients |
---|
| | | | 6 | from flask import current_app | 6 | from flask import current_app |
---|
7 | | 7 | |
---|
8 | from swtstore.classes.database import db | 8 | from swtstore.classes.database import db |
---|
9 | from swtstore.classes.models.um import User | | from swtstore.classes.models.um import User |
---|
| | 9 | from swtstore.classes.models import User | 10 | from swtstore.classes import oauth | 10 | from swtstore.classes import oauth |
---|
| | 11 | |
---|
11 | | 12 | |
---|
12 | class Client(db.Model): | 13 | class Client(db.Model): |
---|
13 | """ | 14 | """ |
---|
| | | | 6 | | 6 | |
---|
7 | from datetime import datetime | 7 | from datetime import datetime |
---|
8 | | 8 | |
---|
9 | from .config import db | | from .config import db |
---|
| | 9 | from swtstore.classes.database import db | | | 10 | |
---|
10 | | 11 | |
---|
11 | class Group(db.Model): | 12 | class Group(db.Model): |
---|
12 | """ | 13 | """ |
---|
| | | | 3 | | 3 | |
---|
4 | from datetime import datetime | 4 | from datetime import datetime |
---|
5 | | 5 | |
---|
6 | from .config import db | | from .config import db |
---|
| | 6 | from swtstore.classes.database import db | | | 7 | |
---|
7 | | 8 | |
---|
8 | class Membership(db.Model): | 9 | class Membership(db.Model): |
---|
9 | """ docstring """ | 10 | """ docstring """ |
---|
| | | | 9 | # custom SQLAlchemy type JSONType | 9 | # custom SQLAlchemy type JSONType |
---|
10 | from swtstore.classes.models.types import JSONType | 10 | from swtstore.classes.models.types import JSONType |
---|
11 | from swtstore.classes.utils import urlnorm # normalize URLs | 11 | from swtstore.classes.utils import urlnorm # normalize URLs |
---|
12 | from swtstore.classes.models import Context | | from swtstore.classes.models import Context |
---|
13 | from swtstore.classes.models.um import User | | from swtstore.classes.models.um import User |
---|
| | 12 | from swtstore.classes.models import Context, User | 14 | | 13 | |
---|
15 | class Sweet(db.Model): | 14 | class Sweet(db.Model): |
---|
16 | """ customary docstring """ | 15 | """ customary docstring """ |
---|
| | | | 3 | | 3 | |
---|
4 | from datetime import datetime | 4 | from datetime import datetime |
---|
5 | from flask import session | 5 | from flask import session |
---|
6 | | | |
---|
7 | #from .config import db | | #from .config import db |
---|
8 | from flask import current_app | 6 | from flask import current_app |
---|
9 | # TODO: remove dependency from config file | | # TODO: remove dependency from config file |
---|
10 | db = current_app.db | | db = current_app.db |
---|
11 | | 7 | |
---|
| | 8 | from swtstore.classes.database import db |
---|
12 | | 9 | |
---|
| | 10 | |
---|
13 | class User(db.Model): | 11 | class User(db.Model): |
---|
14 | """ docstring """ | 12 | """ docstring """ |
---|
15 | | 13 | |
---|
… | | … | |
---|
28 | self.username = kwargs.get('username') | 28 | self.username = kwargs.get('username') |
---|
29 | if kwargs.get('last_active'): | 29 | if kwargs.get('last_active'): |
---|
30 | current_app.logger.debug('Updated last_active timestamp %s for %s', | 30 | current_app.logger.debug('Updated last_active timestamp %s for %s', |
---|
31 | self, kwargs.get('last_active')) | | self, kwargs.get('last_active')) |
---|
| | 31 | kwargs.get('last_active'), self) | 32 | self.last_active = kwargs.get('last_active') | 32 | self.last_active = kwargs.get('last_active') |
---|
33 | | 33 | |
---|
34 | self.persist() | 34 | self.persist() |
---|
| | | | 7 | from hashlib import md5 | 7 | from hashlib import md5 |
---|
8 | from werkzeug.security import gen_salt | 8 | from werkzeug.security import gen_salt |
---|
9 | | 9 | |
---|
10 | from swtstore.classes.models import Client | | from swtstore.classes.models import Client |
---|
11 | from swtstore.classes.models.um import User | | from swtstore.classes.models.um import User |
---|
| | 10 | from swtstore.classes.models import Client, User | 12 | from swtstore.classes.utils import urlnorm | 11 | from swtstore.classes.utils import urlnorm |
---|
13 | | 12 | |
---|
14 | | 13 | |
---|
| | | | 4 | from flask import Module, jsonify, request, render_template, redirect,\ | 4 | from flask import Module, jsonify, request, render_template, redirect,\ |
---|
5 | url_for, json, current_app | 5 | url_for, json, current_app |
---|
6 | | 6 | |
---|
7 | from swtstore.classes.models import Context | | from swtstore.classes.models import Context |
---|
8 | from swtstore.classes.models.um import User | | from swtstore.classes.models.um import User |
---|
| | 7 | from swtstore.classes.models import Context, User | 9 | | 8 | |
---|
10 | | 9 | |
---|
11 | context = Module(__name__) | 10 | context = Module(__name__) |
---|
| | | | 7 | | 7 | |
---|
8 | from sqlalchemy import desc | 8 | from sqlalchemy import desc |
---|
9 | | 9 | |
---|
10 | from swtstore.classes.models import Sweet | | from swtstore.classes.models import Sweet |
---|
11 | from swtstore.classes.models.um import User | | from swtstore.classes.models.um import User |
---|
| | 10 | from swtstore.classes.models import Sweet, User | 12 | | 11 | |
---|
13 | | 12 | |
---|
14 | frontend = Module(__name__) | 13 | frontend = Module(__name__) |
---|
| | | | 6 | import requests | 6 | import requests |
---|
7 | | 7 | |
---|
8 | from swtstore.classes import oauth | 8 | from swtstore.classes import oauth |
---|
9 | from swtstore.classes.models.um import User | | from swtstore.classes.models.um import User |
---|
10 | from swtstore.classes.models import Client, AuthorizedClients | | from swtstore.classes.models import Client, AuthorizedClients |
---|
| | 9 | from swtstore.classes.models import Client, AuthorizedClients, User | 11 | | 10 | |
---|
12 | | 11 | |
---|
13 | Oauth = Module(__name__) | 12 | Oauth = Module(__name__) |
---|
| | | | 5 | from flask import Module, jsonify, request, render_template, redirect,\ | 5 | from flask import Module, jsonify, request, render_template, redirect,\ |
---|
6 | url_for, abort, json | 6 | url_for, abort, json |
---|
7 | | 7 | |
---|
8 | from swtstore.classes.models import Context | | from swtstore.classes.models import Context |
---|
9 | from swtstore.classes.models import Sweet | | from swtstore.classes.models import Sweet |
---|
10 | from swtstore.classes.models.um import User | | from swtstore.classes.models.um import User |
---|
| | 8 | from swtstore.classes.models import Context, Sweet, User | 11 | | 9 | |
---|
12 | | 10 | |
---|
13 | sweet = Module(__name__) | 11 | sweet = Module(__name__) |
---|
| | | | 8 | make_response, url_for, redirect, json, current_app | 8 | make_response, url_for, redirect, json, current_app |
---|
9 | | 9 | |
---|
10 | # swtstore imports | 10 | # swtstore imports |
---|
11 | from swtstore.classes.models.um import User | | from swtstore.classes.models.um import User |
---|
12 | from swtstore.classes.models import Sweet, Context, Client, AuthorizedClients | | from swtstore.classes.models import Sweet, Context, Client, AuthorizedClients |
---|
| | 11 | from swtstore.classes.models import User, Sweet, Context, Client,\ | | | 12 | 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 |
---|