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

DB: Změna ukládání poničených PDF

Viz issue #150.
parent 08d7c480
No related branches found
No related tags found
1 merge request!53Změna reprezentace rozbitých submitů
......@@ -181,9 +181,13 @@ CREATE TABLE papers (
uploaded_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
pages int DEFAULT NULL, -- počet stránek
bytes int DEFAULT NULL, -- velikost souboru
file_name varchar(255) NOT NULL, -- relativní cesta k souboru
note text NOT NULL DEFAULT '', -- komentář uploadujícího
broken bool NOT NULL DEFAULT false -- poničené PDF přijaté s varováním
file_name varchar(255) DEFAULT NULL, -- relativní cesta k souboru
orig_file_name varchar(255) DEFAULT NULL, -- původní cesta, pokud PDF bylo poničené
note text NOT NULL DEFAULT '' -- komentář uploadujícího
-- Sémantika práce s poničenými soubory:
-- - správná PDF mají orig_file_name=NULL
-- - pokud někdo odevzdá poničené, vyplní se orig_file_name, ale file_name=NULL
-- - časem se spustí oprava, která vyplní i file_name a přepočítá bytes
);
CREATE INDEX papers_for_task_index ON papers (for_task);
......
SET ROLE 'mo_osmo';
ALTER TABLE papers
ADD COLUMN orig_file_name varchar(255) DEFAULT NULL;
ALTER TABLE papers
ALTER COLUMN file_name DROP NOT NULL;
ALTER TABLE papers
ALTER COLUMN file_name SET DEFAULT NULL;
ALTER TABLE papers
DROP COLUMN broken;
......@@ -489,9 +489,9 @@ class Paper(Base):
uploaded_at = Column(DateTime(True), nullable=False, server_default=text("CURRENT_TIMESTAMP"))
pages = Column(Integer)
bytes = Column(Integer)
file_name = Column(String(255), nullable=False)
file_name = Column(String(255))
orig_file_name = Column(String(255))
note = Column(Text, nullable=False, server_default=text("''::text"))
broken = Column(Boolean, nullable=False, server_default=text("false"))
task = relationship('Task')
for_user_obj = relationship('User', primaryjoin='Paper.for_user == User.user_id')
......@@ -510,6 +510,12 @@ class Paper(Base):
else:
return None
def is_broken(self) -> bool:
return self.file_name is None
def is_fixed(self) -> bool:
return self.orig_file_name is not None and self.file_name is not None
class PointsHistory(Base):
__tablename__ = 'points_history'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment