From 577085c1660f9584d224b89e41324e5433d479a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Sun, 12 Mar 2017 16:32:07 +0100 Subject: Removed description, added name; also as special prefix --- archivist/model.py | 2 +- archivist/prefixes.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/archivist/model.py b/archivist/model.py index 6d452b4..56ef89e 100644 --- a/archivist/model.py +++ b/archivist/model.py @@ -76,7 +76,7 @@ class Document(BaseModel): content = ForeignKeyField(DocumentContent, related_name = 'document') created = DateField(default=datetime.date.today) inserted = DateTimeField(default=datetime.datetime.now) - description = CharField(null=True) + name = CharField(null=True) original_path = CharField(null=True) mimetype = CharField(null=True) direction = EnumField(Direction, null=True) diff --git a/archivist/prefixes.py b/archivist/prefixes.py index c85d833..5e28207 100644 --- a/archivist/prefixes.py +++ b/archivist/prefixes.py @@ -19,6 +19,7 @@ def _create_prefixes(): FieldPseudoPrefix('direction', 'In- or outgoing', Document.direction) FieldPseudoPrefix('date', 'Date of creation', Document.created) FieldPseudoPrefix('mime', 'Mime Type', Document.mimetype) + ContainsFieldPseudoPrefix('name', 'Name/description of document', Document.name) for part in ('day', 'month', 'year'): FieldPartPseudoPrefix(part, part.capitalize() + ' of creation', Document.created, part) @@ -61,6 +62,10 @@ class FieldPseudoPrefix(PseudoPrefix): def as_query(self, value): return self._field == value +class ContainsFieldPseudoPrefix(FieldPseudoPrefix): + def as_query(self, value): + return self._field.contains(value) + class FieldPartPseudoPrefix(PseudoPrefix): def __init__(self, name, description, field, part): self._field = field -- cgit v1.2.3