Loading coin/dsl_ldap/templates/dsl_ldap/dsl.html 0 → 100644 +32 −0 Original line number Diff line number Diff line {% extends "base.html" %} {% load subnets %} {% block content %} <div class="row"> <form action="" method="post">{% csrf_token %} {% for message in messages %} <div class="message{% if message.tags %} {{ message.tags }}{% endif %}"> {{ message }} </div> {% endfor %} {{ form.non_field_errors }} <div>Numéro de téléphone : {{ object.phone_number }}</div> <div>Identifiant ADSL : {{ object.full_login }}</div> <div> {{ form.password.errors }} {{ form.password.label_tag }} {{ form.password }} Mettre un mot de passe vide pour en générer un nouveau automatiquement </div> <div>État : {{ object.activated|yesno:"activé,désactivé" }}</div> <div>Blocs IP : <ul> {% for subnet in object.ip_subnet.all %} <li>{{ subnet|prettify }}</li> {% endfor %} </ul></div> <input type="submit" value="Mettre à jour" /> </form> </div> {% endblock %} coin/dsl_ldap/urls.py 0 → 100644 +15 −0 Original line number Diff line number Diff line # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.conf.urls import patterns, url from .views import DSLView urlpatterns = patterns( '', # This is part of the generic configuration interface (the "name" is # the same as the "backend_name" of the model). url(r'^(?P<pk>\d+)$', DSLView.as_view(template_name="dsl_ldap/dsl.html"), name="details") ) coin/dsl_ldap/views.py +23 −2 Original line number Diff line number Diff line # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.shortcuts import render from django.shortcuts import get_object_or_404 from django.views.generic.edit import UpdateView from django.contrib.auth.decorators import login_required from django.contrib.messages.views import SuccessMessageMixin from django.utils.decorators import method_decorator # Create your views here. from .models import DSLConfiguration class DSLView(SuccessMessageMixin, UpdateView): model = DSLConfiguration fields = ['password'] success_message = "Configuration enregistrée avec succès !" @method_decorator(login_required) def dispatch(self, *args, **kwargs): return super(DSLView, self).dispatch(*args, **kwargs) def get_object(self): if self.request.user.is_superuser: return get_object_or_404(DSLConfiguration, pk=self.kwargs.get("pk")) # For normal users, ensure the VPN belongs to them. return get_object_or_404(DSLConfiguration, pk=self.kwargs.get("pk"), offersubscription__member=self.request.user) coin/urls.py +0 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ urlpatterns = patterns( url(r'^members/', include('coin.members.urls', namespace='members')), url(r'^billing/', include('coin.billing.urls', namespace='billing')), url(r'^subscription/', include('coin.offers.urls', namespace='subscription')), url(r'^admin/', include(admin.site.urls)), url(r'^hijack/', include('hijack.urls', namespace='hijack')), Loading Loading
coin/dsl_ldap/templates/dsl_ldap/dsl.html 0 → 100644 +32 −0 Original line number Diff line number Diff line {% extends "base.html" %} {% load subnets %} {% block content %} <div class="row"> <form action="" method="post">{% csrf_token %} {% for message in messages %} <div class="message{% if message.tags %} {{ message.tags }}{% endif %}"> {{ message }} </div> {% endfor %} {{ form.non_field_errors }} <div>Numéro de téléphone : {{ object.phone_number }}</div> <div>Identifiant ADSL : {{ object.full_login }}</div> <div> {{ form.password.errors }} {{ form.password.label_tag }} {{ form.password }} Mettre un mot de passe vide pour en générer un nouveau automatiquement </div> <div>État : {{ object.activated|yesno:"activé,désactivé" }}</div> <div>Blocs IP : <ul> {% for subnet in object.ip_subnet.all %} <li>{{ subnet|prettify }}</li> {% endfor %} </ul></div> <input type="submit" value="Mettre à jour" /> </form> </div> {% endblock %}
coin/dsl_ldap/urls.py 0 → 100644 +15 −0 Original line number Diff line number Diff line # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.conf.urls import patterns, url from .views import DSLView urlpatterns = patterns( '', # This is part of the generic configuration interface (the "name" is # the same as the "backend_name" of the model). url(r'^(?P<pk>\d+)$', DSLView.as_view(template_name="dsl_ldap/dsl.html"), name="details") )
coin/dsl_ldap/views.py +23 −2 Original line number Diff line number Diff line # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.shortcuts import render from django.shortcuts import get_object_or_404 from django.views.generic.edit import UpdateView from django.contrib.auth.decorators import login_required from django.contrib.messages.views import SuccessMessageMixin from django.utils.decorators import method_decorator # Create your views here. from .models import DSLConfiguration class DSLView(SuccessMessageMixin, UpdateView): model = DSLConfiguration fields = ['password'] success_message = "Configuration enregistrée avec succès !" @method_decorator(login_required) def dispatch(self, *args, **kwargs): return super(DSLView, self).dispatch(*args, **kwargs) def get_object(self): if self.request.user.is_superuser: return get_object_or_404(DSLConfiguration, pk=self.kwargs.get("pk")) # For normal users, ensure the VPN belongs to them. return get_object_or_404(DSLConfiguration, pk=self.kwargs.get("pk"), offersubscription__member=self.request.user)
coin/urls.py +0 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ urlpatterns = patterns( url(r'^members/', include('coin.members.urls', namespace='members')), url(r'^billing/', include('coin.billing.urls', namespace='billing')), url(r'^subscription/', include('coin.offers.urls', namespace='subscription')), url(r'^admin/', include(admin.site.urls)), url(r'^hijack/', include('hijack.urls', namespace='hijack')), Loading