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

DB: Paper si pamatuje, zda a kdy jsme ho zkoušeli opravit

To je potřeba, aby automatické opravování nezkoušelo tentýž paper
pořád dokola.
parent 57563374
No related branches found
No related tags found
1 merge request!109Automatická oprava rozbitých PDF
This commit is part of merge request !109. Comments created here will be created in the context of that merge request.
......@@ -219,11 +219,13 @@ CREATE TABLE papers (
bytes int DEFAULT NULL, -- velikost souboru
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
note text NOT NULL DEFAULT '', -- komentář uploadujícího
fixed_at timestamp with time zone DEFAULT NULL
-- 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
-- - časem se spustí oprava, která vyplní i file_name, přepočítá bytes a nastaví fixed_at
-- - pokud oprava selže, nastaví pouze fixed_at
);
CREATE INDEX papers_for_task_index ON papers (for_task);
......
SET ROLE 'mo_osmo';
ALTER TABLE papers ADD COLUMN
fixed_at timestamp with time zone DEFAULT NULL;
......@@ -629,6 +629,7 @@ class Paper(Base):
file_name = Column(String(255))
orig_file_name = Column(String(255))
note = Column(Text, nullable=False, server_default=text("''::text"))
fixed_at = Column(DateTime(True))
task = relationship('Task')
for_user_obj = relationship('User', primaryjoin='Paper.for_user == User.user_id')
......@@ -650,6 +651,9 @@ class Paper(Base):
def is_broken(self) -> bool:
return self.file_name is None
def is_nonfixable(self) -> bool:
return self.is_broken() and self.fixed_at is not None
def is_fixed(self) -> bool:
return self.orig_file_name is not None and self.file_name is not None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment