My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 41 attachment: site.patch (3.0 KB)

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# HG changeset patch
# User jibaku
# Date 1225369922 -3600
# Branch trunk
# Node ID 4d32f531dc7bf253f1238e576171b0b6fdfa2e3e
# Parent da7231dbf8888d2d7219e6fd60ecb0600995ffc8
django-forum is now site-aware

diff -r da7231dbf888 -r 4d32f531dc7b admin.py
--- a/admin.py Thu Oct 30 13:17:07 2008 +0100
+++ b/admin.py Thu Oct 30 13:32:02 2008 +0100
@@ -2,8 +2,10 @@
from forum.models import Forum, Thread, Post, Subscription

class ForumAdmin(admin.ModelAdmin):
- list_display = ('title', '_parents_repr')
+ list_display = ('title', '_parents_repr', 'site')
+ list_filter = ('site',)
ordering = ['parent', 'title']
+ prepopulated_fields = {"slug": ("title",)}

class SubscriptionAdmin(admin.ModelAdmin):
list_display = ['author','thread']
diff -r da7231dbf888 -r 4d32f531dc7b models.py
--- a/models.py Thu Oct 30 13:17:07 2008 +0100
+++ b/models.py Thu Oct 30 13:32:02 2008 +0100
@@ -4,13 +4,17 @@
Just about all logic required for smooth updates is in the save()
methods. A little extra logic is in views.py.
"""
+import datetime

from django.db import models
-import datetime
-from django.contrib.auth.models import User
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
+
+from django.contrib.auth.models import User
+from django.contrib.sites.models import Site
+
from forum.managers import ThreadManager
+from django.contrib.sites.managers import CurrentSiteManager

class Forum(models.Model):
"""
@@ -27,6 +31,10 @@
description = models.TextField(_("Description"))
threads = models.IntegerField(_("Threads"), default=0)
posts = models.IntegerField(_("Posts"), default=0)
+ site = models.ForeignKey(Site)
+
+ objects = models.Manager()
+ on_site = CurrentSiteManager()

def _get_forum_latest_post(self):
"""This gets the latest post for the forum"""
diff -r da7231dbf888 -r 4d32f531dc7b urls.py
--- a/urls.py Thu Oct 30 13:17:07 2008 +0100
+++ b/urls.py Thu Oct 30 13:32:02 2008 +0100
@@ -14,7 +14,7 @@
from forum.feeds import RssForumFeed, AtomForumFeed

forum_dict = {
- 'queryset' : Forum.objects.filter(parent__isnull=True),
+ 'queryset' : Forum.on_site.filter(parent__isnull=True),
}

feed_dict = {
diff -r da7231dbf888 -r 4d32f531dc7b views.py
--- a/views.py Thu Oct 30 13:17:07 2008 +0100
+++ b/views.py Thu Oct 30 13:32:02 2008 +0100
@@ -29,7 +29,7 @@

Only allows a user to post if they're logged in.
"""
- forum = get_object_or_404(Forum, slug=slug)
+ forum = get_object_or_404(Forum.on_site, slug=slug)

if request.method == 'POST' and request.user.is_authenticated():
form = CreateThreadForm(request.POST)
@@ -178,7 +178,7 @@
if not request.user.is_authenticated():
return HttpResponseForbidden(_('Sorry, you need to login.'))

- subs = Subscription.objects.filter(author=request.user)
+ subs = Subscription.objects.filter(author=request.user).filter(thread__forum__site__id=settings.SITE_ID)

if request.POST:
# remove the subscriptions that haven't been checked.
Powered by Google Project Hosting