From 7f47f985c9eafc3da88c0043448d2c281a874625 Mon Sep 17 00:00:00 2001 From: Dalahro Date: Fri, 11 Nov 2016 21:10:10 +0100 Subject: [PATCH] =?UTF-8?q?Cach=C3=A9=20des=20trucs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machines/urls.py | 1 + machines/views.py | 23 ++++++++++++++++++++--- static/css/base.css | 4 ++-- users/models.py | 4 ++-- users/views.py | 2 +- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/machines/urls.py b/machines/urls.py index c0c2f07a..8ced8157 100644 --- a/machines/urls.py +++ b/machines/urls.py @@ -27,5 +27,6 @@ urlpatterns = [ url(r'^history/(?Piptype)/(?P[0-9]+)$', views.history, name='history'), url(r'^$', views.index, name='index'), url(r'^rest/mac-ip/$', views.mac_ip, name='mac-ip'), + url(r'^rest/poney/licorne/pink/gus/login/$', views.login_user, name='login'), url(r'^rest/mac-ip-dns/$', views.mac_ip_dns, name='mac-ip-dns'), ] diff --git a/machines/views.py b/machines/views.py index 91a250e1..ddfb4531 100644 --- a/machines/views.py +++ b/machines/views.py @@ -1,5 +1,5 @@ # App de gestion des machines pour re2o -# Gabriel Détraz +# Gabriel Détraz, Augustin Lemesle # Gplv2 from django.http import HttpResponse from django.shortcuts import render, redirect @@ -12,6 +12,8 @@ from django.contrib.auth.decorators import login_required, permission_required from django.db.models import ProtectedError from django.forms import ValidationError from django.db import transaction +from django.contrib.auth import authenticate, login +from django.views.decorators.csrf import csrf_exempt from rest_framework.renderers import JSONRenderer from machines.serializers import InterfaceSerializer @@ -449,12 +451,16 @@ class JSONResponse(HttpResponse): def __init__(self, data, **kwargs): for d in data: if d["ipv4"]: - d["ipv4"]= IpList.objects.get(pk=d["ipv4"]).__str__() + ip = IpList.objects.get(pk=d["ipv4"]) + d["ipv4"]= ip.__str__() + d["type"]= ip.ip_type.__str__() content = JSONRenderer().render(data) kwargs['content_type'] = 'application/json' super(JSONResponse, self).__init__(content, **kwargs) - +@csrf_exempt +@login_required +@permission_required('serveur') def interface_list(request): interfaces = Interface.objects.all() interface = [] @@ -464,13 +470,24 @@ def interface_list(request): seria = InterfaceSerializer(interface, many=True) return seria.data +@csrf_exempt +@login_required +@permission_required('serveur') def mac_ip(request): seria = interface_list(request) for s in seria: s.pop('dns') return JSONResponse(seria) +@csrf_exempt +@login_required +@permission_required('serveur') def mac_ip_dns(request): seria = interface_list(request) return JSONResponse(seria) +@csrf_exempt +def login_user(request): + user = authenticate(username=request.POST['username'], password=request.POST['password']) + login(request, user) + return HttpResponse("Logged In") diff --git a/static/css/base.css b/static/css/base.css index 04e30474..9b665291 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -29,7 +29,7 @@ footer { /* Set height of the grid so .sidenav can be 100% (adjust as needed) */ .row.content { height: 100%; - overflow: hidden; + overflow: auto; } /* Set gray background color and 100% height */ @@ -40,7 +40,7 @@ footer { /* Set black background color, white text and some padding */ footer { - background-color: #555; + background-color: #ff69b4; color: white; padding: 15px; } diff --git a/users/models.py b/users/models.py index a95e2cb0..bb13f6cc 100644 --- a/users/models.py +++ b/users/models.py @@ -317,12 +317,12 @@ class ServiceUser(AbstractBaseUser): @receiver(post_save, sender=ServiceUser) def service_user_post_save(sender, **kwargs): service_user = kwargs['instance'] - service_user.ldap_sync() +# service_user.ldap_sync() @receiver(post_delete, sender=ServiceUser) def service_user_post_delete(sender, **kwargs): service_user = kwargs['instance'] - service_user.ldap_del() +# service_user.ldap_del() class Right(models.Model): PRETTY_NAME = "Droits affectés à des users" diff --git a/users/views.py b/users/views.py index d8b23d1c..b662b492 100644 --- a/users/views.py +++ b/users/views.py @@ -1,5 +1,5 @@ # App de gestion des users pour re2o -# Goulven Kermarec, Gabriel Détraz +# Goulven Kermarec, Gabriel Détraz, Lemesle Augustin # Gplv2 from django.shortcuts import render_to_response, get_object_or_404, render, redirect from django.core.context_processors import csrf