]> git.parisson.com Git - mezzo.git/commitdiff
mv module institute to organization, fix some FKs
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Mon, 27 Jun 2016 11:57:35 +0000 (13:57 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Mon, 27 Jun 2016 11:57:35 +0000 (13:57 +0200)
app/organization/models.py
app/project/models.py
app/settings.py

index 650551f6a255029c0d78233556e19ed51214f4a4..0d13ac18d69bd7a38120142d6d4461a1b1508986 100644 (file)
@@ -13,6 +13,7 @@ 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 django.contrib.auth.models import User
 
 from mezzanine.core.models import RichText, Displayable, Slugged
 from mezzanine.core.fields import RichTextField, OrderField, FileField
@@ -37,7 +38,7 @@ TITLE_CHOICES = [
 ALIGNMENT_CHOICES = (('left', _('left')), ('right', _('right')))
 
 
-class BaseNameModel(models.model):
+class BaseNameModel(models.Model):
     """Base object with name and description"""
 
     name = models.CharField(_('name'), max_length=512)
@@ -83,7 +84,7 @@ class OrganizationType(models.Model):
 class Department(BaseNameModel):
     """(Department description)"""
 
-    organization = models.ForeignKey('Organization', verbose_name=_('organization'), on_delete=models.SET_NULL)
+    organization = models.ForeignKey('Organization', verbose_name=_('organization'))
     domain = models.CharField(_('domain'), max_length=255, blank=True)
 
     def __unicode__(self):
@@ -96,7 +97,7 @@ class Department(BaseNameModel):
 class Team(BaseNameModel):
     """(Team description)"""
 
-    department = models.ForeignKey('Department', verbose_name=_('department'), on_delete=models.SET_NULL)
+    department = models.ForeignKey('Department', verbose_name=_('department'), blank=True, null=True, on_delete=models.SET_NULL)
 
     def __unicode__(self):
         return u"Team"
@@ -105,9 +106,9 @@ class Team(BaseNameModel):
 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)
-    first_name = models.CharField(_('first name'), max_length=255, blank=True, null=True, help="If no User linked")
+    user = models.ForeignKey(User, verbose_name=_('user'), blank=True, null=True, on_delete=models.SET_NULL)
+    person_title = models.CharField(_('Title'), max_length=16, choices=TITLE_CHOICES, blank=True)
+    first_name = models.CharField(_('first name'), max_length=255, blank=True, null=True)
     last_name = models.CharField(_('last name'), max_length=255, blank=True, null=True)
     organization = models.ForeignKey('Organization', verbose_name=_('organization'), blank=True, null=True, on_delete=models.SET_NULL)
     bio = RichTextField(_('biography'), blank=True)
@@ -117,7 +118,6 @@ class Person(Displayable, RichText, AdminThumbMixin):
     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)
-    link = models.URLField(_('Link'), blank=True, null=True)
 
     def __unicode__(self):
         return ' '.join((self.user.first_name, self.user.last_name))
@@ -126,15 +126,15 @@ class Person(Displayable, RichText, AdminThumbMixin):
 class Link(models.Model):
     """A person can have many links."""
 
-    person = models.ForeignKey(Person, verbose_name=_('Person'))
-    link_type = models.ForeignKey(LinkType, verbose_name=_('Link type'))
+    person = models.ForeignKey('Person', verbose_name=_('Person'))
+    link_type = models.ForeignKey('LinkType', verbose_name=_('Link type'))
     url = models.URLField(verbose_name=_('URL'))
 
     def __str__(self):
         return self.url
 
 
-class LinkType(TranslatableModel):
+class LinkType(models.Model):
     """
     A link type could be ``Facebook`` or ``Twitter`` or ``Website``.
     This is masterdata that should be created by the admins when the site is
@@ -162,7 +162,7 @@ class LinkType(TranslatableModel):
 class Activity(models.Model):
     """(Activity description)"""
 
-    person = models.ForeignKey('Person', verbose_name=_('person'), on_delete=models.SET_NULL)
+    person = models.ForeignKey('Person', verbose_name=_('person'))
     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)
index ef1e267e74d1947d61a155f4ee3c4899bfab161b..1fe139b080318d789e81b4029f36d6f9994a124e 100644 (file)
@@ -5,12 +5,11 @@ from django.db import models
 from organization import Person
 
 
-
-
 class Project(Displayable, RichText):
     """(Project description)"""
 
     persons = models.ManyToManyField('Person', verbose_name=_('persons'))
+    partners = models.ManyToManyField('Organization', verbose_name=_('organizations'))
 
     def __unicode__(self):
-        return title
+        return self.title
index 4460d6a8277b38dc2ad9cf29586dc4f090b227e9..553bcc29392bf6b23d6c3dc6891322e3f284a646 100644 (file)
@@ -219,7 +219,7 @@ INSTALLED_APPS = [
     "meta",
     "mezzanine_agenda",
     "festival",
-    "institute",
+    "organization",
 ]
 
 # Add Migration Module path see : https://github.com/stephenmcd/mezzanine/blob/master/docs/model-customization.rst#field-injection-caveats