use djangos named URLs and url-reverse instead of manually constructing urls

This commit is contained in:
fonfon committed 2014-07-10 03:44:52 +00:00
1 parent 32872cea12
commit a82a83576f
30 files changed
+73 -84

No files matched your search

+1 -1
View File
@@ -24,5 +24,5 @@ from django.conf.urls import patterns, url
urlpatterns = patterns( # pylint: disable-msg=C0103
'modules.apps.apps',
url(r'^apps/$', 'index')
url(r'^apps/$', 'index', name='index')
)
+1 -1
View File
@@ -24,5 +24,5 @@ from django.conf.urls import patterns, url
urlpatterns = patterns( # pylint: disable-msg=C0103
'modules.config.config',
url(r'^sys/config/$', 'index'),
url(r'^sys/config/$', 'index', name='index'),
)
@@ -24,8 +24,8 @@
system to confirm that network services are running and configured
properly. It may take a minute to complete.</p>
<p><a class="btn btn-primary btn-large"
href="{{ basehref }}/sys/diagnostics/test">Run diagnostic test
&raquo;</a></p>
<p><a class="btn btn-primary btn-large" href="{% url 'diagnostics:test' %}">
Run diagnostic test &raquo;
</a></p>
{% endblock %}
+2 -2
View File
@@ -24,6 +24,6 @@ from django.conf.urls import patterns, url
urlpatterns = patterns( # pylint: disable-msg=C0103
'modules.diagnostics.diagnostics',
url(r'^sys/diagnostics/$', 'index'),
url(r'^sys/diagnostics/test/$', 'test'),
url(r'^sys/diagnostics/$', 'index', name='index'),
url(r'^sys/diagnostics/test/$', 'test', name='test'),
)
+1 -1
View File
@@ -24,5 +24,5 @@ from django.conf.urls import patterns, url
urlpatterns = patterns( # pylint: disable-msg=C0103
'modules.expert_mode.expert_mode',
url(r'^sys/expert/$', 'index'),
url(r'^sys/expert/$', 'index', name='index'),
)
+1 -1
View File
@@ -24,5 +24,5 @@ from django.conf.urls import patterns, url
urlpatterns = patterns( # pylint: disable-msg=C0103
'modules.firewall.firewall',
url(r'^sys/firewall/$', 'index')
url(r'^sys/firewall/$', 'index', name='index')
)
+3 -3
View File
@@ -21,6 +21,7 @@ The Plinth first-connection process has several stages:
from django import forms
from django.contrib import messages
from django.core import validators
from django.core.urlresolvers import reverse
from django.http.response import HttpResponseRedirect
from django.template.response import TemplateResponse
from gettext import gettext as _
@@ -94,7 +95,7 @@ def state0(request):
"""
try:
if _read_state() >= 5:
return HttpResponseRedirect(cfg.server_dir)
return HttpResponseRedirect(reverse('index'))
except KeyError:
pass
@@ -112,8 +113,7 @@ def state0(request):
if success:
# Everything is good, permanently mark and move to page 2
_write_state(1)
return HttpResponseRedirect(
cfg.server_dir + '/firstboot/state1')
return HttpResponseRedirect(reverse('first_boot:state1'))
else:
form = State0Form(initial=status, prefix='firstboot')
@@ -23,7 +23,7 @@
{% block main_block %}
<p>Welcome screen not completely implemented yet. Press <a
href="{{basehref }}/apps">continue</a> to see the rest of the
href="{% url 'apps:index' %}">continue</a> to see the rest of the
web interface.</p>
<ul>
+3 -3
View File
@@ -24,7 +24,7 @@ from django.conf.urls import patterns, url
urlpatterns = patterns( # pylint: disable-msg=C0103
'modules.first_boot.first_boot',
url(r'^firstboot/$', 'index'),
url(r'^firstboot/state0/$', 'state0'),
url(r'^firstboot/state1/$', 'state1')
url(r'^firstboot/$', 'index', name='index'),
url(r'^firstboot/state0/$', 'state0', name='state0'),
url(r'^firstboot/state1/$', 'state1', name='state1')
)
+11 -7
View File
@@ -1,5 +1,6 @@
import os
from gettext import gettext as _
from django.http import Http404
from django.template.response import TemplateResponse
import cfg
@@ -9,10 +10,10 @@ def init():
"""Initialize the Help module"""
menu = cfg.main_menu.add_item(_('Documentation'), 'icon-book', '/help',
101)
menu.add_item(_("Where to Get Help"), "icon-search", "/help/index", 5)
menu.add_item(_("Where to Get Help"), "icon-search", "/help/index/", 5)
menu.add_item(_('Developer\'s Manual'), 'icon-info-sign',
'/help/view/plinth', 10)
menu.add_item(_('FAQ'), 'icon-question-sign', '/help/view/faq', 20)
'/help/page/plinth', 10)
menu.add_item(_('FAQ'), 'icon-question-sign', '/help/page/faq', 20)
menu.add_item(_('%s Wiki' % cfg.box_name), 'icon-pencil',
'http://wiki.debian.org/FreedomBox', 30)
menu.add_item(_('About'), 'icon-star', '/help/about', 100)
@@ -30,10 +31,13 @@ def about(request):
return TemplateResponse(request, 'about.html', {'title': title})
def default(request, page=''):
"""Serve the documentation pages"""
with open(os.path.join('doc', '%s.part.html' % page), 'r') as input_file:
main = input_file.read()
def helppage(request, page):
"""Serve a help page from the 'doc' directory"""
try:
input_file = open(os.path.join('doc', '%s.part.html' % page), 'r')
except IOError:
raise Http404
main = input_file.read()
title = _('%s Documentation') % cfg.product_name
return TemplateResponse(request, 'base.html',
+2 -1
View File
@@ -1,4 +1,5 @@
{% extends 'base.html' %}
{% load static %}
{% comment %}
#
# This file is part of Plinth.
@@ -20,7 +21,7 @@
{% block main_block %}
<img src="{{ basehref }}/static/theme/img/freedombox-logo-250px.png"
<img src="{% static 'theme/img/freedombox-logo-250px.png' %}"
class="main-graphic" />
<p>We live in a world where our use of the network is mediated by
+2 -2
View File
@@ -23,7 +23,7 @@
<p>There are a variety of places to go for help with
{{ cfg.product_name }} and the box it runs on.</p>
<p>This front end has a <a href="{{ basehref }}/help/view/plinth">
<p>This front end has a <a href="{% url 'help:helppage' 'plinth' %}">
developer's manual</a>. It isn't complete, but it is the first place
to look. Feel free to offer suggestions, edits, and screenshots for
completing it!</p>
@@ -39,7 +39,7 @@ about the {{ cfg.box_name }} and almost surely know nothing of this
front end, but they are an incredible resource for general Debian
issues.</p>
<p>There is no <a href="{{ basehref }}/help/view/faq">FAQ</a> because
<p>There is no <a href="{% url 'help:helppage' 'faq' %}">FAQ</a> because
the question frequency is currently zero for all questions.</p>
{% endblock %}
+7 -8
View File
@@ -20,15 +20,14 @@ URLs for the Help module
"""
from django.conf.urls import patterns, url
from django.core.urlresolvers import reverse_lazy
from django.views.generic import RedirectView
urlpatterns = patterns( # pylint: disable-msg=C0103
'modules.help.help',
url(r'^help/$', 'index'),
url(r'^help/index/$', 'index'),
url(r'^help/about/$', 'about'),
url(r'^help/view/(?P<page>design)/$', 'default'),
url(r'^help/view/(?P<page>plinth)/$', 'default'),
url(r'^help/view/(?P<page>hacking)/$', 'default'),
url(r'^help/view/(?P<page>faq)/$', 'default'),
)
url(r'^help/$', RedirectView.as_view(url=reverse_lazy('help:index'))),
url(r'^help/index/$', 'index', name='index'),
url(r'^help/about/$', 'about', name='about'),
url(r'^help/page/([\w]+)/$', 'helppage', name='helppage'),
)
+2 -3
View File
@@ -23,11 +23,10 @@ from django.conf.urls import patterns, url
import cfg
urlpatterns = patterns( # pylint: disable-msg=C0103
'',
url(r'^accounts/login/$', 'django.contrib.auth.views.login',
{'template_name': 'login.html'}),
{'template_name': 'login.html'}, name='login'),
url(r'^accounts/logout/$', 'django.contrib.auth.views.logout',
{'next_page': cfg.server_dir})
{'next_page': cfg.server_dir}, name='logout')
)
+1 -1
View File
@@ -28,7 +28,7 @@
{{ form|bootstrap }}
<p>When enabled, the owncloud installation will be available
from <a href="/owncloud">owncloud</a> on the web server. Visit
from <a href="{% url 'owncloud:index' %}">owncloud</a> on the web server. Visit
this URL to set up the initial administration account for
owncloud.</p>
+1 -1
View File
@@ -24,5 +24,5 @@ from django.conf.urls import patterns, url
urlpatterns = patterns( # pylint: disable-msg=C0103
'modules.owncloud.owncloud',
url(r'^apps/owncloud/$', 'index'),
url(r'^apps/owncloud/$', 'index', name='index'),
)
+1 -1
View File
@@ -24,5 +24,5 @@ from django.conf.urls import patterns, url
urlpatterns = patterns( # pylint: disable-msg=C0103
'modules.packages.packages',
url(r'^sys/packages/$', 'index'),
url(r'^sys/packages/$', 'index', name='index'),
)
@@ -49,7 +49,7 @@ there. In future, it might be possible to use your buddy's
<p>
<a class='btn btn-primary btn-lg'
href="{{ basehref }}/apps/pagekite/configure">Configure
href="{% url 'pagekite:configure' %}">Configure
PageKite</a>
</p>
+2 -2
View File
@@ -24,6 +24,6 @@ from django.conf.urls import patterns, url
urlpatterns = patterns( # pylint: disable-msg=C0103
'modules.pagekite.pagekite',
url(r'^apps/pagekite/$', 'index'),
url(r'^apps/pagekite/configure/$', 'configure'),
url(r'^apps/pagekite/$', 'index', name='index'),
url(r'^apps/pagekite/configure/$', 'configure', name='configure'),
)
+1 -1
View File
@@ -24,5 +24,5 @@ from django.conf.urls import patterns, url
urlpatterns = patterns( # pylint: disable-msg=C0103
'modules.system.system',
url(r'^sys/$', 'index'),
url(r'^sys/$', 'index', name='index'),
)
+1 -1
View File
@@ -24,5 +24,5 @@ from django.conf.urls import patterns, url
urlpatterns = patterns( # pylint: disable-msg=C0103
'modules.tor.tor',
url(r'^apps/tor/$', 'index')
url(r'^apps/tor/$', 'index', name='index')
)
+3 -3
View File
@@ -24,7 +24,7 @@ from django.conf.urls import patterns, url
urlpatterns = patterns( # pylint: disable-msg=C0103
'modules.users.users',
url(r'^sys/users/$', 'index'),
url(r'^sys/users/add/$', 'add'),
url(r'^sys/users/edit/$', 'edit')
url(r'^sys/users/$', 'index', name='index'),
url(r'^sys/users/add/$', 'add', name='add'),
url(r'^sys/users/edit/$', 'edit', name='edit')
)
+3 -3
View File
@@ -24,7 +24,7 @@ from django.conf.urls import patterns, url
urlpatterns = patterns( # pylint: disable-msg=C0103
'modules.xmpp.xmpp',
url(r'^apps/xmpp/$', 'index'),
url(r'^apps/xmpp/configure/$', 'configure'),
url(r'^apps/xmpp/register/$', 'register')
url(r'^apps/xmpp/$', 'index', name='index'),
url(r'^apps/xmpp/configure/$', 'configure', name='configure'),
url(r'^apps/xmpp/register/$', 'register', name='register')
)