]> git.openstreetmap.org Git - osqa.git/blob - forum/urls.py
fixes osqa-152: interesting and ignored tags work again. also fixed potential perfor...
[osqa.git] / forum / urls.py
1 import startup
2
3 import os.path
4 from django.conf.urls.defaults import *
5 from django.contrib import admin
6 from forum import views as app
7 from forum.feed import RssLastestQuestionsFeed
8 from forum.sitemap import QuestionsSitemap
9 from django.utils.translation import ugettext as _
10 import logging
11
12 admin.autodiscover()
13 feeds = {
14     'rss': RssLastestQuestionsFeed
15 }
16 sitemaps = {
17     'questions': QuestionsSitemap
18 }
19
20 APP_PATH = os.path.dirname(__file__)
21
22 from forum.modules import get_modules_script
23
24 module_patterns = get_modules_script('urls')
25
26 urlpatterns = patterns('')
27
28 for pattern_file in module_patterns:
29     pattern = getattr(pattern_file, 'urlpatterns', None)
30     if pattern:
31         urlpatterns += pattern
32
33 urlpatterns += patterns('',
34     url(r'^$', app.readers.index, name='index'),
35     url(r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}, name='sitemap'),
36     #(r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '/media/images/favicon.ico'}),
37     #(r'^favicon\.gif$', 'django.views.generic.simple.redirect_to', {'url': '/media/images/favicon.gif'}),
38     (r'^favicon\.ico$', app.meta.favicon),
39     url(r'^m/(?P<path>.*)$', 'django.views.static.serve',
40         {'document_root': os.path.join(APP_PATH,'skins').replace('\\','/')},
41         name='osqa_media',
42     ),
43     url(r'^%s(?P<path>.*)$' % _('upfiles/'), 'django.views.static.serve',
44         {'document_root': os.path.join(APP_PATH,'upfiles').replace('\\','/')},
45         name='uploaded_file',
46     ),
47     #url(r'^%s/$' % _('signin/'), 'django_authopenid.views.signin', name='signin'),
48     url(r'^%s$' % _('about/'), app.meta.about, name='about'),
49     url(r'^%s$' % _('faq/'), app.meta.faq, name='faq'),
50     url(r'^%s$' % _('privacy/'), app.meta.privacy, name='privacy'),
51     url(r'^%s$' % _('logout/'), app.meta.logout, name='logout'),
52     url(r'^%s(?P<id>\d+)/%s$' % (_('answers/'), _('edit/')), app.writers.edit_answer, name='edit_answer'),
53     url(r'^%s(?P<id>\d+)/%s$' % (_('answers/'), _('revisions/')), app.readers.revisions, name='answer_revisions'),
54     url(r'^%s$' % _('questions/'), app.readers.questions, name='questions'),
55     url(r'^%s%s$' % (_('questions/'), _('ask/')), app.writers.ask, name='ask'),
56     url(r'^%s%s$' % (_('questions/'), _('unanswered/')), app.readers.unanswered, name='unanswered'),
57     url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('edit/')), app.writers.edit_question, name='edit_question'),
58     url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('close/')), app.commands.close, name='close'),
59     url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('reopen/')), app.commands.reopen, name='reopen'),
60     url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('answer/')), app.writers.answer, name='answer'),
61
62     url(r'^%s(?P<id>\d+)/(?P<vote_type>[a-z]+)/' % _('vote/'), app.commands.vote_post, name='vote_post'),
63     url(r'^%s(?P<id>\d+)/$' % _('like_comment/'), app.commands.like_comment, name="like_comment"),
64     url(r'^%s(?P<id>\d+)/' % _('comment/'), app.commands.comment, name='comment'),
65     url(r'^%s(?P<id>\d+)/$' % _('delete_comment/'), app.commands.delete_comment, name="delete_comment"),
66     url(r'^%s(?P<id>\d+)/$' % _('accept_answer/'), app.commands.accept_answer, name="accept_answer"),
67     url(r'^%s(?P<id>\d+)/$' % _('mark_favorite/'), app.commands.mark_favorite, name="mark_favorite"),
68     url(r'^%s(?P<id>\d+)/' % _('flag/'), app.commands.flag_post, name='flag_post'),
69     url(r'^%s(?P<id>\d+)/' % _('delete/'), app.commands.delete_post, name='delete_post'),
70     url(r'^%s(?P<id>\d+)/$' % _('subscribe/'), app.commands.subscribe, name="subscribe"),
71     url(r'^%s' % _('matching_tags/'), app.commands.matching_tags, name='matching_tags'),
72     
73     url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('revisions/')), app.readers.revisions, name='question_revisions'),
74     url(r'^%s$' % _('command/'), app.commands.ajax_command, name='call_ajax'),
75
76     #place general question item in the end of other operations
77     url(r'^%s(?P<id>\d+)/(?P<slug>[\w-]*)$' % _('question/'), app.readers.question, name='question'),
78     url(r'^%s$' % _('tags/'), app.readers.tags, name='tags'),
79     url(r'^%s(?P<tag>[^/]+)/$' % _('tags/'), app.readers.tag, name='tag_questions'),
80
81     url(r'^%s%s(?P<tag>[^/]+)/$' % (_('mark-tag/'),_('interesting/')), app.commands.mark_tag, \
82                                 kwargs={'reason':'good','action':'add'}, \
83                                 name='mark_interesting_tag'),
84
85     url(r'^%s%s(?P<tag>[^/]+)/$' % (_('mark-tag/'),_('ignored/')), app.commands.mark_tag, \
86                                 kwargs={'reason':'bad','action':'add'}, \
87                                 name='mark_ignored_tag'),
88
89     url(r'^%s(?P<tag>[^/]+)/$' % _('unmark-tag/'), app.commands.mark_tag, \
90                                 kwargs={'action':'remove'}, \
91                                 name='mark_ignored_tag'),
92
93
94
95     url(r'^%s$' % _('users/'),app.users.users, name='users'),
96     url(r'^%s(?P<id>\d+)/$' % _('moderate-user/'), app.users.moderate_user, name='moderate_user'),
97     url(r'^%s(?P<id>\d+)/%s$' % (_('users/'), _('edit/')), app.users.edit_user, name='edit_user'),
98
99     url(r'^%s(?P<id>\d+)/(?P<slug>.+)/%s$' % (_('users/'), _('subscriptions/')), app.users.user_subscriptions, name='user_subscriptions'),
100     url(r'^%s(?P<id>\d+)/(?P<slug>.+)/%s$' % (_('users/'), _('favorites/')), app.users.user_favorites, name='user_favorites'),
101     url(r'^%s(?P<id>\d+)/(?P<slug>.+)/%s$' % (_('users/'), _('reputation/')), app.users.user_reputation, name='user_reputation'),
102     url(r'^%s(?P<id>\d+)/(?P<slug>.+)/%s$' % (_('users/'), _('votes/')), app.users.user_votes, name='user_votes'),
103     url(r'^%s(?P<id>\d+)/(?P<slug>.+)/%s$' % (_('users/'), _('recent/')), app.users.user_recent, name='user_recent'),
104     url(r'^%s(?P<id>\d+)/(?P<slug>.+)/$' % _('users/'), app.users.user_stats, name='user_profile'),
105     
106     url(r'^%s$' % _('badges/'),app.meta.badges, name='badges'),
107     url(r'^%s(?P<id>\d+)//*' % _('badges/'), app.meta.badge, name='badge'),
108     url(r'^%s%s$' % (_('messages/'), _('markread/')),app.commands.read_message, name='read_message'),
109     # (r'^admin/doc/' % _('admin/doc'), include('django.contrib.admindocs.urls')),
110     url(r'^%s(.*)' % _('nimda/'), admin.site.root, name='osqa_admin'),
111     url(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}, name='feeds'),
112     url(r'^%s$' % _('upload/'), app.writers.upload, name='upload'),
113     url(r'^%s$' % _('search/'), app.readers.search, name='search'),
114     url(r'^%s$' % _('feedback/'), app.meta.feedback, name='feedback'),
115
116     (r'^i18n/', include('django.conf.urls.i18n')),
117
118     url(r'^%s%s$' % (_('account/'), _('signin/')), app.auth.signin_page, name='auth_signin'),
119     url(r'^%s%s$' % (_('account/'), _('signout/')), app.auth.signout, name='user_signout'),
120     url(r'^%s%s(?P<action>\w+)/$' % (_('account/'), _('signin/')), app.auth.signin_page, name='auth_action_signin'),
121     url(r'^%s(?P<provider>\w+)/%s$' % (_('account/'), _('signin/')), app.auth.prepare_provider_signin, name='auth_provider_signin'),
122     url(r'^%s(?P<provider>\w+)/%s$' % (_('account/'), _('done/')), app.auth.process_provider_signin, name='auth_provider_done'),
123     url(r'^%s%s$' % (_('account/'), _('register/')), app.auth.external_register, name='auth_external_register'),
124     url(r'^%s%s(?P<user>\d+)/(?P<code>.+)/$' % (_('account/'), _('validate/')),  app.auth.validate_email, name="auth_validate_email"),
125     url(r'^%s%s$' % (_('account/'), _('tempsignin/')),  app.auth.request_temp_login, name="auth_request_tempsignin"),
126     url(r'^%s%s(?P<user>\d+)/(?P<code>.+)/$' % (_('account/'), _('tempsignin/')),  app.auth.temp_signin, name="auth_tempsignin"),
127     url(r'^%s%s$' % (_('account/'), _('authsettings/')), app.auth.auth_settings, name='user_authsettings'),
128     url(r'^%s%s(?P<id>\d+)/%s$' % (_('account/'), _('providers/'),  _('remove/')), app.auth.remove_external_provider, name='user_remove_external_provider'),
129     url(r'^%s%s%s$' % (_('account/'), _('providers/'),  _('add/')), app.auth.signin_page, name='user_add_external_provider'),
130
131
132     url(r'^%s$' % _('admin/'), app.admin.index, name="admin_index"),
133     url(r'^%s%s$' % (_('admin/'), _('denormalize/')), app.admin.recalculate_denormalized, name="admin_denormalize"),
134     url(r'^%s%s$' % (_('admin/'), _('go_bootstrap/')), app.admin.go_bootstrap, name="admin_go_bootstrap"),
135     url(r'^%s%s$' % (_('admin/'), _('go_defaults/')), app.admin.go_defaults, name="admin_go_defaults"),
136     url(r'^%s(?P<set_name>\w+)/$' % _('admin/'), app.admin.settings_set, name="admin_set"),
137
138     url(r'^feeds/rss/$', RssLastestQuestionsFeed, name="latest_questions_feed"),
139 )
140