mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-08-19 21:53:41 +00:00
Caché des trucs
This commit is contained in:
parent
d4e8da7115
commit
7f47f985c9
5 changed files with 26 additions and 8 deletions
|
@ -27,5 +27,6 @@ urlpatterns = [
|
|||
url(r'^history/(?P<object>iptype)/(?P<id>[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'),
|
||||
]
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue