--- a/swtstore/classes/models/__init__.py +++ b/swtstore/classes/models/__init__.py @@ -1,3 +1,6 @@ +from user import User +#from group import Group +#from membership import Membership from context import Context from sweet import Sweet from client import Client, AuthorizedClients --- a/swtstore/classes/models/client.py +++ b/swtstore/classes/models/client.py @@ -6,8 +6,9 @@ from flask import current_app from swtstore.classes.database import db -from swtstore.classes.models.um import User +from swtstore.classes.models import User from swtstore.classes import oauth + class Client(db.Model): """ --- a/swtstore/classes/models/group.py +++ b/swtstore/classes/models/group.py @@ -6,7 +6,8 @@ from datetime import datetime -from .config import db +from swtstore.classes.database import db + class Group(db.Model): """ --- a/swtstore/classes/models/membership.py +++ b/swtstore/classes/models/membership.py @@ -3,7 +3,8 @@ from datetime import datetime -from .config import db +from swtstore.classes.database import db + class Membership(db.Model): """ docstring """ --- a/swtstore/classes/models/sweet.py +++ b/swtstore/classes/models/sweet.py @@ -9,8 +9,7 @@ # custom SQLAlchemy type JSONType from swtstore.classes.models.types import JSONType from swtstore.classes.utils import urlnorm # normalize URLs -from swtstore.classes.models import Context -from swtstore.classes.models.um import User +from swtstore.classes.models import Context, User class Sweet(db.Model): """ customary docstring """ --- a/swtstore/classes/models/user.py +++ b/swtstore/classes/models/user.py @@ -3,13 +3,11 @@ from datetime import datetime from flask import session - -#from .config import db from flask import current_app -# TODO: remove dependency from config file -db = current_app.db +from swtstore.classes.database import db + class User(db.Model): """ docstring """ @@ -30,7 +28,7 @@ self.username = kwargs.get('username') if kwargs.get('last_active'): current_app.logger.debug('Updated last_active timestamp %s for %s', - self, kwargs.get('last_active')) + kwargs.get('last_active'), self) self.last_active = kwargs.get('last_active') self.persist() --- a/swtstore/classes/views/app.py +++ b/swtstore/classes/views/app.py @@ -7,8 +7,7 @@ from hashlib import md5 from werkzeug.security import gen_salt -from swtstore.classes.models import Client -from swtstore.classes.models.um import User +from swtstore.classes.models import Client, User from swtstore.classes.utils import urlnorm --- a/swtstore/classes/views/context.py +++ b/swtstore/classes/views/context.py @@ -4,8 +4,7 @@ from flask import Module, jsonify, request, render_template, redirect,\ url_for, json, current_app -from swtstore.classes.models import Context -from swtstore.classes.models.um import User +from swtstore.classes.models import Context, User context = Module(__name__) --- a/swtstore/classes/views/frontend.py +++ b/swtstore/classes/views/frontend.py @@ -7,8 +7,7 @@ from sqlalchemy import desc -from swtstore.classes.models import Sweet -from swtstore.classes.models.um import User +from swtstore.classes.models import Sweet, User frontend = Module(__name__) --- a/swtstore/classes/views/oauth.py +++ b/swtstore/classes/views/oauth.py @@ -6,8 +6,7 @@ import requests from swtstore.classes import oauth -from swtstore.classes.models.um import User -from swtstore.classes.models import Client, AuthorizedClients +from swtstore.classes.models import Client, AuthorizedClients, User Oauth = Module(__name__) --- a/swtstore/classes/views/sweet.py +++ b/swtstore/classes/views/sweet.py @@ -5,9 +5,7 @@ from flask import Module, jsonify, request, render_template, redirect,\ url_for, abort, json -from swtstore.classes.models import Context -from swtstore.classes.models import Sweet -from swtstore.classes.models.um import User +from swtstore.classes.models import Context, Sweet, User sweet = Module(__name__) --- a/swtstore/classes/views/user.py +++ b/swtstore/classes/views/user.py @@ -8,8 +8,8 @@ make_response, url_for, redirect, json, current_app # swtstore imports -from swtstore.classes.models.um import User -from swtstore.classes.models import Sweet, Context, Client, AuthorizedClients +from swtstore.classes.models import User, Sweet, Context, Client,\ + AuthorizedClients from swtstore.classes.utils.httputils import makeCORSHeaders from swtstore.config import DefaultConfig