From a81fe45f2d5635046bb0651a0a05e373bc6ce107 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 23 Jun 2016 18:48:28 +0200 Subject: [PATCH] add Topic and Category --- app/organization/models.py | 29 +++++++++++++++++++++++++---- app/project/models.py | 2 -- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/organization/models.py b/app/organization/models.py index 665740f9..6edb0dba 100644 --- a/app/organization/models.py +++ b/app/organization/models.py @@ -49,6 +49,10 @@ class BaseNameModel(models.model): def __unicode__(self): return self.name + @property + def slug(self): + return slugify(self.__unicode__()) + class Organization(BaseNameModel): """(Organization description)""" @@ -85,10 +89,6 @@ class Department(BaseNameModel): def __unicode__(self): return self.name - @property - def slug(self): - return slugify(self.__unicode__()) - class Meta: verbose_name = _('department') @@ -107,6 +107,7 @@ class Person(Displayable, RichText, AdminThumbMixin): 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) + organization = models.ForeignKey('Organization', verbose_name=_('organization'), blank=True, null=True, on_delete=models.SET_NULL) 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) @@ -131,3 +132,23 @@ class Activity(models.Model): def __unicode__(self): return ' - '.join((self.person, self.role, self.date_begin, self.date_end)) + + +class Category(BaseNameModel): + """(Category description)""" + + class Meta: + verbose_name = _('category') + + def __unicode__(self): + return self.name + + +class Topic(BaseNameModel): + """(Topic description)""" + + class Meta: + verbose_name = _('topic') + + def __unicode__(self): + return self.name diff --git a/app/project/models.py b/app/project/models.py index bd4b2abe..0d091e53 100644 --- a/app/project/models.py +++ b/app/project/models.py @@ -1,5 +1,3 @@ from __future__ import unicode_literals from django.db import models - -# Create your models here. -- 2.39.5