Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Commit

Permalink
Merge branch 'erikarvstedt-document_field_added'
Browse files Browse the repository at this point in the history
  • Loading branch information
danielquinn committed Jun 1, 2018
2 parents f2cf3a6 + 9173bca commit c94f4dc
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/documents/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ class Media:
}

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)

Expand Down
27 changes: 27 additions & 0 deletions src/documents/migrations/0020_document_added.py
Original file line number Diff line number Diff line change
@@ -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)
]
2 changes: 2 additions & 0 deletions src/documents/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down

0 comments on commit c94f4dc

Please sign in to comment.