A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Add field 'added' to documents
Erik Arvstedt11db87fa117e
diff --git a/src/documents/admin.py b/src/documents/admin.pyindex 3ce2785b5..39524ae21 100644--- a/src/documents/admin.py+++ b/src/documents/admin.py@@ -125,7 +125,9 @@ class DocumentAdmin(CommonAdmin):}search_fields = ("correspondent__name", "title", "content", "tags__name")- list_display = ("title", "created", "thumbnail", "correspondent", "tags_")+ readonly_fields = ("added",)+ list_display = ("title", "created", "added", "thumbnail", "correspondent",+ "tags_")list_filter = ("tags", "correspondent", FinancialYearFilter,MonthListFilter)diff --git a/src/documents/migrations/0020_document_added.py b/src/documents/migrations/0020_document_added.pynew file mode 100644index 000000000..dbddf80ae--- /dev/null+++ b/src/documents/migrations/0020_document_added.py@@ -0,0 +1,27 @@+# -*- coding: utf-8 -*-+from __future__ import unicode_literals++from django.db import migrations, models+import django.utils.timezone+++def set_added_time_to_created_time(apps, schema_editor):+ Document = apps.get_model("documents", "Document")+ for doc in Document.objects.all():+ doc.added = doc.created+ doc.save()++class Migration(migrations.Migration):++ dependencies = [+ ('documents', '0019_add_consumer_user'),+ ]++ operations = [+ migrations.AddField(+ model_name='document',+ name='added',+ field=models.DateTimeField(db_index=True, default=django.utils.timezone.now, editable=False),+ ),+ migrations.RunPython(set_added_time_to_created_time)+ ]diff --git a/src/documents/models.py b/src/documents/models.pyindex 420afa426..c5239a387 100644--- a/src/documents/models.py+++ b/src/documents/models.py@@ -229,6 +229,8 @@ class Document(models.Model):default=timezone.now, db_index=True)modified = models.DateTimeField(auto_now=True, editable=False, db_index=True)+ added = models.DateTimeField(+ default=timezone.now, editable=False, db_index=True)class Meta(object):ordering = ("correspondent", "title")diff --git a/src/documents/templates/admin/documents/document/change_list_results.html b/src/documents/templates/admin/documents/document/change_list_results.htmlindex cd5f88f0a..5bd5b1aff 100644--- a/src/documents/templates/admin/documents/document/change_list_results.html+++ b/src/documents/templates/admin/documents/document/change_list_results.html@@ -129,24 +129,25 @@{# 0: Checkbox #}{# 1: Title #}{# 2: Date #}- {# 3: Image #}- {# 4: Correspondent #}- {# 5: Tags #}- {# 6: Document edit url #}+ {# 3: Added #}+ {# 4: Image #}+ {# 5: Correspondent #}+ {# 6: Tags #}+ {# 7: Document edit url #}<div class="box"><div class="result">- <div class="header" onclick="location.href='{{ result.6 }}';" style="cursor: pointer;">+ <div class="header" onclick="location.href='{{ result.7 }}';" style="cursor: pointer;"><div class="checkbox">{{ result.0 }}</div><div class="info">- {{ result.4 }}<br />+ {{ result.5 }}<br />{{ result.1 }}</div><div style="clear: both;"></div></div>- <div class="tags">{{ result.5 }}</div>+ <div class="tags">{{ result.6 }}</div><div class="date">{{ result.2 }}</div><div style="clear: both;"></div>- <div class="image">{{ result.3 }}</div>+ <div class="image">{{ result.4 }}</div></div></div>{% endfor %}