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 3 attachment: forum_base.diff (2.7 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
Index: urls.py
===================================================================
--- urls.py (revision 9)
+++ urls.py (working copy)
@@ -9,17 +9,15 @@

"""

+from django.conf import settings
from django.conf.urls.defaults import *
-from djangoforum.models import Forum

-forum_dict = {
- 'queryset' : Forum.objects.all(),
-}
+if settings.FORUM_BASE == '':
+ forum_regex = '^'
+else:
+ forum_regex = '^' + settings.FORUM_BASE[1:] + '/'

urlpatterns = patterns('',
- (r'^$', 'django.views.generic.list_detail.object_list', forum_dict),
- (r'^(?P<slug>[A-Za-z0-9-_]+)/$', 'djangoforum.views.forum'),
- (r'^(?P<forum>[A-Za-z0-9-_]+)/(?P<thread>[0-9]+)/$', 'djangoforum.views.thread'),
- (r'^(?P<forum>[A-Za-z0-9-_]+)/new/$', 'djangoforum.views.newthread'),
- (r'^(?P<forum>[A-Za-z0-9-_]+)/(?P<thread>[0-9]+)/reply/$', 'djangoforum.views.reply'),
+ (r'^admin/', include('django.contrib.admin.urls')),
+ (forum_regex, include('djangoforum.forum_urls')),
)
Index: forum_urls.py
===================================================================
--- forum_urls.py (revision 0)
+++ forum_urls.py (revision 0)
@@ -0,0 +1,14 @@
+from django.conf.urls.defaults import *
+from djangoforum.models import Forum
+
+forum_dict = {
+ 'queryset' : Forum.objects.all(),
+}
+
+urlpatterns = patterns('',
+ (r'^$', 'django.views.generic.list_detail.object_list', forum_dict),
+ (r'^(?P<slug>[A-Za-z0-9-_]+)/$', 'djangoforum.views.forum'),
+ (r'^(?P<forum>[A-Za-z0-9-_]+)/(?P<thread>[0-9]+)/$', 'djangoforum.views.thread'),
+ (r'^(?P<forum>[A-Za-z0-9-_]+)/new/$', 'djangoforum.views.newthread'),
+ (r'^(?P<forum>[A-Za-z0-9-_]+)/(?P<thread>[0-9]+)/reply/$', 'djangoforum.views.reply'),
+)
Index: models.py
===================================================================
--- models.py (revision 9)
+++ models.py (working copy)
@@ -8,6 +8,7 @@
from django.db import models
import datetime
from django.contrib.auth.models import User
+from django.conf import settings

class Forum(models.Model):
"""
@@ -26,7 +27,7 @@
pass

def get_absolute_url(self):
- return '/forum/%s/' % self.slug
+ return '%s/%s/' % (settings.FORUM_BASE, self.slug)

def __str__(self):
return self.title
@@ -58,7 +59,7 @@
super(Thread, self).save()

def get_absolute_url(self):
- return '/forum/%s/%s/' % (self.forum.slug, self.id)
+ return '%s/%s/%s/' % (settings.FORUM_BASE, self.forum.slug, self.id)

class Admin:
pass
@@ -99,7 +100,7 @@
ordering = ('-time',)

def get_absolute_url(self):
- return '/forum/%s/%s/#post%s' % (self.thread.forum.slug, self.thread.id, self.id)
+ return '%s/%s/%s/#post%s' % (settings.FORUM_BASE, self.thread.forum.slug, self.thread.id, self.id)

class Admin:
pass
Powered by Google Project Hosting