]> git.parisson.com Git - mezzo.git/commitdiff
add first organization models
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 23 Jun 2016 16:25:24 +0000 (18:25 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 23 Jun 2016 16:25:24 +0000 (18:25 +0200)
14 files changed:
app/institute/__init__.py [deleted file]
app/institute/admin.py [deleted file]
app/institute/apps.py [deleted file]
app/institute/migrations/__init__.py [deleted file]
app/institute/models.py [deleted file]
app/institute/tests.py [deleted file]
app/institute/views.py [deleted file]
app/organization/__init__.py [new file with mode: 0644]
app/organization/admin.py [new file with mode: 0644]
app/organization/apps.py [new file with mode: 0644]
app/organization/migrations/__init__.py [new file with mode: 0644]
app/organization/models.py [new file with mode: 0644]
app/organization/tests.py [new file with mode: 0644]
app/organization/views.py [new file with mode: 0644]

diff --git a/app/institute/__init__.py b/app/institute/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/app/institute/admin.py b/app/institute/admin.py
deleted file mode 100644 (file)
index 8c38f3f..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-from django.contrib import admin
-
-# Register your models here.
diff --git a/app/institute/apps.py b/app/institute/apps.py
deleted file mode 100644 (file)
index e81c8df..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-from __future__ import unicode_literals
-
-from django.apps import AppConfig
-
-
-class InstituteConfig(AppConfig):
-    name = 'institute'
diff --git a/app/institute/migrations/__init__.py b/app/institute/migrations/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/app/institute/models.py b/app/institute/models.py
deleted file mode 100644 (file)
index bd4b2ab..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-from __future__ import unicode_literals
-
-from django.db import models
-
-# Create your models here.
diff --git a/app/institute/tests.py b/app/institute/tests.py
deleted file mode 100644 (file)
index 7ce503c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-from django.test import TestCase
-
-# Create your tests here.
diff --git a/app/institute/views.py b/app/institute/views.py
deleted file mode 100644 (file)
index 91ea44a..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-from django.shortcuts import render
-
-# Create your views here.
diff --git a/app/organization/__init__.py b/app/organization/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/app/organization/admin.py b/app/organization/admin.py
new file mode 100644 (file)
index 0000000..8c38f3f
--- /dev/null
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/app/organization/apps.py b/app/organization/apps.py
new file mode 100644 (file)
index 0000000..3fd95b4
--- /dev/null
@@ -0,0 +1,7 @@
+from __future__ import unicode_literals
+
+from django.apps import AppConfig
+
+
+class OrganizationConfig(AppConfig):
+    name = 'organization'
diff --git a/app/organization/migrations/__init__.py b/app/organization/migrations/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/app/organization/models.py b/app/organization/models.py
new file mode 100644 (file)
index 0000000..665740f
--- /dev/null
@@ -0,0 +1,133 @@
+from __future__ import unicode_literals
+
+import os
+import re
+import pwd
+import time
+import urllib
+import string
+import datetime
+import mimetypes
+
+from django.db import models
+from django.utils.translation import ugettext_lazy as _
+from django.core.urlresolvers import reverse, reverse_lazy
+from django.conf import settings
+
+from mezzanine.core.models import RichText, Displayable, Slugged
+from mezzanine.core.fields import RichTextField, OrderField, FileField
+from mezzanine.utils.models import AdminThumbMixin, upload_to
+
+
+# Hack to have these strings translated
+mr = _('Mr')
+mrs = _('Ms')
+
+GENDER_CHOICES = [
+    ('male', _('male')),
+    ('female', _('female')),
+]
+
+TITLE_CHOICES = [
+    ('Dr', _('Dr')),
+    ('Prof', _('Prof')),
+    ('Prof Dr', _('Prof Dr')),
+]
+
+ALIGNMENT_CHOICES = (('left', _('left')), ('right', _('right')))
+
+
+class BaseNameModel(models.model):
+    """Base object with name and description"""
+
+    name = models.CharField(_('name'), max_length=512)
+    description = models.TextField(_('description'), blank=True)
+
+    class Meta:
+        abstract = True
+
+    def __unicode__(self):
+        return self.name
+
+
+class Organization(BaseNameModel):
+    """(Organization description)"""
+
+    address = models.TextField(_('description'), blank=True)
+    domain = models.CharField(_('domain'), max_length=255, blank=True)
+    organization_type = models.ForeignKey('OrganizationType', verbose_name=_('organization type'), blank=True, null=True, on_delete=models.SET_NULL)
+
+    def __unicode__(self):
+        return self.name
+
+    class Meta:
+        verbose_name = _('organization')
+
+
+class OrganizationType(models.Model):
+    """(OrganizationType description)"""
+
+    type = models.CharField(_('type'), max_length=255)
+
+    def __unicode__(self):
+        return self.type
+
+    class Meta:
+        verbose_name = _('organization type')
+
+
+class Department(BaseNameModel):
+    """(Department description)"""
+
+    organization = models.ForeignKey('Organization', verbose_name=_('organization'), on_delete=models.SET_NULL)
+    domain = models.CharField(_('domain'), max_length=255, blank=True)
+
+    def __unicode__(self):
+        return self.name
+
+    @property
+    def slug(self):
+        return slugify(self.__unicode__())
+
+    class Meta:
+        verbose_name = _('department')
+
+
+class Team(BaseNameModel):
+    """(Team description)"""
+
+    department = models.ForeignKey('Department', verbose_name=_('department'), on_delete=models.SET_NULL)
+
+    def __unicode__(self):
+        return u"Team"
+
+
+class Person(Displayable, RichText, AdminThumbMixin):
+    """(Person description)"""
+
+    user = models.ForeignKey('User', verbose_name=_('user'), blank=True, null=True, on_delete=models.SET_NULL)
+    title = models.CharField(_('Title'), max_length=16, choices=TITLE_CHOICES, blank=True)
+    bio = RichTextField(_('biography'), blank=True)
+    photo = FileField(_('photo'), upload_to='images/photos', max_length=1024, blank=True, format="Image")
+    photo_credits = models.CharField(_('photo credits'), max_length=255, blank=True, null=True)
+    photo_alignment = models.CharField(_('photo alignment'), choices=ALIGNMENT_CHOICES, max_length=32, default="left", blank=True)
+    photo_description = models.TextField(_('photo description'), blank=True)
+    photo_featured = FileField(_('photo featured'), upload_to='images/photos', max_length=1024, blank=True, format="Image")
+    photo_featured_credits = models.CharField(_('photo featured credits'), max_length=255, blank=True, null=True)
+
+    def __unicode__(self):
+        return ' '.join((self.user.first_name, self.user.last_name))
+
+
+class Activity(models.Model):
+    """(Activity description)"""
+
+    person = models.ForeignKey('Person', verbose_name=_('person'), on_delete=models.SET_NULL)
+    teams = models.ManyToManyField('Team', verbose_name=_('teams'))
+    date_begin = models.DateField(_('begin date'), null=True, blank=True)
+    date_end = models.DateField(_('end date'), null=True, blank=True)
+    role = models.CharField(_('role'), blank=True, max_length=512)
+    work = models.TextField(_('work'), blank=True)
+
+    def __unicode__(self):
+        return ' - '.join((self.person, self.role, self.date_begin, self.date_end))
diff --git a/app/organization/tests.py b/app/organization/tests.py
new file mode 100644 (file)
index 0000000..7ce503c
--- /dev/null
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/app/organization/views.py b/app/organization/views.py
new file mode 100644 (file)
index 0000000..91ea44a
--- /dev/null
@@ -0,0 +1,3 @@
+from django.shortcuts import render
+
+# Create your views here.