diff --git a/beat/web/reports/migrations/0003_report_last_edited_date.py b/beat/web/reports/migrations/0003_report_last_edited_date.py new file mode 100644 index 0000000000000000000000000000000000000000..35e29a56ff414ca3ff236558c676362ef1c772bd --- /dev/null +++ b/beat/web/reports/migrations/0003_report_last_edited_date.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2017-03-13 15:11 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('reports', '0002_report_expiration_date'), + ] + + operations = [ + migrations.AddField( + model_name='report', + name='last_edited_date', + field=models.DateTimeField(null=True), + ), + ] diff --git a/beat/web/reports/models.py b/beat/web/reports/models.py index cd2222490532fd7abb4c4ad5ec6161b976a5f512..e8eb282c14b1196baa56465ca8a4c13ba51881f0 100644 --- a/beat/web/reports/models.py +++ b/beat/web/reports/models.py @@ -59,6 +59,7 @@ class ReportManager(models.Manager): else: report.content = content report.creation_date = datetime.now() + report.last_edited_date = datetime.now() report.publication_date = None report.expiration_date = None report.status = self.model.EDITABLE @@ -108,6 +109,7 @@ class Report(models.Model): author = models.ForeignKey(User, related_name='%(class)ss') experiments = models.ManyToManyField(Experiment, related_name='reports', blank=True) creation_date = models.DateTimeField() + last_edited_date = models.DateTimeField(null=True) expiration_date = models.DateTimeField(null=True, blank=True) publication_date = models.DateTimeField(null=True, blank=True) short_description = models.CharField(max_length=100, default='', blank=True, help_text=Messages['short_description']) @@ -192,6 +194,8 @@ class Report(models.Model): report_content = json.loads(self.content) report_content_charts = dict(filter(lambda item: item[0].startswith("chart"),report_content.iteritems())) + self.last_edited_date = datetime.now() + super(Report, self).save(*args, **kwargs) self.referenced_plotters.clear() diff --git a/beat/web/reports/templates/reports/report.html b/beat/web/reports/templates/reports/report.html index 881a92421462aeb2e7f67b4a4e19abc2d125b531..34c89ff217846848dd2329d11f74d38f14c38ace 100644 --- a/beat/web/reports/templates/reports/report.html +++ b/beat/web/reports/templates/reports/report.html @@ -171,12 +171,12 @@ {% else %} <i class="fa fa-calendar-o"></i> Created: <strong>{{ report.creation_date|naturaltime }}</strong><br/> {% endif %} +{% if report.last_edited_date != None %} +<i class="fa fa-calendar-o"></i> Last Edited: <strong>{{ report.last_edited_date|naturaltime }}</strong><br/> +{% endif %} {% if status == 'Editable' %} <i class="fa fa-warning"></i> This report is <strong class="text-danger">{{ status }}</strong> (it may change in time)<br/> -{% if owner %} -<i class="fa fa-code"></i> Analyzer: <strong><a target="_blank" href="{{ report.analyzer.get_absolute_url }}" title="View analyzer in a new window">{{ report.analyzer.fullname }}</a></strong><br/> -{% endif %} {% elif status == 'Locked' %} <i class="fa fa-warning"></i> This report is <strong class="text-warning">{{ status }}</strong> (not yet published)<br/> <i class="fa fa-calendar-o"></i> Expires in <strong>{{ report.expiration_date|naturaltime }}</strong>, on {{ report.expiration_date }} (publish it to make it permanent)<br/>