fix length of labels and some words

This commit is contained in:
Kostiantyn Stoliarskyi 2023-04-27 16:17:25 +03:00
parent 0efe0199e2
commit d242a3d838
15 changed files with 349 additions and 258 deletions

View File

@ -4,5 +4,5 @@ from wtforms.validators import DataRequired, Length
class CreateBookForm(FlaskForm):
label = StringField("Label", [DataRequired(), Length(6, 1024)])
label = StringField("Label", [DataRequired(), Length(6, 256)])
submit = SubmitField("Add new book")

View File

@ -4,14 +4,14 @@ from wtforms.validators import DataRequired, Length
class CreateCollectionForm(FlaskForm):
label = StringField("Label", [DataRequired(), Length(6, 1024)])
label = StringField("Label", [DataRequired(), Length(6, 256)])
about = StringField("About")
submit = SubmitField("Create")
class EditCollectionForm(FlaskForm):
label = StringField("Label", [Length(6, 1024)])
label = StringField("Label", [Length(6, 256)])
about = StringField("About")
submit = SubmitField("Edit")

View File

@ -5,7 +5,7 @@ from app.models.utils import BaseModel
class Book(BaseModel):
__tablename__ = "books"
label = db.Column(db.String(1024), unique=False, nullable=False)
label = db.Column(db.String(256), unique=False, nullable=False)
about = db.Column(db.Text, unique=False, nullable=True)
# Foreign keys

View File

@ -9,7 +9,7 @@ class BookVersion(BaseModel):
# need to redeclare id to use it in the derivative relationship
id = db.Column(db.Integer, primary_key=True)
semver = db.Column(db.String(1024), unique=False, nullable=False)
semver = db.Column(db.String(16), unique=False, nullable=False)
exported = db.Column(db.Boolean, default=False)
updated_at = db.Column(db.DateTime, default=datetime.now)

View File

@ -5,20 +5,19 @@ from app.models.utils import BaseModel
class Collection(BaseModel):
__tablename__ = "collections"
# need to redeclare id to use it in the parrent relationship
# need to redeclare id to use it in the parent relationship
id = db.Column(db.Integer, primary_key=True)
label = db.Column(db.String(1024), unique=False, nullable=False)
label = db.Column(db.String(256), unique=False, nullable=False)
about = db.Column(db.Text, unique=False, nullable=True)
is_root = db.Column(db.Boolean, default=False)
is_leaf = db.Column(db.Boolean, default=False)
# Foreign keys
version_id = db.Column(db.ForeignKey("book_versions.id"))
parrent_id = db.Column(db.ForeignKey("collections.id"))
parent_id = db.Column(db.ForeignKey("collections.id"))
# Relationships
version = db.relationship("BookVersion")
parrent = db.relationship("Collection", remote_side=[id])
children = db.relationship(
"Collection", backref=db.backref("parent", remote_side=[id]), viewonly=True
)

View File

@ -5,20 +5,19 @@ from app.models.utils import BaseModel
class Comment(BaseModel):
__tablename__ = "comments"
# need to redeclare id to use it in the parrent relationship
# need to redeclare id to use it in the parent relationship
id = db.Column(db.Integer, primary_key=True)
text = db.Column(db.Text, unique=False, nullable=False)
marked = db.Column(db.Boolean, default=False)
included_with_interpreation = db.Column(db.Boolean, default=False)
included_with_interpretation = db.Column(db.Boolean, default=False)
# Foreign keys
user_id = db.Column(db.ForeignKey("users.id"))
parrent_id = db.Column(db.ForeignKey("comments.id"))
parent_id = db.Column(db.ForeignKey("comments.id"))
interpretation_id = db.Column(db.ForeignKey("interpretations.id"))
# Relationships
user = db.relationship("User")
parrent = db.relationship("Comment", remote_side=[id])
children = db.relationship(
"Comment", backref=db.backref("parent", remote_side=[id]), viewonly=True
)

View File

