Delete Objects

parent 3cf8b367
# Generated by Django 2.1.2 on 2018-10-29 20:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dashboard', '0004_raspi_status'),
]
operations = [
migrations.AlterField(
model_name='raspi',
name='ip',
field=models.CharField(choices=[('up', 'up'), ('down', 'down')], max_length=50),
),
]
# Generated by Django 2.1.2 on 2018-10-29 20:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dashboard', '0005_auto_20181029_2025'),
]
operations = [
migrations.AlterField(
model_name='raspi',
name='ip',
field=models.CharField(max_length=50),
),
migrations.AlterField(
model_name='raspi',
name='status',
field=models.CharField(choices=[('up', 'up'), ('down', 'down')], max_length=5),
),
]
......@@ -16,6 +16,12 @@ class Patient(models.Model):
def __str__(self):
return self.last_name + self.first_name
class Raspi(models.Model):
STATUS_CHOICES = [
('up', 'up'),
('down', 'down'),
]
ip = models.CharField(max_length=50)
status = models.CharField(max_length=5)
status = models.CharField(max_length=5, choices=STATUS_CHOICES)
......@@ -20,7 +20,7 @@ var myLineChart = new Chart(ctx, {
pointHoverBackgroundColor: "rgba(2,117,216,1)",
pointHitRadius: 50,
pointBorderWidth: 2,
data: [10000, 30162, 26263, 18394, 18287, 28682, 31274, 33259, 25849, 24159, 32651, 31984, 38451],
data: [30000, 30162, 33000, 31000, 1287, 28682, 31274, 33259, 25849, 24159, 32651, 31984, 38451],
}],
},
options: {
......
{% extends 'base.html' %}
{% block content %}
<div class="container">
<div class="jumbotron mt-5">
<h1 class="display-4">404 maggle</h1>
</div>
</div>
{% endblock %}
......@@ -6,20 +6,26 @@
<div class="row mt-5">
{% for doctor in doctors %}
<div class="col">
<div class="card" style="width: 18rem;">
<img class="card-img-top" src="{% static "doctor.jpg" %}" alt="Card image cap">
<div class="card mb-5" style="width: 18rem;">
<img class="card-img-top" src="{% static "doctor.jpg" %}" alt="{{ doctor.first_name }} {{ doctor.last_name }}">
<div class="card-body mx-auto">
<h5 class="card-title">{{doctor.first_name}} {{doctor.last_name}}</h5>
<p class="card-text">Email : {{doctor.email}}</p>
<p class="card-text">Address : {{doctor.address}}</p>
<a href="#" class="btn btn-primary">Voir la fiche</a>
<a href="#" class="btn btn-dark">Modify</a>
<a href="{% url 'delete_doctor' id=doctor.id %}" class="btn btn-danger">Delete</a>
</div>
</div>
</div>
{% if forloop.counter|divisibleby:"4" or forloop.last %}
</div> <!--end row-->
{% endif %}
{% empty %}
<h1>No doctor..</h1>
{% endfor %}
<a href="{% url 'doctor_new' %}" class="btn btn-dark btn-lg btn-block">Add a Doctor.</a>
</div>
{% endblock %}
......@@ -6,7 +6,7 @@
<div class="container">
<div class="row mt-5 mb-5 ">
<div class="row mt-5 mb-2 ">
<div class="col-sm-4">
<a href="{% url 'doctor_new' %}">
<button type="button" class="btn btn-dark btn-lg btn-block">Add a doctor</button>
......@@ -24,25 +24,23 @@
</div>
</div>
<hr>
<div class="row mb-5">
<div class="col-sm-4">
<a href="{% url 'doctors' %}">
<div class="card mx-auto">
<img class="card-img-top" src="{% static "doctor.png" %}" alt="doctors">
<div class="card-body mx-auto">
<a href="{% url 'doctors' %}" class="btn btn-dark">Doctors</a>
</div>
</div>
</a>
<a href="{% url 'doctors' %}">
<div class="card mx-auto">
<img class="card-img-top" src="{% static "doctor.png" %}" alt="doctors">
<a href="{% url 'doctors' %}" class="btn btn-dark btn-lg btn-block mt-2">Doctors</a>
</div>
</a>
</div>
<div class="col-sm-4">
<a href="{% url 'patients' %}">
<div class="card mx-auto">
<img class="card-img-top" src="{% static "patient.png" %}" alt="patients">
<div class="card-body mx-auto">
<a href="{% url 'patients' %}" class="btn btn-dark">Patients</a>
</div>
<a href="{% url 'patients' %}" class="btn btn-dark btn-lg btn-block mt-2">Patients</a>
</div>
</a>
</div>
......@@ -51,9 +49,7 @@
<a href="{% url 'dashboard' %}">
<div class="card mx-auto">
<img class="card-img-top" src="{% static "computer.png" %}" alt="interface">
<div class="card-body mx-auto">
<a href="{% url 'interface' %}" class="btn btn-dark">My Interface</a>
</div>
<a href="{% url 'interface' %}" class="btn btn-dark btn-lg btn-block mt-2">My Interface</a>
</div>
</a>
</div>
......
......@@ -2,32 +2,37 @@
{% block content %}
<div class="container">
<div class="jumbotron mt-5">
<h1>My Interface</h1>
</div>
{% load static %}
<div class="row mt-5">
{% for pi in raspis %}
<div class="col">
<div class="card" style="width: 10rem;">
<div class="card mb-5" style="width: 12rem;">
<img class="card-img-top" src="{% static "pi.png" %}" alt="raspi">
<div class="card-body ">
<center>
<h5 class="card-title">{{pi.ip}}</h5>
{% if pi.status == "DOWN" %}
<a href="#" class="btn btn-danger">{{ pi.status }}</a>
<p> Status : <span class="badge badge-danger">{{pi.status}}</span> </p>
{% elif pi.status == "UP" %}
<p> Status : <span class="badge badge-success">{{pi.status}}</span> </p>
{% else %}
<a href="#" class="btn btn-success ">{{ pi.status }}</a>
<p> Status : <span class="badge badge-secondary">Unknown</span> </p>
{% endif %}
<a href="#" class="btn btn-dark">Modify</a>
<a href="{% url 'delete_raspi' id=pi.id %}" class="btn btn-danger">Delete</a>
</center>
</div>
</div>
</div>
{% if forloop.counter|divisibleby:"6" or forloop.last %}
{% if forloop.counter|divisibleby:"4" or forloop.last %}
</div> <!--end row-->
{% endif %}
{% empty %}
<h1>No results..</h1>
{% endfor %}
<a href="{% url 'raspi_new' %}" class="btn btn-dark btn-lg btn-block">Add a Raspberry Pi to the Network.</a>
</div>
{% endblock %}
......@@ -6,14 +6,15 @@
<div class="row mt-5">
{% for patient in patients %}
<div class="col">
<div class="card" style="width: 18rem;">
<div class="card mb-5" style="width: 18rem;">
<img class="card-img-top" src="{% static "patient.png" %}" alt="patient">
<div class="card-body mx-auto">
<center>
<h5 class="card-title">{{patient.first_name}} {{patient.last_name}}</h5>
<p class="card-text">date_of_birth : {{patient.date_of_birth}}</p>
<p class="card-text">Doctor : {{patient.doctor}}</p>
<a href="#" class="btn btn-primary">Details</a>
<p class="card-text">Date of birth : {{patient.date_of_birth}}</p>
<p class="card-text">Doctor : {{patient.doctor.first_name}} {{patient.doctor.last_name}}</p>
<a href="#" class="btn btn-dark">Modify</a>
<a href="{% url 'delete_patient' id=patient.id %}" class="btn btn-danger">Delete</a>
</center>
</div>
</div>
......@@ -21,7 +22,13 @@
{% if forloop.counter|divisibleby:"4" or forloop.last %}
</div> <!--end row-->
{% endif %}
{% empty %}
<h1>No patient..</h1>
{% endfor %}
<a href="{% url 'patient_new' %}" class="btn btn-dark btn-lg btn-block">Add a Patient.</a>
</div>
{% endblock %}
......@@ -16,5 +16,7 @@ urlpatterns = [
path('patients', views.patients, name='patients'),
path('interface', views.interface, name='interface'),
path('dashboard', views.dashboard, name='dashboard'),
path('delete/raspi/<int:id>', views.delete_raspi, name='delete_raspi'),
path('delete/doctor/<int:id>', views.delete_doctor, name='delete_doctor'),
path('delete/patient/<int:id>', views.delete_patient, name='delete_patient'),
]
......@@ -89,3 +89,15 @@ def patients(request):
@login_required
def dashboard(request):
return render(request, 'dashboard.html')
def delete_raspi(request, id):
u = Raspi.objects.filter(id=id).delete()
return redirect('interface')
def delete_patient(request, id):
u = Patient.objects.filter(id=id).delete()
return redirect('patients')
def delete_doctor(request, id):
u = Doctor.objects.filter(id=id).delete()
return redirect('doctors')
No preview for this file type
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