Skip to content
Snippets Groups Projects
Verified Commit 510c56be authored by Mark's avatar Mark
Browse files

Refactor space between class defs

parent 34b0ec23
No related branches found
No related tags found
No related merge requests found
...@@ -5,29 +5,34 @@ from sqlalchemy.orm import relationship, backref ...@@ -5,29 +5,34 @@ from sqlalchemy.orm import relationship, backref
from sqlalchemy import Boolean, DateTime, Column, Integer, \ from sqlalchemy import Boolean, DateTime, Column, Integer, \
String, ForeignKey String, ForeignKey
class RolesUsers(Base): class RolesUsers(Base):
__tablename__ = 'oas_roles_users' __tablename__ = 'oas_roles_users'
id = Column(Integer(), primary_key=True) id = Column(Integer(), primary_key=True)
user_id = Column('user_id', Integer(), ForeignKey('oas_user.id')) user_id = Column('user_id', Integer(), ForeignKey('oas_user.id'))
role_id = Column('role_id', Integer(), ForeignKey('oas_role.id')) role_id = Column('role_id', Integer(), ForeignKey('oas_role.id'))
class ApplicationsUsers(Base): class ApplicationsUsers(Base):
__tablename__ = 'oas_applications_users' __tablename__ = 'oas_applications_users'
id = Column(Integer(), primary_key=True) id = Column(Integer(), primary_key=True)
user_id = Column('user_id', Integer(), ForeignKey('oas_user.id')) user_id = Column('user_id', Integer(), ForeignKey('oas_user.id'))
application_id = Column('application_id', Integer(), ForeignKey('oas_application.id')) application_id = Column('application_id', Integer(), ForeignKey('oas_application.id'))
class Role(Base, RoleMixin): class Role(Base, RoleMixin):
__tablename__ = 'oas_role' __tablename__ = 'oas_role'
id = Column(Integer(), primary_key=True) id = Column(Integer(), primary_key=True)
name = Column(String(80), unique=True) name = Column(String(80), unique=True)
description = Column(String(255)) description = Column(String(255))
class Application(Base): class Application(Base):
__tablename__ = 'oas_application' __tablename__ = 'oas_application'
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
name = Column(String(80), unique=True) name = Column(String(80), unique=True)
class User(Base, UserMixin): class User(Base, UserMixin):
__tablename__ = 'oas_user' __tablename__ = 'oas_user'
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
......
...@@ -7,12 +7,14 @@ from flask_security.utils import hash_password ...@@ -7,12 +7,14 @@ from flask_security.utils import hash_password
user_datastore = get_user_datastore() user_datastore = get_user_datastore()
class User(SQLAlchemyObjectType): class User(SQLAlchemyObjectType):
class Meta: class Meta:
model = UserModel model = UserModel
exclude_fields = ("password") exclude_fields = ("password")
interfaces = (relay.Node, ) interfaces = (relay.Node, )
class UserMutation(graphene.Mutation): class UserMutation(graphene.Mutation):
class Arguments: class Arguments:
username = graphene.String(required=True) username = graphene.String(required=True)
...@@ -28,11 +30,13 @@ class UserMutation(graphene.Mutation): ...@@ -28,11 +30,13 @@ class UserMutation(graphene.Mutation):
user_datastore.commit() user_datastore.commit()
return UserMutation(user=user) return UserMutation(user=user)
class Application(SQLAlchemyObjectType): class Application(SQLAlchemyObjectType):
class Meta: class Meta:
model = ApplicationModel model = ApplicationModel
interfaces = (relay.Node, ) interfaces = (relay.Node, )
class Role(SQLAlchemyObjectType): class Role(SQLAlchemyObjectType):
class Meta: class Meta:
model = RoleModel model = RoleModel
...@@ -78,6 +82,7 @@ class Query(graphene.ObjectType): ...@@ -78,6 +82,7 @@ class Query(graphene.ObjectType):
query = User.get_query(info) query = User.get_query(info)
return query.filter(UserModel.username == username).first() return query.filter(UserModel.username == username).first()
class Mutation(graphene.ObjectType): class Mutation(graphene.ObjectType):
create_user = UserMutation.Field() create_user = UserMutation.Field()
create_role = CreateRole.Field() create_role = CreateRole.Field()
......
...@@ -7,6 +7,7 @@ from flask_security import SQLAlchemySessionUserDatastore ...@@ -7,6 +7,7 @@ from flask_security import SQLAlchemySessionUserDatastore
from database.models import User, Role, Application from database.models import User, Role, Application
from database.database import init_db from database.database import init_db
class DatabaseSetupTest(unittest.TestCase): class DatabaseSetupTest(unittest.TestCase):
def setUp(self): def setUp(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment