A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Better created & modified + __str__()
Daniel Quinnb65f9af9cc19
diff --git a/src/documents/migrations/0002_auto_20151226_1316.py b/src/documents/migrations/0002_auto_20151226_1316.pynew file mode 100644index 000000000..5c1a78271--- /dev/null+++ b/src/documents/migrations/0002_auto_20151226_1316.py@@ -0,0 +1,25 @@+# -*- coding: utf-8 -*-+# Generated by Django 1.9 on 2015-12-26 13:16+from __future__ import unicode_literals++from django.db import migrations, models+import django.utils.timezone+++class Migration(migrations.Migration):++ dependencies = [+ ('documents', '0001_initial'),+ ]++ operations = [+ migrations.AlterModelOptions(+ name='document',+ options={'ordering': ('sender', 'title')},+ ),+ migrations.AlterField(+ model_name='document',+ name='created',+ field=models.DateTimeField(default=django.utils.timezone.now, editable=False),+ ),+ ]diff --git a/src/documents/models.py b/src/documents/models.pyindex a1b00e17e..16a45d97e 100644--- a/src/documents/models.py+++ b/src/documents/models.py@@ -1,4 +1,5 @@from django.db import models+from django.utils import timezoneclass Document(models.Model):@@ -6,5 +7,16 @@ class Document(models.Model):sender = models.CharField(max_length=128, blank=True, db_index=True)title = models.CharField(max_length=128, blank=True, db_index=True)content = models.TextField(db_index=True)- created = models.DateTimeField(auto_now_add=True)- modified = models.DateTimeField(auto_now=True)+ created = models.DateTimeField(default=timezone.now, editable=False)+ modified = models.DateTimeField(auto_now=True, editable=False)++ class Meta(object):+ ordering = ("sender", "title")++ def __str__(self):+ created = self.created.strftime("%Y-%m-%d")+ if self.sender and self.title:+ return "{}: {}, {}".format(created, self.sender, self.title)+ if self.sender or self.title:+ return "{}: {}, {}".format(created, self.sender or self.title)+ return str(created)