Skip to content
Snippets Groups Projects
Commit df1ee680 authored by markus scheller's avatar markus scheller
Browse files

Added invitation storage

parent 665469d1
Branches
No related tags found
1 merge request!12WIP: Resolve "Einladungen zum Aushängen drucken"
This commit is part of merge request !12. Comments created here will be created in the context of that merge request.
"""empty message
Revision ID: 45c336464a07
Revises: 3b2e9b2b7579
Create Date: 2018-03-19 18:50:45.428045
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '45c336464a07'
down_revision = '3b2e9b2b7579'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('invitationdocuments',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('protocol_id', sa.Integer(), nullable=True),
sa.Column('name', sa.String(), nullable=True),
sa.Column('filename', sa.String(), nullable=True),
sa.ForeignKeyConstraint(['protocol_id'], ['protocols.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('invitationdocuments')
# ### end Alembic commands ###
...@@ -207,6 +207,9 @@ class Protocol(DatabaseModel): ...@@ -207,6 +207,9 @@ class Protocol(DatabaseModel):
documents = relationship( documents = relationship(
"Document", backref=backref("protocol"), "Document", backref=backref("protocol"),
cascade="all, delete-orphan", order_by="Document.is_compiled") cascade="all, delete-orphan", order_by="Document.is_compiled")
invitations = relationship(
"Invitation", backref=backref("protocol"),
cascade="all, delete-orphan", order_by="Invitation.id")
errors = relationship( errors = relationship(
"Error", backref=backref("protocol"), cascade="all, delete-orphan", "Error", backref=backref("protocol"), cascade="all, delete-orphan",
order_by="Error.id") order_by="Error.id")
...@@ -584,6 +587,33 @@ def on_decisions_document_delete(mapper, connection, document): ...@@ -584,6 +587,33 @@ def on_decisions_document_delete(mapper, connection, document):
os.remove(document_path) os.remove(document_path)
class InvitationDocument(DatabaseModel):
__tablename__ = "invitationdocuments"
__model_name__ = "invitationdocument"
id = db.Column(db.Integer, primary_key=True)
protocol_id = db.Column(db.Integer, db.ForeignKey("protocols.id"))
name = db.Column(db.String)
filename = db.Column(db.String)
def get_parent(self):
return self.decision
def get_filename(self):
return os.path.join(config.DOCUMENTS_PATH, self.filename)
def as_file_like(self):
with open(self.get_filename(), "rb") as file:
return BytesIO(file.read())
@event.listens_for(InvitationDocument, "before_delete")
def on_decisions_document_delete(mapper, connection, document):
if document.filename is not None:
document_path = document.get_filename()
if os.path.isfile(document_path):
os.remove(document_path)
class TodoState(Enum): class TodoState(Enum):
open = 0 open = 0
waiting = 1 waiting = 1
...@@ -933,5 +963,6 @@ class LikeTOPAssociation(DatabaseModel): ...@@ -933,5 +963,6 @@ class LikeTOPAssociation(DatabaseModel):
ALL_MODELS = [ ALL_MODELS = [
ProtocolType, Protocol, DefaultTOP, TOP, Document, DecisionDocument, ProtocolType, Protocol, DefaultTOP, TOP, Document, DecisionDocument,
Todo, Decision, MeetingReminder, Error, DefaultMeta, Meta, DecisionCategory InvitationDocument, Todo, Decision, MeetingReminder, Error, DefaultMeta,
Meta, DecisionCategory
] ]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment