amschaal / glims

3 stars 0 forks source link

Add "Modified" Column to Projects #42

Closed monicabritton closed 6 years ago

monicabritton commented 6 years ago

Add a column to Projects page for "Date Modified". This should be the latest date in the Log, or the creation date if there are no entries in the log.

amschaal commented 6 years ago

Make sure to optionally list it on projects list

amschaal commented 6 years ago

This script updates the db based on logs or project creation date... whichever is later:

from glims.models import Project
from logger.models import Log
from django.contrib.contenttypes.models import ContentType
ct = ContentType.objects.get_for_model(Project)
for p in Project.objects.all():
  log = Log.objects.filter(content_type=ct,object_id=p.id).order_by('-created').first()
  if log:
    modified = log.created
  else:
    modified = p.created
  Project.objects.filter(id=p.id).update(modified=modified)
amschaal commented 6 years ago

Done, changes are live.