From 31fbd85a02a61274f2f15a54a8f5357f61870093 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Wed, 21 Sep 2016 19:15:06 +0200 Subject: [PATCH] Rename period date fields, add project status property --- app/organization/core/models.py | 4 +-- .../commands/import-ircam-person-xls.py | 4 +-- .../migrations/0021_auto_20160921_1908.py | 25 +++++++++++++++++++ .../migrations/0009_auto_20160921_1908.py | 25 +++++++++++++++++++ app/organization/projects/models.py | 9 +++++++ lib/django-eve | 2 +- lib/django-prestashop | 2 +- 7 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 app/organization/network/migrations/0021_auto_20160921_1908.py create mode 100644 app/organization/projects/migrations/0009_auto_20160921_1908.py diff --git a/app/organization/core/models.py b/app/organization/core/models.py index 3d0bb98e..e31d0d0e 100644 --- a/app/organization/core/models.py +++ b/app/organization/core/models.py @@ -172,8 +172,8 @@ class Link(URL): class Period(models.Model): - date_begin = models.DateField(_('begin date'), null=True, blank=True) - date_end = models.DateField(_('end date'), null=True, blank=True) + date_from = models.DateField(_('begin date'), null=True, blank=True) + date_to = models.DateField(_('end date'), null=True, blank=True) class Meta: abstract = True diff --git a/app/organization/network/management/commands/import-ircam-person-xls.py b/app/organization/network/management/commands/import-ircam-person-xls.py index ea0bddea..ca0abdc9 100644 --- a/app/organization/network/management/commands/import-ircam-person-xls.py +++ b/app/organization/network/management/commands/import-ircam-person-xls.py @@ -123,8 +123,8 @@ class IrcamPerson(object): return None def get_activity(self): - self.activity.date_begin = datetime.datetime(*xlrd.xldate_as_tuple(self.row[4].value, self.datemode)) if self.row[4].value else None - self.activity.date_end = datetime.datetime(*xlrd.xldate_as_tuple(self.row[5].value, self.datemode)) if self.row[5].value else None + self.activity.date_from = datetime.datetime(*xlrd.xldate_as_tuple(self.row[4].value, self.datemode)) if self.row[4].value else None + self.activity.date_to = datetime.datetime(*xlrd.xldate_as_tuple(self.row[5].value, self.datemode)) if self.row[5].value else None try: self.activity.weeks = int(self.row[6].value) if self.row[6].value else None except: diff --git a/app/organization/network/migrations/0021_auto_20160921_1908.py b/app/organization/network/migrations/0021_auto_20160921_1908.py new file mode 100644 index 00000000..0929f899 --- /dev/null +++ b/app/organization/network/migrations/0021_auto_20160921_1908.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-09-21 17:08 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('organization-network', '0020_auto_20160921_1043'), + ] + + operations = [ + migrations.RenameField( + model_name='personactivity', + old_name='date_begin', + new_name='date_from', + ), + migrations.RenameField( + model_name='personactivity', + old_name='date_end', + new_name='date_to', + ), + ] diff --git a/app/organization/projects/migrations/0009_auto_20160921_1908.py b/app/organization/projects/migrations/0009_auto_20160921_1908.py new file mode 100644 index 00000000..6437e017 --- /dev/null +++ b/app/organization/projects/migrations/0009_auto_20160921_1908.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-09-21 17:08 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('organization-projects', '0008_auto_20160916_1835'), + ] + + operations = [ + migrations.RenameField( + model_name='project', + old_name='date_begin', + new_name='date_from', + ), + migrations.RenameField( + model_name='project', + old_name='date_end', + new_name='date_to', + ), + ] diff --git a/app/organization/projects/models.py b/app/organization/projects/models.py index 49bfbfeb..0ac9dcdc 100644 --- a/app/organization/projects/models.py +++ b/app/organization/projects/models.py @@ -36,6 +36,15 @@ class Project(Displayable, Period, RichText): def get_absolute_url(self): return reverse("organization-project-detail", kwargs={"slug": self.slug}) + @property + def status(self): + if datetime.date.today() >= self.date_from and datetime.date.today() <= self.date_to: + return _('in progress') + elif datetime.date.today() < self.date_from and datetime.date.today() < self.date_to: + return _('pending') + elif datetime.date.today() > self.date_to and datetime.date.today() > self.date_to: + return _('completed') + class ProjectTopic(Named): diff --git a/lib/django-eve b/lib/django-eve index cf5caf29..aea178e1 160000 --- a/lib/django-eve +++ b/lib/django-eve @@ -1 +1 @@ -Subproject commit cf5caf29cfc9c893a091290a54589789cb0ada7b +Subproject commit aea178e1000f7297ed7a76252518048ab8982276 diff --git a/lib/django-prestashop b/lib/django-prestashop index 1b7f9c30..37a97f9a 160000 --- a/lib/django-prestashop +++ b/lib/django-prestashop @@ -1 +1 @@ -Subproject commit 1b7f9c30776907a7815109ec64f3347ab3c71705 +Subproject commit 37a97f9affa7979e52b6b0ff7c3bc39ce2c05302 -- 2.39.5