From 55c97022239dad2b9b37c4842d036d6b3c3cdceb Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 23 Jun 2016 22:58:25 +0200 Subject: [PATCH] add links, start project, add magazine module --- app/magazine/__init__.py | 0 app/magazine/admin.py | 3 +++ app/magazine/apps.py | 7 ++++++ app/magazine/migrations/__init__.py | 0 app/magazine/models.py | 5 ++++ app/magazine/tests.py | 3 +++ app/magazine/views.py | 3 +++ app/organization/models.py | 39 +++++++++++++++++++++++++++++ app/project/models.py | 13 ++++++++++ 9 files changed, 73 insertions(+) create mode 100644 app/magazine/__init__.py create mode 100644 app/magazine/admin.py create mode 100644 app/magazine/apps.py create mode 100644 app/magazine/migrations/__init__.py create mode 100644 app/magazine/models.py create mode 100644 app/magazine/tests.py create mode 100644 app/magazine/views.py diff --git a/app/magazine/__init__.py b/app/magazine/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/app/magazine/admin.py b/app/magazine/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/app/magazine/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/app/magazine/apps.py b/app/magazine/apps.py new file mode 100644 index 00000000..f4f5391b --- /dev/null +++ b/app/magazine/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class MagazineConfig(AppConfig): + name = 'magazine' diff --git a/app/magazine/migrations/__init__.py b/app/magazine/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/app/magazine/models.py b/app/magazine/models.py new file mode 100644 index 00000000..bd4b2abe --- /dev/null +++ b/app/magazine/models.py @@ -0,0 +1,5 @@ +from __future__ import unicode_literals + +from django.db import models + +# Create your models here. diff --git a/app/magazine/tests.py b/app/magazine/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/app/magazine/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/app/magazine/views.py b/app/magazine/views.py new file mode 100644 index 00000000..91ea44a2 --- /dev/null +++ b/app/magazine/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/app/organization/models.py b/app/organization/models.py index 6edb0dba..650551f6 100644 --- a/app/organization/models.py +++ b/app/organization/models.py @@ -107,6 +107,8 @@ 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) + first_name = models.CharField(_('first name'), max_length=255, blank=True, null=True, help="If no User linked") + 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) photo = FileField(_('photo'), upload_to='images/photos', max_length=1024, blank=True, format="Image") @@ -115,11 +117,48 @@ 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)) +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')) + url = models.URLField(verbose_name=_('URL')) + + def __str__(self): + return self.url + + +class LinkType(TranslatableModel): + """ + A link type could be ``Facebook`` or ``Twitter`` or ``Website``. + This is masterdata that should be created by the admins when the site is + deployed for the first time. + :ordering: Enter numbers here if you want links to be displayed in a + special order. + """ + + name=models.CharField(max_length=256, verbose_name=_('Name')) + slug = models.SlugField(max_length=256, verbose_name=_('Slug'), help_text=_( + 'Use this field to define a simple identifier that can be used' + ' to style the different link types (i.e. assign social media' + ' icons to them)'), + blank=True, + ) + ordering = models.PositiveIntegerField(verbose_name=_('Ordering'), null=True, blank=True) + + class Meta: + ordering = ['ordering', ] + + def __str__(self): + return self.name + + class Activity(models.Model): """(Activity description)""" diff --git a/app/project/models.py b/app/project/models.py index 0d091e53..ef1e267e 100644 --- a/app/project/models.py +++ b/app/project/models.py @@ -1,3 +1,16 @@ from __future__ import unicode_literals from django.db import models + +from organization import Person + + + + +class Project(Displayable, RichText): + """(Project description)""" + + persons = models.ManyToManyField('Person', verbose_name=_('persons')) + + def __unicode__(self): + return title -- 2.39.5