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