Commit acd1c89d authored by chirac's avatar chirac

Ajoute des vues pour la suppression, et nettoie le code

parent 17ba68cb
{% 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 %}
......@@ -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')
......
# -*- 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'),
),
]
{% 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 %}
......@@ -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')
......
# -*- 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),
),
]
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment