Merge branch 'Kerl/django111-urls' into 'supportBDS'

Write modern-style urls

- Proper use of include
- Defining namespaces (I do not use them for now because many urls are
  going to change)
- Do not try to reverse with old-style references: 'cof.views.XXX'

See merge request !178
This commit is contained in:
Martin Pepin 2017-02-23 17:32:05 +01:00
commit 646b213d97
18 changed files with 91 additions and 52 deletions

View file

@ -16,7 +16,7 @@
<h4 class="bda-prix">Total à payer : {{ total|floatformat }}€</h4>
<br/>
<p>Ne manque pas un spectacle avec le
<a href="{% url "cof.views.calendar" %}">calendrier
<a href="{% url "calendar" %}">calendrier
automatique&#8239;!</a></p>
{% else %}
<h3>Vous n'avez aucune place :(</h3>

View file

@ -3,7 +3,7 @@
{% block content %}
<header>
<div class="container banner">
<a href="{% url "cof.views.home" %}">
<a href="{% url "home" %}">
<h1>GestioCOF</h1>
{% block homelink %}
<span class="glyphicon glyphicon-home" aria-hidden=true></span>

View file

@ -12,7 +12,7 @@ souscrire aux événements du COF et/ou aux spectacles BdA.
{% if token %}
<p>Votre calendrier (compatible avec toutes les applications d'agenda) se trouve à
<a href="{% url 'cof.views.calendar_ics' token %}">cette adresse</a>.</p>
<a href="{% url 'calendar.ics' token %}">cette adresse</a>.</p>
<ul>
<li>Pour l'ajouter à Thunderbird (lightning), il faut copier ce lien et aller

View file

@ -8,7 +8,7 @@
{% if event.details %}
<p>{{ event.details }}</p>
{% endif %}
<form method="post" action="{% url 'cof.views.event' event.id %}">
<form method="post" action="{% url 'event' event.id %}">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" class="btn-submit" value="Enregistrer" />

View file

@ -15,7 +15,7 @@
{% if survey.details %}
<p>{{ survey.details }}</p>
{% endif %}
<form class="form-horizontal" method="post" action="{% url 'cof.views.survey' survey.id %}">
<form class="form-horizontal" method="post" action="{% url 'survey' survey.id %}">
{% csrf_token %}
{{ form | bootstrap}}

View file

@ -7,15 +7,15 @@
<h2>Liens utiles du COF</h2>
<h3>COF</h3>
<ul>
<li><a href="{% url 'cof.views.export_members' %}">Export des membres du COF</a></li>
<li><a href="{% url 'cof.views.liste_diffcof' %}">Diffusion COF</a></li>
<li><a href="{% url 'export.members' %}">Export des membres du COF</a></li>
<li><a href="{% url 'liste_diffcof' %}">Diffusion COF</a></li>
</ul>
<h3>Mega</h3>
<ul>
<li><a href="{% url 'cof.views.export_mega_participants' %}">Export des non-orgas uniquement</a></li>
<li><a href="{% url 'cof.views.export_mega_orgas' %}">Export des orgas uniquement</a></li>
<li><a href="{% url 'cof.views.export_mega' %}">Export de tout le monde</a></li>
<li><a href="{% url 'export.mega.participants' %}">Export des non-orgas uniquement</a></li>
<li><a href="{% url 'export.mega.orgas' %}">Export des orgas uniquement</a></li>
<li><a href="{% url 'export.mega' %}">Export de tout le monde</a></li>
</ul>
<p>Note&nbsp;: pour ouvrir les fichiers .csv avec Excel, il faut

View file

@ -11,7 +11,7 @@
{% endif %}
{% include "tristate_js.html" %}
<h3>Filtres</h3>
<form method="post" action="{% url 'cof.views.event_status' event.id %}">
<form method="post" action="{% url 'event.status' event.id %}">
{% csrf_token %}
{{ form.as_p }}
<input style="margin-top:10px;" type="submit" class="btn btn-primary" value="Filtrer" />

View file

@ -13,7 +13,7 @@
<div class="hm-block">
<ul>
{% for event in open_events %}
<li><a href="{% url "cof.views.event" event.id %}">{{ event.title }}</a></li>
<li><a href="{% url "event" event.id %}">{{ event.title }}</a></li>
{% endfor %}
</ul>
</div>
@ -23,7 +23,7 @@
<div class="hm-block">
<ul>
{% for survey in open_surveys %}
<li><a href="{% url "cof.views.survey" survey.id %}">{{ survey.title }}</a></li>
<li><a href="{% url "survey" survey.id %}">{{ survey.title }}</a></li>
{% endfor %}
</ul>
</div>
@ -54,11 +54,11 @@
<h3 class="block-title">Divers<span class="pull-right glyphicon glyphicon-question-sign"></span></h3>
<div class="hm-block">
<ul>
<li><a href="{% url "cof.views.calendar" %}">Calendrier dynamique</a></li>
<li><a href="{% url "calendar" %}">Calendrier dynamique</a></li>
{% if user.profile.cof.is_cof %}<li><a href="{% url "petits-cours-inscription" %}">Inscription pour donner des petits cours</a></li>{% endif %}
<li><a href="{% url "gestion:profile" %}">Éditer mon profil</a></li>
{% if not user.profile.login_clipper %}<li><a href="{% url "django.contrib.auth.views.password_change" %}">Changer mon mot de passe</a></li>{% endif %}
{% if not user.profile.login_clipper %}<li><a href="{% url "password_change" %}">Changer mon mot de passe</a></li>{% endif %}
</ul>
</div>
{% endif %}
@ -71,16 +71,16 @@
<h4>Général</h4>
<li><a href="{% url "admin:index" %}">Administration générale</a></li>
<li><a href="{% url "petits-cours-demandes-list" %}">Demandes de petits cours</a></li>
<li><a href="{% url "cof.views.registration" %}">Inscription d'un nouveau membre</a></li>
<li><a href="{% url "registration" %}">Inscription d'un nouveau membre</a></li>
<li><a href="{% url "liste-clubs" %}">Gestion des clubs</a></li>
</ul>
<ul>
<h4>Évènements & Sondages</h4>
{% for event in events %}
<li><a href="{% url "cof.views.event_status" event.id %}">Événement : {{ event.title }}</a></li>
<li><a href="{% url "event.status" event.id %}">Événement : {{ event.title }}</a></li>
{% endfor %}
{% for survey in surveys %}
<li><a href="{% url "cof.views.survey_status" survey.id %}">Sondage : {{ survey.title }}</a></li>
<li><a href="{% url "survey.status" survey.id %}">Sondage : {{ survey.title }}</a></li>
{% endfor %}
</ul>
</div>
@ -105,8 +105,8 @@
<h3 class="block-title">Liens utiles<span class="pull-right glyphicon glyphicon-link"></span></h3>
<div class="hm-block">
<ul>
<li><a href="{% url "cof.views.utile_cof" %}">Liens utiles du COF</a></li>
<li><a href="{% url "cof.views.utile_bda" %}">Liens utiles BdA</a></li>
<li><a href="{% url "utile_cof" %}">Liens utiles du COF</a></li>
<li><a href="{% url "utile_bda" %}">Liens utiles BdA</a></li>
</ul>
</div>
</div>

View file

@ -16,7 +16,7 @@
// On attend que la page soit prête pour executer le code
$(document).ready(function() {
$('input#search_autocomplete').yourlabsAutocomplete({
url: '{% url 'cof.autocomplete.autocomplete' %}',
url: '{% url 'autocomplete' %}',
minimumCharacters: 3,
id: 'search_autocomplete',
choiceSelector: 'li:has(a)',

View file

@ -5,5 +5,5 @@
{% block realcontent %}
<h2>Mot de passe modifié avec succès !</h2>
<h3><a href="{% url "cof.views.home" %}">Retour au menu principal</a></h3>
<h3><a href="{% url "home" %}">Retour au menu principal</a></h3>
{% endblock %}

View file

@ -5,7 +5,7 @@
{% block realcontent %}
<h2>Changement de mot de passe</h2>
<form class="form-horizontal" method="post" action="{% url 'django.contrib.auth.views.password_change' %}">
<form class="form-horizontal" method="post" action="{% url 'password_change' %}">
{% csrf_token %}
{{ form | bootstrap }}
<input type="submit" class="btn btn-primary pull-right" value="Changer" />

View file

@ -7,7 +7,7 @@
{% else %}
<h3>Inscription d'un nouveau compte (extérieur ?)</h3>
{% endif %}
<form role="form" id="profile" method="post" action="{% url 'cof.views.registration' %}">
<form role="form" id="profile" method="post" action="{% url 'registration' %}">
{% csrf_token %}
<table>
{{ user_form | bootstrap }}

View file

@ -11,7 +11,7 @@
{% endif %}
<h3>Filtres</h3>
{% include "tristate_js.html" %}
<form method="post" action="{% url 'cof.views.survey_status' survey.id %}">
<form method="post" action="{% url 'survey.status' survey.id %}">
{% csrf_token %}
{{ form.as_p }}
<input style="margin-top:10px;" type="submit" class="btn btn-primary" value="Filtrer" />

View file

@ -7,7 +7,7 @@
<h2>Liens utiles du BdA</h2>
<h3>Listes mail</h3>
<ul>
<li><a href="{% url 'cof.views.liste_bdadiff' %}">BdA diffusion</a></li>
<li><a href="{% url 'cof.views.liste_bdarevente' %}">BdA revente</a></li>
<li><a href="{% url 'liste_bdadiff' %}">BdA diffusion</a></li>
<li><a href="{% url 'liste_bdarevente' %}">BdA revente</a></li>
</ul>
{% endblock %}

View file

@ -7,12 +7,20 @@ from . import views, petits_cours_views
export_patterns = [
url(r'^members$', views.export_members),
url(r'^members$',
views.export_members,
name="export.members"),
url(r'^mega/avecremarques$', views.export_mega_remarksonly),
url(r'^mega/participants$', views.export_mega_participants),
url(r'^mega/orgas$', views.export_mega_orgas),
url(r'^mega/participants$',
views.export_mega_participants,
name="export.mega.participants"),
url(r'^mega/orgas$',
views.export_mega_orgas,
name="export.mega.orgas"),
url(r'^mega/(?P<type>.+)$', views.export_mega_bytype),
url(r'^mega$', views.export_mega),
url(r'^mega$',
views.export_mega,
name="export.mega"),
]
petitcours_patterns = [
@ -37,19 +45,30 @@ petitcours_patterns = [
]
surveys_patterns = [
url(r'^(?P<survey_id>\d+)/status$', views.survey_status),
url(r'^(?P<survey_id>\d+)$', views.survey),
url(r'^(?P<survey_id>\d+)/status$',
views.survey_status,
name="survey.status"),
url(r'^(?P<survey_id>\d+)$',
views.survey,
name="survey"),
]
events_patterns = [
url(r'^(?P<event_id>\d+)$', views.event),
url(r'^(?P<event_id>\d+)/status$', views.event_status),
url(r'^(?P<event_id>\d+)$',
views.event,
name="event"),
url(r'^(?P<event_id>\d+)/status$',
views.event_status,
name="event.status"),
]
calendar_patterns = [
url(r'^subscription$', 'cof.views.calendar'),
url(r'^subscription$',
views.calendar,
name="calendar"),
url(r'^(?P<token>[a-z0-9-]+)/calendar.ics$',
'cof.views.calendar_ics')
views.calendar_ics,
name="calendar.ics")
]
clubs_patterns = [

View file

@ -5,6 +5,9 @@ Fichier principal de configuration des urls du projet GestioCOF
"""
import autocomplete_light
import gestion.urls
import kfet.urls
import bda.urls
from django.conf import settings
from django.conf.urls import include, url
@ -21,19 +24,20 @@ from cof.autocomplete import autocomplete
from gestion import views as gestion_views
autocomplete_light.autodiscover()
admin.autodiscover()
urlpatterns = [
# Page d'accueil
url(r'^$', cof_views.home, name='home'),
# The common views
url(r"^", include("gestion.urls", namespace='gestion')),
url(r"^", include(gestion.urls, namespace="gestion")),
# Admin urls
url(r'^admin/logout/', gestion_views.logout),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', admin.site.urls),
# Le BdA
url(r'^bda/', include('bda.urls')),
url(r'^bda/', include(bda.urls)),
# Les exports
url(r'^export/', include(export_patterns)),
# Les petits cours
@ -47,12 +51,16 @@ urlpatterns = [
# Clubs
url(r'^clubs/', include(clubs_patterns)),
# Infos persos
url(r'^outsider/password-change$', django_views.password_change),
url(r'^outsider/password-change$',
django_views.password_change,
name="password_change"),
url(r'^outsider/password-change-done$',
django_views.password_change_done,
name='password_change_done'),
# Inscription d'un nouveau membre
url(r'^registration$', cof_views.registration),
url(r'^registration$',
cof_views.registration,
name="registration"),
url(r'^registration/clipper/(?P<login_clipper>[\w-]+)$',
cof_views.registration_form2, name="clipper-registration"),
url(r'^registration/user/(?P<username>.+)$',
@ -60,21 +68,33 @@ urlpatterns = [
url(r'^registration/empty$', cof_views.registration_form2,
name="empty-registration"),
# Autocompletion
url(r'^autocomplete/registration$', autocomplete),
url(r'^autocomplete/registration$',
autocomplete,
name="autocomplete"),
url(r'^autocomplete/', include('autocomplete_light.urls')),
# Liens utiles du COF et du BdA
url(r'^utile_cof$', cof_views.utile_cof),
url(r'^utile_bda$', cof_views.utile_bda),
url(r'^utile_bda/bda_diff$', cof_views.liste_bdadiff),
url(r'^utile_cof/diff_cof$', cof_views.liste_diffcof),
url(r'^utile_bda/bda_revente$', cof_views.liste_bdarevente),
url(r'^k-fet/', include('kfet.urls')),
url(r'^utile_cof$',
cof_views.utile_cof,
name="utile_cof"),
url(r'^utile_bda$',
cof_views.utile_bda,
name="utile_bda"),
url(r'^utile_bda/bda_diff$',
cof_views.liste_bdadiff,
name="liste_bdadiff"),
url(r'^utile_cof/diff_cof$',
cof_views.liste_diffcof,
name="liste_diffcof"),
url(r'^utile_bda/bda_revente$',
cof_views.liste_bdarevente,
name="liste_bdarevente"),
url(r'^k-fet/', include(kfet.urls)),
]
if 'debug_toolbar' in settings.INSTALLED_APPS:
import debug_toolbar
urlpatterns += [
url(r'^__debug__/', include(debug_toolbar.urls)),
url(r'^__debug__/', debug_toolbar.urls),
]
# Si on est en production, MEDIA_ROOT est servi par Apache.

View file

@ -5,7 +5,7 @@ from django_cas_ng import views as django_cas_views
from . import views
app_name = "gestion"
urlpatterns = [
# Profile edition
url(r"^profile/?$", views.profile, name="profile"),

View file

@ -16,7 +16,7 @@ from .forms import ProfileForm, UserForm
def login(request):
if request.user.is_authenticated():
return redirect("cof.views.home")
return redirect("home")
context = {}
# Fetch the next page from the request data
if request.method == "GET" and 'next' in request.GET: