8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 07:02:26 +00:00

removes hard-coded urls, calls reverse. Fix issue #63

This commit is contained in:
FERNET Laouen 2018-01-07 20:29:43 +01:00 committed by root
parent 23732800b3
commit d3f07cf63a
4 changed files with 16 additions and 13 deletions

View file

@ -90,7 +90,7 @@ def edit_options(request, section):
if not can:
messages.error(request, msg or "Vous ne pouvez pas éditer cette\
option.")
return redirect('/')
return redirect(reverse('index'))
options = form_instance(
request.POST or None,
instance=options_instance

View file

@ -43,7 +43,7 @@ from django.contrib.auth import views as auth_views
from .views import index
urlpatterns = [
url(r'^$', index),
url(r'^$', index, name='index'),
url('^logout/', auth_views.logout, {'next_page': '/'}),
url('^', include('django.contrib.auth.urls')),
url(r'^admin/', include(admin.site.urls)),

View file

@ -416,7 +416,7 @@ def create_ports(request, switch_id):
switch = Switch.objects.get(pk=switch_id)
except Switch.DoesNotExist:
messages.error(request, u"Switch inexistant")
return redirect("/topologie/")
return redirect(reverse('topologie:index'))
s_begin = s_end = 0
nb_ports = switch.ports.count()
@ -439,7 +439,10 @@ def create_ports(request, switch_id):
except ValidationError as 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)
@ -573,7 +576,7 @@ def new_model_switch(request):
reversion.set_user(request.user)
reversion.set_comment("Création")
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)
@ -591,7 +594,7 @@ def edit_model_switch(request, model_switch, model_switch_id):
field for field in model_switch.changed_data)
)
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)
@ -609,7 +612,7 @@ def del_model_switch(request, model_switch_id):
except ProtectedError:
messages.error(request, "Le modèle %s est affectée à un autre objet,\
impossible de la supprimer (switch ou user)" % model_switch)
return redirect("/topologie/index_model_switch/")
return redirect(reverse('topologie:index-model-switch'))
return form({
'objet': model_switch,
'objet_name': 'Modèle de switch'
@ -627,7 +630,7 @@ def new_constructor_switch(request):
reversion.set_user(request.user)
reversion.set_comment("Création")
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)
@ -645,7 +648,7 @@ def edit_constructor_switch(request, constructor_switch, constructor_switch_id):
field for field in constructor_switch.changed_data)
)
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)
@ -663,7 +666,7 @@ def del_constructor_switch(request, constructor_switch_id):
except ProtectedError:
messages.error(request, "Le constructeur %s est affecté à un autre objet,\
impossible de la supprimer (switch ou user)" % constructor_switch)
return redirect("/topologie/index_model_switch/")
return redirect(reverse('topologie:index-model-switch'))
return form({
'objet': constructor_switch,
'objet_name': 'Constructeur de switch'

View file

@ -111,7 +111,7 @@ def password_change_action(u_form, user, request, req=False):
messages.success(request, "Le mot de passe a changé")
if req:
req.delete()
return redirect("/")
return redirect(reverse('index'))
return redirect(reverse(
'users:profil',
kwargs={'userid':str(user.id)}
@ -809,7 +809,7 @@ def reset_password(request):
user.reset_passwd_mail(request)
messages.success(request, "Un mail pour l'initialisation du mot\
de passe a été envoyé")
redirect("/")
redirect(reverse('index'))
return form({'userform': userform}, 'users/user.html', request)
@ -822,7 +822,7 @@ def process(request, token):
return process_passwd(request, req)
else:
messages.error(request, "Entrée incorrecte, contactez un admin")
redirect("/")
redirect(reverse('index'))
def process_passwd(request, req):