root/lib/sct/sphenecoll/sphene/sphblog/models.py

Revision 147:942e3ce3d7d2, 1.8 kB (checked in by Daniele Varrazzo <piro@develer.com>, 1 year ago)

Sphene package updated to r803.

Line 
1 # blog models
2
3
4 from django.db import models
5
6 from sphene.community.models import tag_get_labels
7 from sphene.community.sphutils import sphpermalink
8 from sphene.community.middleware import get_current_request
9
10 from sphene.sphboard.models import Post, Category
11
12 BLOG_POST_STATUS_CHOICES = (
13     (1, 'Draft'),
14     (2, 'Published'),
15     (3, 'Hidden'),
16     )
17
18 class BlogPostExtension(models.Model):
19     """
20     Extension to a forum post - but actually only applicable for
21     threads not posts.
22     """
23     post = models.ForeignKey(Post, unique = True)
24     # The status is basically just for usability ..
25     # It is just important that this info gets populated to the Posts 'is_hidden' attribute.
26     status = models.IntegerField( choices = BLOG_POST_STATUS_CHOICES )
27     slug = models.CharField( max_length = 250, unique = True, db_index = True)
28
29     def get_tag_labels(self):
30         return tag_get_labels(self.post)
31
32     def get_absolute_url(self):
33         post = self.post
34         date = post.postdate
35         return ('sphene.sphblog.views.show_thread', (), { 'groupName': post.category.group.name,
36                                                           'year': date.year,
37                                                           'month': date.month,
38                                                           'day': date.day,
39                                                           'slug': self.slug,
40                                                           })
41     get_absolute_url = sphpermalink(get_absolute_url)
42
43
44
45 class BlogCategoryConfig(models.Model):
46     """
47     Extended configuration for a Blog category.
48     """
49     category = models.ForeignKey( Category, unique = True )
50
51     enable_googleblogping = models.BooleanField(help_text = "Enable ping to blogsearch.google.com ?")
52
53
Note: See TracBrowser for help on using the browser.