Skip to content
Snippets Groups Projects
Commit 49eeb29f authored by Martin Mareš's avatar Martin Mareš
Browse files

DB: Soubor s diplomy si pamatuje, zda je schválen

parent 9184d8d0
No related branches found
No related tags found
No related merge requests found
...@@ -532,6 +532,7 @@ CREATE TABLE cert_files ( ...@@ -532,6 +532,7 @@ CREATE TABLE cert_files (
cert_set_id int NOT NULL REFERENCES cert_sets(contest_id) ON DELETE CASCADE, cert_set_id int NOT NULL REFERENCES cert_sets(contest_id) ON DELETE CASCADE,
type cert_type NOT NULL, type cert_type NOT NULL,
pdf_file text NOT NULL, -- relativně vůči mo.util.data_dir('cert') pdf_file text NOT NULL, -- relativně vůči mo.util.data_dir('cert')
approved bool NOT NULL DEFAULT false,
UNIQUE (cert_set_id, type) UNIQUE (cert_set_id, type)
); );
......
...@@ -30,6 +30,7 @@ CREATE TABLE cert_files ( ...@@ -30,6 +30,7 @@ CREATE TABLE cert_files (
cert_set_id int NOT NULL REFERENCES cert_sets(contest_id) ON DELETE CASCADE, cert_set_id int NOT NULL REFERENCES cert_sets(contest_id) ON DELETE CASCADE,
type cert_type NOT NULL, type cert_type NOT NULL,
pdf_file text NOT NULL, -- relativně vůči mo.util.data_dir('cert') pdf_file text NOT NULL, -- relativně vůči mo.util.data_dir('cert')
approved bool NOT NULL DEFAULT false,
UNIQUE (cert_set_id, type) UNIQUE (cert_set_id, type)
); );
......
...@@ -1152,6 +1152,7 @@ class CertFile(Base): ...@@ -1152,6 +1152,7 @@ class CertFile(Base):
cert_set_id = Column(Integer, ForeignKey('cert_sets.contest_id', ondelete='CASCADE'), primary_key=True) cert_set_id = Column(Integer, ForeignKey('cert_sets.contest_id', ondelete='CASCADE'), primary_key=True)
type = Column(Enum(CertType, name='cert_type'), nullable=False, primary_key=True) type = Column(Enum(CertType, name='cert_type'), nullable=False, primary_key=True)
pdf_file = Column(Text, nullable=False) pdf_file = Column(Text, nullable=False)
approved = Column(Boolean, server_default=text("false"), nullable=False)
class Certificate(Base): class Certificate(Base):
...@@ -1164,6 +1165,9 @@ class Certificate(Base): ...@@ -1164,6 +1165,9 @@ class Certificate(Base):
page_number = Column(Integer, nullable=False) page_number = Column(Integer, nullable=False)
cert_set = relationship('CertSet') cert_set = relationship('CertSet')
cert_file = relationship('CertFile',
primaryjoin='and_(CertFile.cert_set_id == Certificate.cert_set_id, CertFile.type == Certificate.type)',
foreign_keys='[Certificate.cert_set_id, Certificate.type]')
user = relationship('User') user = relationship('User')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment