1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
import datetime
from django.contrib.auth.models import User
from django.db import models
from sorl.thumbnail import ImageField
from utils import render_creole
class Project(models.Model):
"""A project.
"""
name = models.CharField('Name', max_length=100)
slug = models.SlugField('Slug', unique=True)
description = models.TextField('Beschreibung',
help_text='Es kann <a href="http://wikicreole.org/" target="blank">Creole als Markup</a> benutzt werden.')
description_html = models.TextField(editable=False)
contact_email = models.EmailField('E-Mail', blank=True)
contact_url = models.URLField('URL', blank=True)
contact_user = models.ForeignKey(User, verbose_name='Ansprechpartner')
image = ImageField('Bild', upload_to='projects', blank=True)
date_created = models.DateTimeField('Erstellungsdatum', editable=False)
date_updated = models.DateTimeField('Aktualisierungsdatum', editable=False)
class Meta:
ordering = ['name']
verbose_name = 'Projekt'
verbose_name_plural = 'Projekte'
def __unicode__(self):
return self.name
def save(self, *args, **kwargs):
if not self.id:
self.date_created = datetime.datetime.now()
self.date_updated = datetime.datetime.now()
self.description_html = render_creole(self.description)
return super(Project, self).save(*args, **kwargs)
@models.permalink
def get_absolute_url(self):
return ('projects_detail', (), {'slug': self.slug})
|