section approved_interpretation

approved_comments
This commit is contained in:
SvyatoslavArtymovych 2023-05-18 16:01:33 +03:00
parent 0d7e736bed
commit 13aba00a7d
4 changed files with 143159 additions and 2 deletions

View File

@ -1,6 +1,8 @@
from app import db from app import db
from app.models.utils import BaseModel from app.models.utils import BaseModel
from app.controllers import create_breadcrumbs from app.controllers import create_breadcrumbs
from .interpretation import Interpretation
from .comment import Comment
class Section(BaseModel): class Section(BaseModel):
@ -71,5 +73,26 @@ class Section(BaseModel):
if not interpretation.is_deleted if not interpretation.is_deleted
] ]
@property
def approved_interpretation(self):
interpretation = Interpretation.query.filter_by(
approved=True, section_id=self.id
).first()
return interpretation
@property
def approved_comments(self):
interpretation_ids = [
interpretation.id for interpretation in self.interpretations
]
comments = (
Comment.query.filter_by(approved=True)
.filter(Comment.interpretation_id.in_(interpretation_ids))
.all()
)
return comments
def __repr__(self): def __repr__(self):
return f"<{self.id}: {self.label}>" return f"<{self.id}: {self.label}>"

View File

@ -1462,6 +1462,10 @@ input:checked + .toggle-bg {
height: 4rem; height: 4rem;
} }
.h-40 {
height: 10rem;
}
.max-h-full { .max-h-full {
max-height: 100%; max-height: 100%;
} }
@ -1752,6 +1756,10 @@ input:checked + .toggle-bg {
gap: 1.5rem; gap: 1.5rem;
} }
.gap-1 {
gap: 0.25rem;
}
.-space-x-px > :not([hidden]) ~ :not([hidden]) { .-space-x-px > :not([hidden]) ~ :not([hidden]) {
--tw-space-x-reverse: 0; --tw-space-x-reverse: 0;
margin-right: calc(-1px * var(--tw-space-x-reverse)); margin-right: calc(-1px * var(--tw-space-x-reverse));
@ -2090,6 +2098,11 @@ input:checked + .toggle-bg {
background-color: rgb(255 255 255 / 0.5); background-color: rgb(255 255 255 / 0.5);
} }
.bg-sky-300 {
--tw-bg-opacity: 1;
background-color: rgb(125 211 252 / var(--tw-bg-opacity));
}
.bg-opacity-50 { .bg-opacity-50 {
--tw-bg-opacity: 0.5; --tw-bg-opacity: 0.5;
} }
@ -2561,6 +2574,11 @@ input:checked + .toggle-bg {
background-color: rgb(255 255 255 / var(--tw-bg-opacity)); background-color: rgb(255 255 255 / var(--tw-bg-opacity));
} }
.hover\:bg-sky-400:hover {
--tw-bg-opacity: 1;
background-color: rgb(56 189 248 / var(--tw-bg-opacity));
}
.hover\:bg-gradient-to-bl:hover { .hover\:bg-gradient-to-bl:hover {
background-image: linear-gradient(to bottom left, var(--tw-gradient-stops)); background-image: linear-gradient(to bottom left, var(--tw-gradient-stops));
} }

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,38 @@
"""remove fields from section and interpretation
Revision ID: 883298018384
Revises: 5df1fabbee7d
Create Date: 2023-05-18 15:49:20.145655
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '883298018384'
down_revision = '5df1fabbee7d'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('interpretations', schema=None) as batch_op:
batch_op.drop_column('label')
with op.batch_alter_table('sections', schema=None) as batch_op:
batch_op.drop_column('about')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('sections', schema=None) as batch_op:
batch_op.add_column(sa.Column('about', sa.TEXT(), autoincrement=False, nullable=True))
with op.batch_alter_table('interpretations', schema=None) as batch_op:
batch_op.add_column(sa.Column('label', sa.VARCHAR(length=256), autoincrement=False, nullable=False))
# ### end Alembic commands ###