Commit 7a317c4e authored by Stéphane Raimbault's avatar Stéphane Raimbault

Adjust names of views and URL patterns indentation

- names similar to views
- named args
parent 9c6755b6
......@@ -64,7 +64,7 @@ def site_login(request, msgs=[]):
user.message_set.create(message=message)
if Role.objects.filter(person__username=user.username).count() < 1:
message = _("You have not joined any translation team yet. You can do it from <a href=\"%(url)s\">your profile</a>.") % {
'url': reverse('person-team-join-view'),
'url': reverse('person_team_join'),
}
user.message_set.create(message=message)
if request.POST['referer']:
......
......@@ -7,6 +7,8 @@ feeds = {
}
urlpatterns = patterns('',
(r'^(?P<url>.*)/$', 'django.contrib.syndication.views.feed',
{'feed_dict': feeds}),
url(
regex = r'^(?P<url>.*)/$',
view = 'django.contrib.syndication.views.feed',
kwargs = {'feed_dict': feeds})
)
from django.conf.urls.defaults import *
urlpatterns = patterns('',
url(r'^$', 'languages.views.languages', name='languages'),
url(r'^(?P<locale>[\w\-@]+)/all/(?P<dtype>(ui|doc)+)/$', 'languages.views.language_all', name='language_all'),
url(r'^(?P<locale>[\w\-@]+)/(?P<release_name>[\w-]+)/(?P<dtype>(ui|doc)+)/$', 'languages.views.language_release', name='language_release'),
(r'^(?P<locale>[\w\-@]+)/(?P<release_name>[\w-]+).xml$', 'languages.views.language_release_xml'),
(r'^(?P<locale>[\w\-@]+)/(?P<release_name>[\w-]+)/(?P<dtype>(ui|doc)+).tar.gz$', 'languages.views.language_release_tar'),
(r'^(?P<team_slug>[\w\-@]+)/$', 'teams.views.team'),
url(
regex = r'^$',
view = 'languages.views.languages',
name = 'languages'),
url(
regex = r'^(?P<locale>[\w\-@]+)/all/(?P<dtype>(ui|doc)+)/$',
view = 'languages.views.language_all',
name = 'language_all'),
url(
regex = r'^(?P<locale>[\w\-@]+)/(?P<release_name>[\w-]+)/(?P<dtype>(ui|doc)+)/$',
view = 'languages.views.language_release',
name = 'language_release'),
url(
regex = r'^(?P<locale>[\w\-@]+)/(?P<release_name>[\w-]+).xml$',
view = 'languages.views.language_release_xml'),
url(
regex = r'^(?P<locale>[\w\-@]+)/(?P<release_name>[\w-]+)/(?P<dtype>(ui|doc)+).tar.gz$',
view = 'languages.views.language_release_tar'),
url(
regex = r'^(?P<team_slug>[\w\-@]+)/$',
view = 'teams.views.team'),
)
......@@ -84,7 +84,7 @@ class Person(User):
@models.permalink
def get_absolute_url(self):
return ('person-username-view', [self.username])
return ('person_detail_username', [self.username])
def coordinates_teams(self):
from teams.models import Team
......
......@@ -10,17 +10,38 @@ info_dict_list = {
}
# Regex order is really important here
urlpatterns = patterns('people.views',
url(r'^detail_change/$', 'person_detail_change', name='person-detail-change-view'),
url(r'^password_change/$', 'person_password_change', name='person-password-change-view'),
url(r'^team_join/$', 'person_team_join', name='person-team-join-view'),
url(r'^team_leave/(?P<team_slug>[\w\-@]+)/$', 'person_team_leave', name='person-team-leave-view'),
url(r'^(?P<person_id>\d+)/$', 'person_detail', name='person-id-view'),
# equivalent to the previous, but using username instead of user pk
url(r'^(?P<person_username>[\w@\.\-]+)/$', 'person_detail', name='person-username-view'),
url(
regex = r'^detail_change/$',
view = 'person_detail_change',
name='person_detail_change'),
url(
regex = r'^password_change/$',
view = 'person_password_change',
name='person_password_change'),
url(
regex = r'^team_join/$',
view = 'person_team_join',
name='person_team_join'),
url(
regex = r'^team_leave/(?P<team_slug>[\w\-@]+)/$',
view = 'person_team_leave',
name='person_team_leave'),
url(
regex = r'^(?P<person_id>\d+)/$',
view = 'person_detail',
name='person_detail_id'),
# Equivalent to the previous, but using username instead of user pk
url(
regex = r'^(?P<person_username>[\w@\.\-]+)/$',
view = 'person_detail',
name='person_detail_username'),
)
urlpatterns += patterns('django.views.generic.list_detail',
url(r'^$', 'object_list', dict(info_dict_list), name='persons-view'),
url(
regex = r'^$',
view = 'object_list',
kwargs = dict(info_dict_list),
name = 'people'),
)
......@@ -114,7 +114,7 @@ def person_team_leave(request, team_slug):
# Message no i18n'ed, should never happen under normal conditions
person.message_set.create(message="You are not a member of this team.")
# redirect to normal person detail
return HttpResponseRedirect(urlresolvers.reverse('person-username-view',
return HttpResponseRedirect(urlresolvers.reverse('person_detail_username',
args=(person.username,)))
@login_required
......
......@@ -11,8 +11,17 @@ info_dict = {
}
urlpatterns = patterns('',
url(r'^$', 'teams.views.teams', name='teams'),
#url(r'(?P<slug>\w+)', 'django.views.generic.list_detail.object_detail', dict(info_dict), 'team_slug'),
url(r'(?P<team_slug>[\w\-@]+)', 'teams.views.team', name='team_slug'),
url(r'(?P<object_id>\d+)', 'django.views.generic.list_detail.object_detail', dict(info_dict), 'team'),
url(
regex = r'^$',
view = 'teams.views.teams',
name = 'teams'),
url(
regex = r'(?P<team_slug>[\w\-@]+)',
view = 'teams.views.team',
name = 'team_slug'),
url(
regex = r'(?P<object_id>\d+)',
view = 'django.views.generic.list_detail.object_detail',
kwargs = dict(info_dict),
name = 'team')
)
......@@ -34,7 +34,7 @@
{% endwith %}
</td><td></td></tr>
{% endifnotequal %}
{% for module in categ.modules %}
{% with module.0 as modname %}
{% for branch, doms in module.1.items %}
......@@ -49,7 +49,7 @@
{% endifequal %}
<td class="leftcell">
{% if language %}
<a href="{% url vertimus-names-view modname branch stat.domain.name language.locale %}">{{ stat.module_description }}
<a href="{% url vertimus_by_names modname,branch,stat.domain.name,language.locale %}">{{ stat.module_description }}
{% else %}
<a href="{% url stats.views.module modname %}">{{ stat.module_description }}
{% endif %}
......@@ -57,7 +57,7 @@
{# For a partial po, domain description is appended #}
&bull; {{ domname }}
{% endif %}
</a>
</a>
{% for err in stat.info_list %}
<img src="{{ err.get_icon }}" title="{{ err.get_description|striptags }}" alt="{{ err.type }}" />
{% endfor %}
......
......@@ -9,9 +9,9 @@
{% if on_own_page %}
<div class="right_actions">
<ul>
<li><a href="{% url person-detail-change-view %}">{% trans "Change your details" %}</a></li>
<li><a href="{% url person-password-change-view %}">{% trans "Change your password" %}</a></li>
<li><a href="{% url person-team-join-view %}">{% trans "Join a team" %}</a></li>
<li><a href="{% url person_detail_change %}">{% trans "Change your details" %}</a></li>
<li><a href="{% url person_password_change %}">{% trans "Change your password" %}</a></li>
<li><a href="{% url person_team_join %}">{% trans "Join a team" %}</a></li>
</ul>
</div>
{% endif %}
......
......@@ -8,7 +8,7 @@
{% with role.role as role_name %}
<li>{% blocktrans with role.team|linked_with:role.team.get_description|safe as team_name %}Member of {{ team_name }} team ({{ role_name }}){% endblocktrans %}
{% if on_own_page %}
<form class="inline" method="GET" action="{% url person-team-leave-view role.team.name %}">
<form class="inline" method="GET" action="{% url person_team_leave role.team.name %}">
<input type="submit" value="{% trans "Leave" %}"
onClick="javascript:return confirm('{% trans "Are you sure you want to leave the team?" %}')">
</form>
......
{% load i18n %}
{% for dname, stat in stats.items %}
{% with stat|first as pot_stat %}
{% with stat|first as pot_stat %}
<h3>{% trans pot_stat.domain.get_description %}
{% ifnotequal pot_stat.domain.directory 'help' %}
{% ifnotequal pot_stat.domain.directory 'po' %}
......@@ -37,8 +37,8 @@
{% for line in stat %}
{% if not forloop.first %}
<tr>
<td class="leftcell"><a href="{% url vertimus-names-view module.name branch.name pot_stat.domain.name line.language.locale %}">{{ line.get_lang }}</a>
{% with line.most_important_message as msg %}
<td class="leftcell"><a href="{% url vertimus_by_names module.name,branch.name,pot_stat.domain.name,line.language.locale %}">{{ line.get_lang }}</a>
{% with line.most_important_message as msg %}
{% if msg %}
<img src="{{ msg.get_icon }}" title="{{ msg.get_description }}" alt="{{ msg.type }}" />
{% endif %}
......
......@@ -88,7 +88,7 @@ $(document).ready(function() {
<img src="{{ MEDIA_URL }}img/warn.png" alt="Warning logo" />
{% trans "On-going activities in same module:" %}
{% for st in other_states %}
<a href="{% url vertimus-ids-view st.branch.pk,st.domain.pk,st.language.pk %}">{{ st.branch.name }}</a>
<a href="{% url vertimus_by_ids st.branch.pk,st.domain.pk,st.language.pk %}">{{ st.branch.name }}</a>
{% endfor %}
</div>
{% endif %}
......@@ -99,7 +99,7 @@ $(document).ready(function() {
{% trans "Actions" %}
{% else %}
{% blocktrans with level|ordinal|safe as human_level %}Archived Actions ({{ human_level }} archived series){% endblocktrans %}
<a href="{% url vertimus-names-view module.name,branch.name,domain.name,language.locale %}">
<a href="{% url vertimus_by_names module.name,branch.name,domain.name,language.locale %}">
{% trans "(Return to current)" %}
</a>
{% endifequal %}
......@@ -136,7 +136,7 @@ $(document).ready(function() {
{% endif %}
<div class="right_actions">{% trans "diff with:" %}
{% for f in files %}
<a href="{% url vertimus-diff-view action.id,f.action_id %}" title="{{ f.title }}">[{{ forloop.revcounter }}]</a>
<a href="{% url vertimus_diff action.id,f.action_id %}" title="{{ f.title }}">[{{ forloop.revcounter }}]</a>
{% endfor %}
</div>
{% endif %}
......@@ -161,7 +161,7 @@ $(document).ready(function() {
{% if action_form %}
<form enctype="multipart/form-data"
action="{% url vertimus-stats-id-view stats.id language.id %}"
action="{% url vertimus_by_stats_id stats.id,language.id %}"
method="POST">
<table class="djform">
{{ action_form.as_table }}
......
......@@ -13,7 +13,7 @@
<div class="mainpage">
<h1>{{ state.branch.module.get_description }} - {{ state.branch.name }} - {{ state.domain.get_description }} - {{ state.language.get_name }}</h1>
<p><a href="{% url vertimus-names-view state.branch.module.name state.branch.name state.domain.name state.language.locale %}">{% trans "&lt;- Back to actions" %}</a></p>
<p><a href="{% url vertimus_by_names state.branch.module.name,state.branch.name,state.domain.name,state.language.locale %}">{% trans "&lt;- Back to actions" %}</a></p>
{{ diff_content|safe }}
......
......@@ -5,52 +5,104 @@ from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', 'common.views.index', name='home'),
url(r'^login/$', 'common.views.site_login', name='login'),
url(r'^register/$', 'common.views.site_register', name='register'),
url(r'^register/success$', 'django.views.generic.simple.direct_to_template', {'template': 'registration/register_success.html'}, name='register_success'),
url(r'^register/activate/(?P<key>\w+)$', 'common.views.activate_account', name='register_activation'),
(r'^password_reset/$', 'django.contrib.auth.views.password_reset', {'template_name':'registration/password_reset_form.html'}),
(r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done', {'template_name':'registration/password_reset_done.html'}),
(r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm'),
(r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'),
(r'^teams/', include('teams.urls')),
(r'^people/', include('people.urls')),
# users is the hardcoded url in the contrib.auth User class, making it identical to /people
(r'^users/', include('people.urls')),
(r'^languages/', include('languages.urls')),
(r'^vertimus/', include('vertimus.urls')),
(r'^i18n/', include('django.conf.urls.i18n')),
(r'^admin/(.*)', admin.site.root),
(r'^rss/', include('feeds.urls')),
url(
regex = r'^$',
view = 'common.views.index',
name = 'home'),
url(
regex = r'^login/$',
view = 'common.views.site_login',
name = 'login'),
url(
regex = r'^register/$',
view = 'common.views.site_register',
name = 'register'),
url(
regex = r'^register/success$',
view = 'django.views.generic.simple.direct_to_template',
kwargs = {'template': 'registration/register_success.html'},
name = 'register_success'),
url(
regex = r'^register/activate/(?P<key>\w+)$',
view = 'common.views.activate_account',
name = 'register_activation'),
url(
regex = r'^password_reset/$',
view = 'django.contrib.auth.views.password_reset',
kwargs = {'template_name':'registration/password_reset_form.html'}),
url(
regex = r'^password_reset/done/$',
view = 'django.contrib.auth.views.password_reset_done',
kwargs = {'template_name':'registration/password_reset_done.html'}),
url(
regex = r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
view = 'django.contrib.auth.views.password_reset_confirm'),
url(
regex = r'^reset/done/$',
view = 'django.contrib.auth.views.password_reset_complete'),
url(r'^teams/', include('teams.urls')),
url(r'^people/', include('people.urls')),
url(# users is the hardcoded url in the contrib.auth User class, making it identical to /people
r'^users/', include('people.urls')),
url(r'^languages/', include('languages.urls')),
url(r'^vertimus/', include('vertimus.urls')),
url(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^admin/(.*)', admin.site.root),
url(r'^rss/', include('feeds.urls')),
)
urlpatterns += patterns('stats.views',
url(r'^module/$', 'modules', name='modules'),
url(r'^module/po/(?P<filename>.*)$', 'dynamic_po', name='dynamic_po'),
(r'^module/(?P<module_name>[\w\-\+]+)/$', 'module'),
(r'^module/(?P<module_name>[\w\-\+]+)/edit/branches/$', 'module_edit_branches'),
(r'^module/(?P<module_name>[\w\-\+]+)/branch/(?P<branch_name>[\w-]+)/$', 'module_branch'),
(r'^module/(?P<module_name>[\w\-\+]+)/(?P<potbase>[\w-]+)/(?P<branch_name>[\w-]+)/(?P<langcode>[\w@]+)/images/$', 'docimages'),
url(r'^releases/(?P<format>(html|json|xml))?/?$', 'releases', name='releases'),
(r'^releases/(?P<release_name>[\w-]+)/(?P<format>(html|xml))?/?$', 'release'),
(r'^releases/compare/(?P<dtype>\w+)/(?P<rels_to_compare>[\w-]+)/$', 'compare_by_releases'),
url(
regex = r'^module/$',
view = 'modules',
name = 'modules'),
url(
regex = r'^module/po/(?P<filename>.*)$',
view = 'dynamic_po',
name = 'dynamic_po'),
url(
regex = r'^module/(?P<module_name>[\w\-\+]+)/$',
view = 'module'),
url(
regex = r'^module/(?P<module_name>[\w\-\+]+)/edit/branches/$',
view = 'module_edit_branches'),
url(
regex = r'^module/(?P<module_name>[\w\-\+]+)/branch/(?P<branch_name>[\w-]+)/$',
view = 'module_branch'),
url(
regex = r'^module/(?P<module_name>[\w\-\+]+)/(?P<potbase>[\w-]+)/(?P<branch_name>[\w-]+)/(?P<langcode>[\w@]+)/images/$',
view = 'docimages'),
url(
regex = r'^releases/(?P<format>(html|json|xml))?/?$',
view = 'releases',
name = 'releases'),
url(
regex = r'^releases/(?P<release_name>[\w-]+)/(?P<format>(html|xml))?/?$',
view = 'release'),
url(
regex = r'^releases/compare/(?P<dtype>\w+)/(?P<rels_to_compare>[\w-]+)/$',
view = 'compare_by_releases'),
)
if 'django_openid' in settings.INSTALLED_APPS:
from django_openid.auth import AuthConsumer
urlpatterns += patterns('',
# ...
(r'^openid/(.*)', AuthConsumer()),
)
if settings.STATIC_SERVE:
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
(r'^POT/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.POTDIR}),
(r'^(robots.txt)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
url(
regex = r'^media/(?P<path>.*)$',
view = 'django.views.static.serve',
kwargs = {'document_root': settings.MEDIA_ROOT}),
url(
regex = r'^POT/(?P<path>.*)$',
view = 'django.views.static.serve',
kwargs = {'document_root': settings.POTDIR}),
url(
regex = r'^(robots.txt)$',
view = 'django.views.static.serve',
kwargs = {'document_root': settings.MEDIA_ROOT})
)
......@@ -61,7 +61,7 @@ class LatestActionsByLanguage(Feed):
return (action_db.get_action() for action_db in islice(imerge_sorted_by_field(actions_db, archived_actions_db, '-created'), 20))
def item_link(self, item):
return urlresolvers.reverse('vertimus-names-view',
return urlresolvers.reverse('vertimus_by_names',
args=(item.state.branch.module.name,
item.state.branch.name,
item.state.domain.name,
......@@ -108,7 +108,7 @@ class LatestActionsByTeam(Feed):
return (action_db.get_action() for action_db in islice(imerge_sorted_by_field(actions_db, archived_actions_db, '-created'), 20))
def item_link(self, item):
return urlresolvers.reverse('vertimus-names-view',
return urlresolvers.reverse('vertimus_by_names',
args=(item.state.branch.module.name,
item.state.branch.name,
item.state.domain.name,
......
......@@ -65,7 +65,7 @@ class StateDb(models.Model):
@models.permalink
def get_absolute_url(self):
return ('vertimus-ids-view', [self.branch.id, self.domain.id, self.language.id])
return ('vertimus_by_ids', [self.branch.id, self.domain.id, self.language.id])
class StateAbstract(object):
"""Abstract class"""
......@@ -508,7 +508,7 @@ class ActionAbstract(object):
activate(old_state.language.locale)
current_site = Site.objects.get_current()
url = "http://%s%s" % (current_site.domain, urlresolvers.reverse(
'vertimus-names-view',
'vertimus_by_names',
args = (
old_state.branch.module.name,
old_state.branch.name,
......@@ -559,7 +559,7 @@ class ActionWC(ActionAbstract):
activate(state.language.locale)
current_site = Site.objects.get_current()
url = "http://%s%s" % (current_site.domain, urlresolvers.reverse(
'vertimus-names-view',
'vertimus_by_names',
args = (
state.branch.module.name,
state.branch.name,
......
......@@ -4,11 +4,11 @@ urlpatterns = patterns('vertimus.views',
url(
regex = r'^(?P<stats_id>\d+)/(?P<lang_id>\d+)$',
view = 'vertimus_by_stats_id',
name = 'vertimus-stats-id-view'),
name = 'vertimus_by_stats_id'),
url(
regex = r'^(?P<branch_id>\d+)/(?P<domain_id>\d+)/(?P<language_id>\d+)',
view = 'vertimus_by_ids',
name = 'vertimus-ids-view'),
name = 'vertimus_by_ids'),
url(
regex = '^(?P<module_name>[\w\+\-\.]+)/(?P<branch_name>[\w\-\.]+)/(?P<domain_name>[\w\-]+)/(?P<locale_name>[\w\-@]+)/level(?P<level>\d+)/$',
view = 'vertimus_by_names',
......@@ -16,9 +16,9 @@ urlpatterns = patterns('vertimus.views',
url(
regex = r'^(?P<module_name>[\w\+\-\.]+)/(?P<branch_name>[\w\-\.]+)/(?P<domain_name>[\w\-]+)/(?P<locale_name>[\w\-@]+)',
view = 'vertimus_by_names',
name = 'vertimus-names-view'),
name = 'vertimus_by_names'),
url(
regex = r'^diff/(?P<action_id_1>\d+)/(?P<action_id_2>\d+)?$',
view = 'vertimus_diff',
name = 'vertimus-diff-view')
name = 'vertimus_diff'),
)
......@@ -111,7 +111,7 @@ def vertimus(request, branch, domain, language, stats=None, level="0"):
new_state.save()
return HttpResponseRedirect(
urlresolvers.reverse('vertimus-names-view',
urlresolvers.reverse('vertimus_by_names',
args=(branch.module.name, branch.name, domain.name,
language.locale)))
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment