]> git.openstreetmap.org Git - osqa.git/blob - forum/urls.py
Initial commit
[osqa.git] / forum / urls.py
1 import os.path
2 from django.conf.urls.defaults import *
3 from django.contrib import admin
4 from forum import views as app
5 from forum.feed import RssLastestQuestionsFeed
6 from forum.sitemap import QuestionsSitemap
7 from django.utils.translation import ugettext as _
8 import logging
9
10 admin.autodiscover()
11 feeds = {
12     'rss': RssLastestQuestionsFeed
13 }
14 sitemaps = {
15     'questions': QuestionsSitemap
16 }
17
18 APP_PATH = os.path.dirname(__file__)
19 urlpatterns = patterns('',
20     url(r'^$', app.readers.index, name='index'),
21     url(r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}, name='sitemap'),
22     #(r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '/media/images/favicon.ico'}),
23     #(r'^favicon\.gif$', 'django.views.generic.simple.redirect_to', {'url': '/media/images/favicon.gif'}),
24     url(r'^m/(?P<path>.*)$', 'django.views.static.serve',
25         {'document_root': os.path.join(APP_PATH,'skins').replace('\\','/')},
26         name='osqa_media',
27     ),
28     url(r'^%s(?P<path>.*)$' % _('upfiles/'), 'django.views.static.serve',
29         {'document_root': os.path.join(APP_PATH,'upfiles').replace('\\','/')},
30         name='uploaded_file',
31     ),
32     #url(r'^%s/$' % _('signin/'), 'django_authopenid.views.signin', name='signin'),
33     url(r'^%s$' % _('about/'), app.meta.about, name='about'),
34     url(r'^%s$' % _('faq/'), app.meta.faq, name='faq'),
35     url(r'^%s$' % _('privacy/'), app.meta.privacy, name='privacy'),
36     url(r'^%s$' % _('logout/'), app.meta.logout, name='logout'),
37     url(r'^%s(?P<id>\d+)/%s$' % (_('answers/'), _('comments/')), app.writers.answer_comments, name='answer_comments'),
38     url(r'^%s(?P<id>\d+)/%s$' % (_('answers/'), _('edit/')), app.writers.edit_answer, name='edit_answer'),
39     url(r'^%s(?P<id>\d+)/%s$' % (_('answers/'), _('revisions/')), app.readers.answer_revisions, name='answer_revisions'),
40     url(r'^%s$' % _('questions/'), app.readers.questions, name='questions'),
41     url(r'^%s%s$' % (_('questions/'), _('ask/')), app.writers.ask, name='ask'),
42     url(r'^%s%s$' % (_('questions/'), _('unanswered/')), app.readers.unanswered, name='unanswered'),
43     url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('edit/')), app.writers.edit_question, name='edit_question'),
44     url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('close/')), app.commands.close, name='close'),
45     url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('reopen/')), app.commands.reopen, name='reopen'),
46     url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('answer/')), app.writers.answer, name='answer'),
47     url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('vote/')), app.commands.vote, name='vote'),
48     url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('revisions/')), app.readers.question_revisions, name='question_revisions'),
49     url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('comments/')), app.writers.question_comments, name='question_comments'),
50     url(r'^%s$' % _('command/'), app.commands.ajax_command, name='call_ajax'),
51
52     url(r'^%s(?P<object_id>\d+)/%s(?P<comment_id>\d+)/%s$' % (_('questions/'), _('comments/'),_('delete/')), \
53                                                 app.writers.delete_comment, kwargs={'commented_object_type':'question'},\
54                                                 name='delete_question_comment'),
55
56     url(r'^%s(?P<object_id>\d+)/%s(?P<comment_id>\d+)/%s$' % (_('answers/'), _('comments/'),_('delete/')), \
57                                                 app.writers.delete_comment, kwargs={'commented_object_type':'answer'}, \
58                                                 name='delete_answer_comment'), \
59     #place general question item in the end of other operations
60     url(r'^%s(?P<id>\d+)/' % _('question/'), app.readers.question, name='question'),
61     url(r'^%s$' % _('tags/'), app.readers.tags, name='tags'),
62     url(r'^%s(?P<tag>[^/]+)/$' % _('tags/'), app.readers.tag, name='tag_questions'),
63
64     url(r'^%s%s(?P<tag>[^/]+)/$' % (_('mark-tag/'),_('interesting/')), app.commands.mark_tag, \
65                                 kwargs={'reason':'good','action':'add'}, \
66                                 name='mark_interesting_tag'),
67
68     url(r'^%s%s(?P<tag>[^/]+)/$' % (_('mark-tag/'),_('ignored/')), app.commands.mark_tag, \
69                                 kwargs={'reason':'bad','action':'add'}, \
70                                 name='mark_ignored_tag'),
71
72     url(r'^%s(?P<tag>[^/]+)/$' % _('unmark-tag/'), app.commands.mark_tag, \
73                                 kwargs={'action':'remove'}, \
74                                 name='mark_ignored_tag'),
75
76     url(r'^%s$' % _('users/'),app.users.users, name='users'),
77     url(r'^%s(?P<id>\d+)/$' % _('moderate-user/'), app.users.moderate_user, name='moderate_user'),
78     url(r'^%s(?P<id>\d+)/%s$' % (_('users/'), _('edit/')), app.users.edit_user, name='edit_user'),
79     url(r'^%s(?P<id>\d+)//*' % _('users/'), app.users.user, name='user'),
80     url(r'^%s$' % _('badges/'),app.meta.badges, name='badges'),
81     url(r'^%s(?P<id>\d+)//*' % _('badges/'), app.meta.badge, name='badge'),
82     url(r'^%s%s$' % (_('messages/'), _('markread/')),app.commands.read_message, name='read_message'),
83     # (r'^admin/doc/' % _('admin/doc'), include('django.contrib.admindocs.urls')),
84     url(r'^%s(.*)' % _('nimda/'), admin.site.root, name='osqa_admin'),
85     url(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}, name='feeds'),
86     url(r'^%s$' % _('upload/'), app.writers.upload, name='upload'),
87     url(r'^%s$' % _('search/'), app.readers.search, name='search'),
88     url(r'^%s$' % _('feedback/'), app.meta.feedback, name='feedback'),
89     #(r'^%sfb/' % _('account/'),  include('fbconnect.urls')), 
90     #(r'^%s' % _('account/'), include('django_authopenid.urls')),
91     (r'^i18n/', include('django.conf.urls.i18n')),
92
93     url(r'^%s%s$' % (_('account/'), _('signin/')), app.auth.signin_page, name='auth_signin'),
94     url(r'^%s%s$' % (_('account/'), _('signout/')), app.auth.signout, name='user_signout'),
95     url(r'^%s%s(?P<action>\w+)/$' % (_('account/'), _('signin/')), app.auth.signin_page, name='auth_action_signin'),
96     url(r'^%s(?P<provider>\w+)/%s$' % (_('account/'), _('signin/')), app.auth.prepare_provider_signin, name='auth_provider_signin'),
97     url(r'^%s(?P<provider>\w+)/%s$' % (_('account/'), _('done/')), app.auth.process_provider_signin, name='auth_provider_done'),
98     url(r'^%s%s$' % (_('account/'), _('register/')), app.auth.external_register, name='auth_external_register'),
99
100     url(r'^%s%s$' % (_('account/'), _('password/')), app.users.changepw, name='user_changepw'),
101     #url(r'^%s%s%s$' % (_('accounts/'), _('password/'), _('confirm/')), app.user.confirmchangepw, name='user_confirmchangepw'),
102     url(r'^%s$' % _('account/'), app.users.account_settings, name='user_account_settings'),
103     #url(r'^%s$' % _('delete/'), app.users.delete, name='user_delete'),    
104 )
105
106 from forum.modules import get_modules_script
107
108 module_patterns = get_modules_script('urls')
109
110 for pattern_file in module_patterns:
111     pattern = getattr(pattern_file, 'urlpatterns', None)
112     if pattern:
113         urlpatterns += pattern
114