From fef3a855657a7e5c2393dc469690d73bb249bd8f Mon Sep 17 00:00:00 2001 From: Parker Berberian Date: Tue, 29 Jan 2019 10:05:27 -0500 Subject: Allow Users to Delete objects and Cancel Bookings A user can now delete thier own resources, configs, and snapshots as well as cancelling bookings. Change-Id: Ic8e4751feeb0b8fa0d76816b8df2d16729ad2828 Signed-off-by: Parker Berberian --- src/booking/migrations/0004_auto_20190124_1700.py | 20 ++++++++++++++++++++ src/booking/models.py | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/booking/migrations/0004_auto_20190124_1700.py (limited to 'src/booking') diff --git a/src/booking/migrations/0004_auto_20190124_1700.py b/src/booking/migrations/0004_auto_20190124_1700.py new file mode 100644 index 0000000..baa32d2 --- /dev/null +++ b/src/booking/migrations/0004_auto_20190124_1700.py @@ -0,0 +1,20 @@ +# Generated by Django 2.1 on 2019-01-24 17:00 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('booking', '0003_auto_20190115_1733'), + ] + + operations = [ + migrations.AlterField( + model_name='booking', + name='owner', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='owner', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/src/booking/models.py b/src/booking/models.py index 0972922..8612abd 100644 --- a/src/booking/models.py +++ b/src/booking/models.py @@ -18,7 +18,7 @@ import resource_inventory.resource_manager class Booking(models.Model): id = models.AutoField(primary_key=True) - owner = models.ForeignKey(User, models.CASCADE, related_name='owner') + owner = models.ForeignKey(User, on_delete=models.PROTECT, related_name='owner') collaborators = models.ManyToManyField(User, related_name='collaborators') start = models.DateTimeField() end = models.DateTimeField() -- cgit 1.2.3-korg