]> git.parisson.com Git - mezzo.git/commitdiff
Rename period date fields, add project status property
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 21 Sep 2016 17:15:06 +0000 (19:15 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 21 Sep 2016 17:15:06 +0000 (19:15 +0200)
app/organization/core/models.py
app/organization/network/management/commands/import-ircam-person-xls.py
app/organization/network/migrations/0021_auto_20160921_1908.py [new file with mode: 0644]
app/organization/projects/migrations/0009_auto_20160921_1908.py [new file with mode: 0644]
app/organization/projects/models.py
lib/django-eve
lib/django-prestashop

index 3d0bb98e3308d845a4112b2c7a54c70cee2fc93b..e31d0d0ef1d2117f43a19365ff4436ed2f7f92b6 100644 (file)
@@ -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
index ea0bddea08cabe492c91bf4039444abb7379eca8..ca0abdc9ade801d6cc1fc711dc61c57288f12242 100644 (file)
@@ -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 (file)
index 0000000..0929f89
--- /dev/null
@@ -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 (file)
index 0000000..6437e01
--- /dev/null
@@ -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',
+        ),
+    ]
index 49bfbfeb9ba72a68d5dab7a17254c01f6e0f10ba..0ac9dcdcf5b7fddf2b2e2119896dab52e1b47ff3 100644 (file)
@@ -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):
 
index cf5caf29cfc9c893a091290a54589789cb0ada7b..aea178e1000f7297ed7a76252518048ab8982276 160000 (submodule)
@@ -1 +1 @@
-Subproject commit cf5caf29cfc9c893a091290a54589789cb0ada7b
+Subproject commit aea178e1000f7297ed7a76252518048ab8982276
index 1b7f9c30776907a7815109ec64f3347ab3c71705..37a97f9affa7979e52b6b0ff7c3bc39ce2c05302 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 1b7f9c30776907a7815109ec64f3347ab3c71705
+Subproject commit 37a97f9affa7979e52b6b0ff7c3bc39ce2c05302