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

Ajoute des vues pour la suppression, et nettoie le code

This commit is contained in:
chirac 2016-07-18 18:37:52 +02:00
parent 17ba68cb4e
commit acd1c89d38
7 changed files with 87 additions and 10 deletions

View file

@ -0,0 +1,16 @@
{% extends "machines/sidebar.html" %}
{% load bootstrap3 %}
{% block title %}Création et modification de machines{% endblock %}
{% block content %}
<form class="form" method="post">
{% csrf_token %}
<h4>Attention, voulez-vous vraiment supprimer cet objet {{ objet_name }} ( {{ objet }} ) ?</h4>
{% bootstrap_button "Confirmer" button_type="submit" icon="trash" %}
</form>
<br />
<br />
<br />
{% endblock %}

View file

@ -147,9 +147,11 @@ def del_facture(request, factureid):
if (facture.control or not facture.valid):
messages.error(request, "Vous ne pouvez pas editer une facture controlée ou invalidée par le trésorier")
return redirect("/cotisations/")
facture.delete()
messages.success(request, "La facture a bien été supprimée")
return redirect("/cotisations/")
if request.method == "POST":
facture.delete()
messages.success(request, "La facture a été détruite")
return redirect("/cotisations/")
return form({'objet': facture, 'objet_name': 'facture'}, 'cotisations/delete.html', request)
@login_required
@permission_required('trésorier')

View file

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('machines', '0018_auto_20160708_1813'),
]
operations = [
migrations.AlterField(
model_name='interface',
name='machine',
field=models.ForeignKey(to='machines.Machine'),
),
]

View file

@ -0,0 +1,16 @@
{% extends "machines/sidebar.html" %}
{% load bootstrap3 %}
{% block title %}Création et modification de machines{% endblock %}
{% block content %}
<form class="form" method="post">
{% csrf_token %}
<h4>Attention, voulez-vous vraiment supprimer cet objet {{ objet_name }} ( {{ objet }} ) ?</h4>
{% bootstrap_button "Confirmer" button_type="submit" icon="trash" %}
</form>
<br />
<br />
<br />
{% endblock %}

View file

@ -135,9 +135,11 @@ def del_machine(request, machineid):
if machine.user != request.user:
messages.error(request, "Vous ne pouvez pas éditer une machine d'un autre user que vous sans droit")
return redirect("/users/profil/" + str(request.user.id))
machine.delete()
messages.success(request, "La machine a été détruite")
return redirect("/users/profil/" + str(request.user.id))
if request.method == "POST":
machine.delete()
messages.success(request, "La machine a été détruite")
return redirect("/users/profil/" + str(request.user.id))
return form({'objet': machine, 'objet_name': 'machine'}, 'machines/delete.html', request)
@login_required
def new_interface(request, machineid):
@ -175,9 +177,11 @@ def del_interface(request, interfaceid):
if interface.machine.user != request.user:
messages.error(request, "Vous ne pouvez pas éditer une machine d'un autre user que vous sans droit")
return redirect("/users/profil/" + str(request.user.id))
interface.delete()
messages.success(request, "L'interface a été détruite")
return redirect("/users/profil/" + str(request.user.id))
if request.method == "POST":
interface.delete()
messages.success(request, "L'interface a été détruite")
return redirect("/users/profil/" + str(request.user.id))
return form({'objet': interface, 'objet_name': 'interface'}, 'machines/delete.html', request)
@login_required
@permission_required('infra')

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('topologie', '0016_auto_20160706_1531'),
]
operations = [
migrations.AlterField(
model_name='port',
name='machine_interface',
field=models.OneToOneField(to='machines.Interface', on_delete=django.db.models.deletion.SET_NULL, null=True, blank=True),
),
]

View file

@ -29,7 +29,7 @@ class Port(models.Model):
switch = models.ForeignKey('Switch', related_name="ports")
port = models.IntegerField()
room = models.ForeignKey('Room', on_delete=models.PROTECT, blank=True, null=True)
machine_interface = models.OneToOneField('machines.Interface', on_delete=models.PROTECT, blank=True, null=True)
machine_interface = models.OneToOneField('machines.Interface', on_delete=models.SET_NULL, blank=True, null=True)
related = models.OneToOneField('self', null=True, blank=True, related_name='related_port')
details = models.CharField(max_length=255, blank=True)