Skip to content
Snippets Groups Projects
Commit 82895d8c authored by Jaden Diefenbaugh's avatar Jaden Diefenbaugh
Browse files

add last_edited_date to report model & view, add migration, rm ana from view

parent 12b5c937
No related branches found
No related tags found
1 merge request!223Reports overhaul
# -*- 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),
),
]
...@@ -59,6 +59,7 @@ class ReportManager(models.Manager): ...@@ -59,6 +59,7 @@ class ReportManager(models.Manager):
else: else:
report.content = content report.content = content
report.creation_date = datetime.now() report.creation_date = datetime.now()
report.last_edited_date = datetime.now()
report.publication_date = None report.publication_date = None
report.expiration_date = None report.expiration_date = None
report.status = self.model.EDITABLE report.status = self.model.EDITABLE
...@@ -108,6 +109,7 @@ class Report(models.Model): ...@@ -108,6 +109,7 @@ class Report(models.Model):
author = models.ForeignKey(User, related_name='%(class)ss') author = models.ForeignKey(User, related_name='%(class)ss')
experiments = models.ManyToManyField(Experiment, related_name='reports', blank=True) experiments = models.ManyToManyField(Experiment, related_name='reports', blank=True)
creation_date = models.DateTimeField() creation_date = models.DateTimeField()
last_edited_date = models.DateTimeField(null=True)
expiration_date = models.DateTimeField(null=True, blank=True) expiration_date = models.DateTimeField(null=True, blank=True)
publication_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']) short_description = models.CharField(max_length=100, default='', blank=True, help_text=Messages['short_description'])
...@@ -192,6 +194,8 @@ class Report(models.Model): ...@@ -192,6 +194,8 @@ class Report(models.Model):
report_content = json.loads(self.content) report_content = json.loads(self.content)
report_content_charts = dict(filter(lambda item: item[0].startswith("chart"),report_content.iteritems())) 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) super(Report, self).save(*args, **kwargs)
self.referenced_plotters.clear() self.referenced_plotters.clear()
......
...@@ -171,12 +171,12 @@ ...@@ -171,12 +171,12 @@
{% else %} {% else %}
<i class="fa fa-calendar-o"></i> Created: <strong>{{ report.creation_date|naturaltime }}</strong><br/> <i class="fa fa-calendar-o"></i> Created: <strong>{{ report.creation_date|naturaltime }}</strong><br/>
{% endif %} {% 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' %} {% if status == 'Editable' %}
<i class="fa fa-warning"></i> This report is <strong class="text-danger">{{ status }}</strong> (it may change in time)<br/> <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' %} {% 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-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/> <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/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment