Skip to content

Commit

Permalink
Merge pull request #1114 from jefmoura/379-add-reporting-period
Browse files Browse the repository at this point in the history
Remove and add some fields from ReportingPeriod
  • Loading branch information
Rafael Muñoz Cárdenas authored Jul 4, 2018
2 parents c3c6c93 + 70d5bfd commit 38d9581
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
40 changes: 40 additions & 0 deletions indicators/migrations/0012_auto_20180704_0256.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-07-04 09:56
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('workflow', '0025_auto_20180620_0557'),
('indicators', '0011_auto_20180613_0232'),
]

operations = [
migrations.RemoveField(
model_name='reportingperiod',
name='frequency',
),
migrations.RemoveField(
model_name='reportingperiod',
name='organization',
),
migrations.AddField(
model_name='reportingperiod',
name='period',
field=models.CharField(blank=True, help_text=b'Predefined reporting period for a workflowlevel1', max_length=255, null=True),
),
migrations.AddField(
model_name='reportingperiod',
name='sort',
field=models.IntegerField(blank=True, null=True),
),
migrations.AddField(
model_name='reportingperiod',
name='workflowlevel1',
field=models.ForeignKey(blank=True, help_text=b'Related workflowlevel1 or project/program etc.', null=True, on_delete=django.db.models.deletion.CASCADE, to='workflow.WorkflowLevel1'),
),
]
9 changes: 5 additions & 4 deletions indicators/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,18 @@ def save(self, *args, **kwargs):


class ReportingPeriod(models.Model):
frequency = models.ForeignKey(Frequency)
organization = models.ForeignKey(Organization, default=1)
period = models.CharField(max_length=255, blank=True, null=True, help_text="Predefined reporting period for a workflowlevel1")
workflowlevel1 = models.ForeignKey(WorkflowLevel1, null=True, blank=True, help_text="Related workflowlevel1 or project/program etc.")
sort = models.IntegerField(blank=True, null=True)
create_date = models.DateTimeField(null=True, blank=True)
edit_date = models.DateTimeField(null=True, blank=True)

def __unicode__(self):
return self.frequency
return self.period

def save(self, *args, **kwargs):
# onsave add create date or update edit date
if self.create_date == None:
if self.create_date is None:
self.create_date = timezone.now()
self.edit_date = timezone.now()
super(ReportingPeriod, self).save(*args, **kwargs)
Expand Down

0 comments on commit 38d9581

Please sign in to comment.