@ -8,11 +8,11 @@ class CommentVote(BaseModel):
# Foreign keys
user_id = db.Column(db.Integer, db.ForeignKey("users.id"))
comment_id = db.Column(db.Integer, db.ForeignKey("comments.id"))
possitive = db.Column(db.Boolean, default=True)
positive = db.Column(db.Boolean, default=True)
# Relationships
user = db.relationship("User", viewonly=True)
comment = db.relationship("Comment", viewonly=True)
def __repr__(self):
return f"<{self.user} to {self.comment} Positive:{self.possitive}>"
return f"<{self.user} to {self.comment} Positive:{self.positive}>"

View File

@ -5,7 +5,7 @@ from app.models.utils import BaseModel
class Interpretation(BaseModel):
__tablename__ = "interpretations"
label = db.Column(db.String(1024), unique=False, nullable=False)
label = db.Column(db.String(256), unique=False, nullable=False)
text = db.Column(db.Text, unique=False, nullable=False)
marked = db.Column(db.Boolean, default=False)

View File

@ -8,11 +8,11 @@ class InterpretationVote(BaseModel):
# Foreign keys
user_id = db.Column(db.Integer, db.ForeignKey("users.id"))
interpretation_id = db.Column(db.Integer, db.ForeignKey("interpretations.id"))
possitive = db.Column(db.Boolean, default=True)
positive = db.Column(db.Boolean, default=True)
# Relationships
user = db.relationship("User", viewonly=True)
interpretation = db.relationship("Interpretation", viewonly=True)
def __repr__(self):
return f"<{self.user} to {self.interpretation} Positive:{self.possitive}>"
return f"<{self.user} to {self.interpretation} Positive:{self.positive}>"

View File

@ -5,7 +5,7 @@ from app.models.utils import BaseModel
class Section(BaseModel):
__tablename__ = "sections"
label = db.Column(db.String(1024), unique=False, nullable=False)
label = db.Column(db.String(256), unique=False, nullable=False)
about = db.Column(db.Text, unique=False, nullable=True)
# Foreign keys

View File

@ -1,200 +0,0 @@
"""init
Revision ID: e96f96cb7d02
Revises:
Create Date: 2023-04-26 11:40:49.008918
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'e96f96cb7d02'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('tags',
sa.Column('name', sa.String(length=32), nullable=False),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_deleted', sa.Boolean(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
op.create_table('users',
sa.Column('username', sa.String(length=60), nullable=False),
sa.Column('password_hash', sa.String(length=255), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_deleted', sa.Boolean(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('username')
)
op.create_table('books',
sa.Column('label', sa.String(length=1024), nullable=False),
sa.Column('about', sa.Text(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_deleted', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('book_contributors',
sa.Column('role', sa.Enum('UNKNOWN', 'MODERATOR', 'EDITOR', name='roles'), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('book_id', sa.Integer(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_deleted', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['book_id'], ['books.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('book_versions',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('semver', sa.String(length=1024), nullable=False),
sa.Column('exported', sa.Boolean(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.Column('derivative_id', sa.Integer(), nullable=True),
sa.Column('book_id', sa.Integer(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_deleted', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['book_id'], ['books.id'], ),
sa.ForeignKeyConstraint(['derivative_id'], ['book_versions.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('books_stars',
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('book_id', sa.Integer(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_deleted', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['book_id'], ['books.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('collections',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('label', sa.String(length=1024), nullable=False),
sa.Column('about', sa.Text(), nullable=False),
sa.Column('is_root', sa.Boolean(), nullable=True),
sa.Column('is_leaf', sa.Boolean(), nullable=True),
sa.Column('version_id', sa.Integer(), nullable=True),
sa.Column('parrent_id', sa.Integer(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_deleted', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['parrent_id'], ['collections.id'], ),
sa.ForeignKeyConstraint(['version_id'], ['book_versions.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('sections',
sa.Column('label', sa.String(length=1024), nullable=False),
sa.Column('about', sa.Text(), nullable=True),
sa.Column('collection_id', sa.Integer(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('version_id', sa.Integer(), nullable=True),
sa.Column('selected_interpretation_id', sa.Integer(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_deleted', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['collection_id'], ['collections.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.ForeignKeyConstraint(['version_id'], ['book_versions.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('interpretations',
sa.Column('label', sa.String(length=1024), nullable=False),
sa.Column('text', sa.Text(), nullable=False),
sa.Column('marked', sa.Boolean(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('section_id', sa.Integer(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_deleted', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['section_id'], ['sections.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('comments',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('text', sa.Text(), nullable=False),
sa.Column('marked', sa.Boolean(), nullable=True),
sa.Column('included_with_interpreation', sa.Boolean(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('parrent_id', sa.Integer(), nullable=True),
sa.Column('interpretation_id', sa.Integer(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_deleted', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['interpretation_id'], ['interpretations.id'], ),
sa.ForeignKeyConstraint(['parrent_id'], ['comments.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('interpretation_tags',
sa.Column('tag_id', sa.Integer(), nullable=True),
sa.Column('interpretation_id', sa.Integer(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_deleted', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['interpretation_id'], ['interpretations.id'], ),
sa.ForeignKeyConstraint(['tag_id'], ['tags.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('interpretation_votes',
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('interpretation_id', sa.Integer(), nullable=True),
sa.Column('possitive', sa.Boolean(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_deleted', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['interpretation_id'], ['interpretations.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('comment_tags',
sa.Column('tag_id', sa.Integer(), nullable=True),
sa.Column('comment_id', sa.Integer(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_deleted', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['comment_id'], ['comments.id'], ),
sa.ForeignKeyConstraint(['tag_id'], ['tags.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('comment_votes',
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('comment_id', sa.Integer(), nullable=True),
sa.Column('possitive', sa.Boolean(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_deleted', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['comment_id'], ['comments.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('comment_votes')
op.drop_table('comment_tags')
op.drop_table('interpretation_votes')
op.drop_table('interpretation_tags')
op.drop_table('comments')
op.drop_table('interpretations')
op.drop_table('sections')
op.drop_table('collections')
op.drop_table('books_stars')
op.drop_table('book_versions')
op.drop_table('book_contributors')
op.drop_table('books')
op.drop_table('users')
op.drop_table('tags')
# ### end Alembic commands ###

View File

@ -0,0 +1,293 @@
"""empty message
Revision ID: febf8dfa148f
Revises:
Create Date: 2023-04-27 16:07:14.727110
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "febf8dfa148f"
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"tags",
sa.Column("name", sa.String(length=32), nullable=False),
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("name"),
)
op.create_table(
"users",
sa.Column("username", sa.String(length=60), nullable=False),
sa.Column("password_hash", sa.String(length=255), nullable=True),
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("username"),
)
op.create_table(
"books",
sa.Column("label", sa.String(length=256), nullable=False),
sa.Column("about", sa.Text(), nullable=True),
sa.Column("user_id", sa.Integer(), nullable=True),
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"book_contributors",
sa.Column(
"role",
sa.Enum("UNKNOWN", "MODERATOR", "EDITOR", name="roles"),
nullable=True,
),
sa.Column("user_id", sa.Integer(), nullable=True),
sa.Column("book_id", sa.Integer(), nullable=True),
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(
["book_id"],
["books.id"],
),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"book_versions",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("semver", sa.String(length=16), nullable=False),
sa.Column("exported", sa.Boolean(), nullable=True),
sa.Column("updated_at", sa.DateTime(), nullable=True),
sa.Column("derivative_id", sa.Integer(), nullable=True),
sa.Column("book_id", sa.Integer(), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(
["book_id"],
["books.id"],
),
sa.ForeignKeyConstraint(
["derivative_id"],
["book_versions.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"books_stars",
sa.Column("user_id", sa.Integer(), nullable=True),
sa.Column("book_id", sa.Integer(), nullable=True),
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(
["book_id"],
["books.id"],
),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"collections",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("label", sa.String(length=256), nullable=False),
sa.Column("about", sa.Text(), nullable=True),
sa.Column("is_root", sa.Boolean(), nullable=True),
sa.Column("is_leaf", sa.Boolean(), nullable=True),
sa.Column("version_id", sa.Integer(), nullable=True),
sa.Column("parent_id", sa.Integer(), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(
["parent_id"],
["collections.id"],
),
sa.ForeignKeyConstraint(
["version_id"],
["book_versions.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"sections",
sa.Column("label", sa.String(length=256), nullable=False),
sa.Column("about", sa.Text(), nullable=True),
sa.Column("collection_id", sa.Integer(), nullable=True),
sa.Column("user_id", sa.Integer(), nullable=True),
sa.Column("version_id", sa.Integer(), nullable=True),
sa.Column("selected_interpretation_id", sa.Integer(), nullable=True),
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(
["collection_id"],
["collections.id"],
),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
),
sa.ForeignKeyConstraint(
["version_id"],
["book_versions.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"interpretations",
sa.Column("label", sa.String(length=256), nullable=False),
sa.Column("text", sa.Text(), nullable=False),
sa.Column("marked", sa.Boolean(), nullable=True),
sa.Column("user_id", sa.Integer(), nullable=True),
sa.Column("section_id", sa.Integer(), nullable=True),
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(
["section_id"],
["sections.id"],
),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"comments",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("text", sa.Text(), nullable=False),
sa.Column("marked", sa.Boolean(), nullable=True),
sa.Column("included_with_interpretation", sa.Boolean(), nullable=True),
sa.Column("user_id", sa.Integer(), nullable=True),
sa.Column("parent_id", sa.Integer(), nullable=True),
sa.Column("interpretation_id", sa.Integer(), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(
["interpretation_id"],
["interpretations.id"],
),
sa.ForeignKeyConstraint(
["parent_id"],
["comments.id"],
),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"interpretation_tags",
sa.Column("tag_id", sa.Integer(), nullable=True),
sa.Column("interpretation_id", sa.Integer(), nullable=True),
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(
["interpretation_id"],
["interpretations.id"],
),
sa.ForeignKeyConstraint(
["tag_id"],
["tags.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"interpretation_votes",
sa.Column("user_id", sa.Integer(), nullable=True),
sa.Column("interpretation_id", sa.Integer(), nullable=True),
sa.Column("positive", sa.Boolean(), nullable=True),
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(
["interpretation_id"],
["interpretations.id"],
),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"comment_tags",
sa.Column("tag_id", sa.Integer(), nullable=True),
sa.Column("comment_id", sa.Integer(), nullable=True),
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(
["comment_id"],
["comments.id"],
),
sa.ForeignKeyConstraint(
["tag_id"],
["tags.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"comment_votes",
sa.Column("user_id", sa.Integer(), nullable=True),
sa.Column("comment_id", sa.Integer(), nullable=True),
sa.Column("positive", sa.Boolean(), nullable=True),
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(
["comment_id"],
["comments.id"],
),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("comment_votes")
op.drop_table("comment_tags")
op.drop_table("interpretation_votes")
op.drop_table("interpretation_tags")
op.drop_table("comments")
op.drop_table("interpretations")
op.drop_table("sections")
op.drop_table("collections")
op.drop_table("books_stars")
op.drop_table("book_versions")
op.drop_table("book_contributors")
op.drop_table("books")
op.drop_table("users")
op.drop_table("tags")
# ### end Alembic commands ###

View File

@ -47,7 +47,7 @@ def create_dummy_data():
label="Dummy Collection 1 Label",
about="Dummy Collection 1 About",
version_id=unexported_version.id,
parrent_id=rool_collection.id,
parent_id=rool_collection.id,
is_leaf=True,
).save()
@ -55,7 +55,7 @@ def create_dummy_data():
label="Dummy Collection 2 Label",
about="Dummy Collection 2 About",
version_id=unexported_version.id,
parrent_id=rool_collection.id,
parent_id=rool_collection.id,
).save()
subcollection_2_1 = m.Collection(
@ -63,7 +63,7 @@ def create_dummy_data():
about="Dummy SubCollection 2.1 About",
is_leaf=True,
version_id=unexported_version.id,
parrent_id=collection_2.id,
parent_id=collection_2.id,
).save()
# sections
@ -150,7 +150,7 @@ def create_dummy_data():
# - comment 2
# - comment 3
# - comment 3.1 (marked)
# - comment 3.2 (included_with_interpreation)
# - comment 3.2 (included_with_interpretation)
# - comment 3.3
comment_1 = m.Comment(
@ -162,14 +162,14 @@ def create_dummy_data():
m.Comment(
text="Dummy Comment 1.1 Text",
user_id=user_3.id,
parrent_id=comment_1.id,
parent_id=comment_1.id,
interpretation_id=interpretation_2.id,
).save()
m.Comment(
text="Dummy Comment 1.2 Text",
user_id=user_2.id,
parrent_id=comment_1.id,
parent_id=comment_1.id,
marked=True,
interpretation_id=interpretation_2.id,
).save()
@ -190,52 +190,52 @@ def create_dummy_data():
text="Dummy Comment 3.1 Text",
user_id=user.id,
marked=True,
parrent_id=comment_3.id,
parent_id=comment_3.id,
interpretation_id=interpretation_2.id,
).save()
comment_3_2 = m.Comment(
text="Dummy Comment 3.2 Text",
user_id=user.id,
included_with_interpreation=True,
parrent_id=comment_3.id,
included_with_interpretation=True,
parent_id=comment_3.id,
interpretation_id=interpretation_2.id,
).save()
comment_3_3 = m.Comment(
text="Dummy Comment 3.3 Text",
user_id=user.id,
parrent_id=comment_3.id,
parent_id=comment_3.id,
interpretation_id=interpretation_2.id,
).save()
# - comment 3.1 (2 possitive, 2 negative)
# - comment 3.1 (2 positive, 2 negative)
# - comment 3.2 (1 negative)
# - comment 3.3 (1 possitive)
m.CommentVote(comment_id=comment_3_1.id, user_id=user.id, possitive=True).save()
m.CommentVote(comment_id=comment_3_1.id, user_id=user_2.id, possitive=True).save()
m.CommentVote(comment_id=comment_3_1.id, user_id=user_3.id, possitive=False).save()
m.CommentVote(comment_id=comment_3_1.id, user_id=user_4.id, possitive=False).save()
m.CommentVote(comment_id=comment_3_2.id, user_id=user_2.id, possitive=False).save()
m.CommentVote(comment_id=comment_3_3.id, user_id=user_3.id, possitive=True).save()
# - comment 3.3 (1 positive)
m.CommentVote(comment_id=comment_3_1.id, user_id=user.id, positive=True).save()
m.CommentVote(comment_id=comment_3_1.id, user_id=user_2.id, positive=True).save()
m.CommentVote(comment_id=comment_3_1.id, user_id=user_3.id, positive=False).save()
m.CommentVote(comment_id=comment_3_1.id, user_id=user_4.id, positive=False).save()
m.CommentVote(comment_id=comment_3_2.id, user_id=user_2.id, positive=False).save()
m.CommentVote(comment_id=comment_3_3.id, user_id=user_3.id, positive=True).save()
# - interpretation 1 (2 possitive, 1 negative)
# - interpretation 1 (2 positive, 1 negative)
# - interpretation 2 (1 negative)
# - interpretation 3 (1 possitive)
# - interpretation 3 (1 positive)
m.InterpretationVote(
interpretation_id=interpretation_1.id, user_id=user.id, possitive=True
interpretation_id=interpretation_1.id, user_id=user.id, positive=True
).save()
m.InterpretationVote(
interpretation_id=interpretation_1.id, user_id=user_2.id, possitive=True
interpretation_id=interpretation_1.id, user_id=user_2.id, positive=True
).save()
m.InterpretationVote(
interpretation_id=interpretation_1.id, user_id=user_3.id, possitive=False
interpretation_id=interpretation_1.id, user_id=user_3.id, positive=False
).save()
m.InterpretationVote(
interpretation_id=interpretation_2.id, user_id=user_2.id, possitive=False
interpretation_id=interpretation_2.id, user_id=user_2.id, positive=False
).save()
m.InterpretationVote(
interpretation_id=interpretation_3.id, user_id=user_3.id, possitive=True
interpretation_id=interpretation_3.id, user_id=user_3.id, positive=True
).save()
# tags

View File

@ -20,14 +20,14 @@ def test_create_book(client: FlaskClient):
)
assert response.status_code == 200
assert b"Label must be between 6 and 1024 characters long." in response.data
assert b"Label must be between 6 and 256 characters long." in response.data
book = m.Book.query.filter_by(label=BOOK_NAME).first()
assert not book
assert not m.Book.query.count()
# label len > 1024
# label len > 256
response: Response = client.post(
"/book/create",
data=dict(
@ -37,7 +37,7 @@ def test_create_book(client: FlaskClient):
)
assert response.status_code == 200
assert b"Label must be between 6 and 1024 characters long." in response.data
assert b"Label must be between 6 and 256 characters long." in response.data
book = m.Book.query.filter_by(label=BOOK_NAME).first()

View File

@ -190,14 +190,14 @@ def test_dummy_data(runner: FlaskCliRunner):
# - comment 2
# - comment 3
# - comment 3.1 (marked)
# - comment 3.2 (included_with_interpreation)
# - comment 3.2 (included_with_interpretation)
# - comment 3.3
comment_1: m.Comment = m.Comment.query.filter_by(
text="Dummy Comment 1 Text"
).first()
assert not comment_1.parrent
assert not comment_1.parent
comment_1_1: m.Comment = m.Comment.query.filter_by(
text="Dummy Comment 1.1 Text"
@ -209,22 +209,22 @@ def test_dummy_data(runner: FlaskCliRunner):
assert comment_1_1 in comment_1.children
assert comment_1_1 in comment_1.children
assert comment_1_2.parrent == comment_1
assert comment_1_2.parrent == comment_1
assert comment_1_2.parent == comment_1
assert comment_1_2.parent == comment_1
assert comment_1_2.marked
comment_2: m.Comment = m.Comment.query.filter_by(
text="Dummy Comment 2 Text"
).first()
assert not comment_2.parrent
assert not comment_2.parent
assert not comment_2.children
comment_3: m.Comment = m.Comment.query.filter_by(
text="Dummy Comment 3 Text"
).first()
assert not comment_3.parrent
assert not comment_3.parent
assert comment_3.children
comment_3_1: m.Comment = m.Comment.query.filter_by(
@ -243,23 +243,23 @@ def test_dummy_data(runner: FlaskCliRunner):
assert comment_3_2 in comment_3.children
assert comment_3_3 in comment_3.children
assert comment_3_1.marked
assert comment_3_2.included_with_interpreation
assert comment_3_2.included_with_interpretation
assert comment_1 in interpretation_2.comments
assert comment_2 in interpretation_2.comments
assert comment_3 in interpretation_2.comments
# - comment 3.1 (2 possitive, 2 negative)
# - comment 3.1 (2 positive, 2 negative)
# - comment 3.2 (1 negative)
# - comment 3.3 (1 possitive)
# - comment 3.3 (1 positive)
assert len(comment_3_1.votes) == 4
assert len(comment_3_2.votes) == 1
assert len(comment_3_3.votes) == 1
# - interpretation 1 (2 possitive, 1 negative)
# - interpretation 1 (2 positive, 1 negative)
# - interpretation 2 (1 negative)
# - interpretation 3 (1 possitive)
# - interpretation 3 (1 positive)
assert len(interpretation_1.votes) == 3
assert len(interpretation_2.votes) == 1
assert len(interpretation_3.votes) == 1