mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
removes hard-coded urls, calls reverse. Fix issue #63
This commit is contained in:
parent
23732800b3
commit
d3f07cf63a
4 changed files with 16 additions and 13 deletions
|
@ -90,7 +90,7 @@ def edit_options(request, section):
|
||||||
if not can:
|
if not can:
|
||||||
messages.error(request, msg or "Vous ne pouvez pas éditer cette\
|
messages.error(request, msg or "Vous ne pouvez pas éditer cette\
|
||||||
option.")
|
option.")
|
||||||
return redirect('/')
|
return redirect(reverse('index'))
|
||||||
options = form_instance(
|
options = form_instance(
|
||||||
request.POST or None,
|
request.POST or None,
|
||||||
instance=options_instance
|
instance=options_instance
|
||||||
|
|
|
@ -43,7 +43,7 @@ from django.contrib.auth import views as auth_views
|
||||||
from .views import index
|
from .views import index
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', index),
|
url(r'^$', index, name='index'),
|
||||||
url('^logout/', auth_views.logout, {'next_page': '/'}),
|
url('^logout/', auth_views.logout, {'next_page': '/'}),
|
||||||
url('^', include('django.contrib.auth.urls')),
|
url('^', include('django.contrib.auth.urls')),
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
|
|
|
@ -416,7 +416,7 @@ def create_ports(request, switch_id):
|
||||||
switch = Switch.objects.get(pk=switch_id)
|
switch = Switch.objects.get(pk=switch_id)
|
||||||
except Switch.DoesNotExist:
|
except Switch.DoesNotExist:
|
||||||
messages.error(request, u"Switch inexistant")
|
messages.error(request, u"Switch inexistant")
|
||||||
return redirect("/topologie/")
|
return redirect(reverse('topologie:index'))
|
||||||
|
|
||||||
s_begin = s_end = 0
|
s_begin = s_end = 0
|
||||||
nb_ports = switch.ports.count()
|
nb_ports = switch.ports.count()
|
||||||
|
@ -439,7 +439,10 @@ def create_ports(request, switch_id):
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
messages.error(request, ''.join(e))
|
messages.error(request, ''.join(e))
|
||||||
|
|
||||||
return redirect("/topologie/switch/" + str(switch.id))
|
return redirect(reverse(
|
||||||
|
'topologie:index-port',
|
||||||
|
kwargs={'switch_id':switch_id}
|
||||||
|
))
|
||||||
|
|
||||||
return form({'id_switch': switch_id, 'topoform': port_form}, 'topologie/switch.html', request)
|
return form({'id_switch': switch_id, 'topoform': port_form}, 'topologie/switch.html', request)
|
||||||
|
|
||||||
|
@ -573,7 +576,7 @@ def new_model_switch(request):
|
||||||
reversion.set_user(request.user)
|
reversion.set_user(request.user)
|
||||||
reversion.set_comment("Création")
|
reversion.set_comment("Création")
|
||||||
messages.success(request, "Le modèle a été créé")
|
messages.success(request, "Le modèle a été créé")
|
||||||
return redirect("/topologie/index_model_switch/")
|
return redirect(reverse('topologie:index-model-switch'))
|
||||||
return form({'topoform': model_switch}, 'topologie/topo.html', request)
|
return form({'topoform': model_switch}, 'topologie/topo.html', request)
|
||||||
|
|
||||||
|
|
||||||
|
@ -591,7 +594,7 @@ def edit_model_switch(request, model_switch, model_switch_id):
|
||||||
field for field in model_switch.changed_data)
|
field for field in model_switch.changed_data)
|
||||||
)
|
)
|
||||||
messages.success(request, "Le modèle a bien été modifié")
|
messages.success(request, "Le modèle a bien été modifié")
|
||||||
return redirect("/topologie/index_model_switch/")
|
return redirect(reverse('topologie:index-model-switch'))
|
||||||
return form({'topoform': model_switch}, 'topologie/topo.html', request)
|
return form({'topoform': model_switch}, 'topologie/topo.html', request)
|
||||||
|
|
||||||
|
|
||||||
|
@ -609,7 +612,7 @@ def del_model_switch(request, model_switch_id):
|
||||||
except ProtectedError:
|
except ProtectedError:
|
||||||
messages.error(request, "Le modèle %s est affectée à un autre objet,\
|
messages.error(request, "Le modèle %s est affectée à un autre objet,\
|
||||||
impossible de la supprimer (switch ou user)" % model_switch)
|
impossible de la supprimer (switch ou user)" % model_switch)
|
||||||
return redirect("/topologie/index_model_switch/")
|
return redirect(reverse('topologie:index-model-switch'))
|
||||||
return form({
|
return form({
|
||||||
'objet': model_switch,
|
'objet': model_switch,
|
||||||
'objet_name': 'Modèle de switch'
|
'objet_name': 'Modèle de switch'
|
||||||
|
@ -627,7 +630,7 @@ def new_constructor_switch(request):
|
||||||
reversion.set_user(request.user)
|
reversion.set_user(request.user)
|
||||||
reversion.set_comment("Création")
|
reversion.set_comment("Création")
|
||||||
messages.success(request, "Le constructeur a été créé")
|
messages.success(request, "Le constructeur a été créé")
|
||||||
return redirect("/topologie/index_model_switch/")
|
return redirect(reverse('topologie:index-model-switch'))
|
||||||
return form({'topoform': constructor_switch}, 'topologie/topo.html', request)
|
return form({'topoform': constructor_switch}, 'topologie/topo.html', request)
|
||||||
|
|
||||||
|
|
||||||
|
@ -645,7 +648,7 @@ def edit_constructor_switch(request, constructor_switch, constructor_switch_id):
|
||||||
field for field in constructor_switch.changed_data)
|
field for field in constructor_switch.changed_data)
|
||||||
)
|
)
|
||||||
messages.success(request, "Le modèle a bien été modifié")
|
messages.success(request, "Le modèle a bien été modifié")
|
||||||
return redirect("/topologie/index_model_switch/")
|
return redirect(reverse('topologie:index-model-switch'))
|
||||||
return form({'topoform': constructor_switch}, 'topologie/topo.html', request)
|
return form({'topoform': constructor_switch}, 'topologie/topo.html', request)
|
||||||
|
|
||||||
|
|
||||||
|
@ -663,7 +666,7 @@ def del_constructor_switch(request, constructor_switch_id):
|
||||||
except ProtectedError:
|
except ProtectedError:
|
||||||
messages.error(request, "Le constructeur %s est affecté à un autre objet,\
|
messages.error(request, "Le constructeur %s est affecté à un autre objet,\
|
||||||
impossible de la supprimer (switch ou user)" % constructor_switch)
|
impossible de la supprimer (switch ou user)" % constructor_switch)
|
||||||
return redirect("/topologie/index_model_switch/")
|
return redirect(reverse('topologie:index-model-switch'))
|
||||||
return form({
|
return form({
|
||||||
'objet': constructor_switch,
|
'objet': constructor_switch,
|
||||||
'objet_name': 'Constructeur de switch'
|
'objet_name': 'Constructeur de switch'
|
||||||
|
|
|
@ -111,7 +111,7 @@ def password_change_action(u_form, user, request, req=False):
|
||||||
messages.success(request, "Le mot de passe a changé")
|
messages.success(request, "Le mot de passe a changé")
|
||||||
if req:
|
if req:
|
||||||
req.delete()
|
req.delete()
|
||||||
return redirect("/")
|
return redirect(reverse('index'))
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
'users:profil',
|
'users:profil',
|
||||||
kwargs={'userid':str(user.id)}
|
kwargs={'userid':str(user.id)}
|
||||||
|
@ -809,7 +809,7 @@ def reset_password(request):
|
||||||
user.reset_passwd_mail(request)
|
user.reset_passwd_mail(request)
|
||||||
messages.success(request, "Un mail pour l'initialisation du mot\
|
messages.success(request, "Un mail pour l'initialisation du mot\
|
||||||
de passe a été envoyé")
|
de passe a été envoyé")
|
||||||
redirect("/")
|
redirect(reverse('index'))
|
||||||
return form({'userform': userform}, 'users/user.html', request)
|
return form({'userform': userform}, 'users/user.html', request)
|
||||||
|
|
||||||
|
|
||||||
|
@ -822,7 +822,7 @@ def process(request, token):
|
||||||
return process_passwd(request, req)
|
return process_passwd(request, req)
|
||||||
else:
|
else:
|
||||||
messages.error(request, "Entrée incorrecte, contactez un admin")
|
messages.error(request, "Entrée incorrecte, contactez un admin")
|
||||||
redirect("/")
|
redirect(reverse('index'))
|
||||||
|
|
||||||
|
|
||||||
def process_passwd(request, req):
|
def process_passwd(request, req):
|
||||||
|
|
Loading…
Reference in a new issue