[extensions-web] Added on_delete ForeignKey param to silence deprecation warnings



commit 5d4e9547b8d4fa9362dfaba4b63c001a1e77dedd
Author: Claude Paroz <claude 2xlibre net>
Date:   Sat Jan 12 11:08:09 2019 +0100

    Added on_delete ForeignKey param to silence deprecation warnings
    
    Closes: https://gitlab.gnome.org/Infrastructure/extensions-web/merge_requests/6
    Signed-off-by: Yuri Konotopov <ykonotopov gnome org>

 sweettooth/errorreports/migrations/0001_initial.py | 4 ++--
 sweettooth/errorreports/models.py                  | 4 ++--
 sweettooth/extensions/migrations/0001_initial.py   | 6 +++---
 sweettooth/extensions/models.py                    | 6 +++---
 sweettooth/ratings/migrations/0001_initial.py      | 2 +-
 sweettooth/review/migrations/0001_initial.py       | 4 ++--
 sweettooth/review/models.py                        | 4 ++--
 7 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/sweettooth/errorreports/migrations/0001_initial.py 
b/sweettooth/errorreports/migrations/0001_initial.py
index 92b93a7..f182c05 100644
--- a/sweettooth/errorreports/migrations/0001_initial.py
+++ b/sweettooth/errorreports/migrations/0001_initial.py
@@ -18,8 +18,8 @@ class Migration(migrations.Migration):
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, 
primary_key=True)),
                 ('comment', models.TextField(blank=True)),
-                ('extension', models.ForeignKey(to='extensions.Extension', null=True)),
-                ('user', models.ForeignKey(related_name='+', to=settings.AUTH_USER_MODEL)),
+                ('extension', models.ForeignKey(on_delete=models.CASCADE, to='extensions.Extension', 
null=True)),
+                ('user', models.ForeignKey(on_delete=models.CASCADE, related_name='+', 
to=settings.AUTH_USER_MODEL)),
             ],
             options={
             },
diff --git a/sweettooth/errorreports/models.py b/sweettooth/errorreports/models.py
index a64e6bf..8f7e45a 100644
--- a/sweettooth/errorreports/models.py
+++ b/sweettooth/errorreports/models.py
@@ -6,7 +6,7 @@ from sweettooth.extensions.models import Extension
 
 class ErrorReport(models.Model):
     comment = models.TextField(blank=True)
-    user = models.ForeignKey(auth.models.User, related_name="+")
-    extension = models.ForeignKey(Extension, null=True)
+    user = models.ForeignKey(auth.models.User, on_delete=models.CASCADE, related_name="+")
+    extension = models.ForeignKey(Extension, null=True, on_delete=models.CASCADE)
 
 error_reported = Signal(providing_args=["request", "version", "report"])
diff --git a/sweettooth/extensions/migrations/0001_initial.py 
b/sweettooth/extensions/migrations/0001_initial.py
index e5139a8..2fb9745 100644
--- a/sweettooth/extensions/migrations/0001_initial.py
+++ b/sweettooth/extensions/migrations/0001_initial.py
@@ -28,7 +28,7 @@ class Migration(migrations.Migration):
                 ('popularity', models.IntegerField(default=0)),
                 ('screenshot', 
models.ImageField(upload_to=sweettooth.extensions.models.make_screenshot_filename, blank=True)),
                 ('icon', models.ImageField(default=b'/static/images/plugin.png', 
upload_to=sweettooth.extensions.models.make_icon_filename, blank=True)),
-                ('creator', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
+                ('creator', models.ForeignKey(on_delete=models.CASCADE, to=settings.AUTH_USER_MODEL)),
             ],
             options={
                 'permissions': (('can-modify-data', 'Can modify extension data'),),
@@ -41,7 +41,7 @@ class Migration(migrations.Migration):
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, 
primary_key=True)),
                 ('offset', models.IntegerField()),
                 ('date', models.DateTimeField(auto_now_add=True)),
-                ('extension', models.ForeignKey(related_name='popularity_items', to='extensions.Extension')),
+                ('extension', models.ForeignKey(on_delete=models.CASCADE, related_name='popularity_items', 
to='extensions.Extension')),
             ],
             options={
             },
@@ -55,7 +55,7 @@ class Migration(migrations.Migration):
                 ('extra_json_fields', models.TextField()),
                 ('status', models.PositiveIntegerField(choices=[(0, 'Unreviewed'), (1, 'Rejected'), (2, 
'Inactive'), (3, 'Active'), (4, 'Waiting for author')])),
                 ('source', models.FileField(max_length=223, 
upload_to=sweettooth.extensions.models.make_filename)),
-                ('extension', models.ForeignKey(related_name='versions', to='extensions.Extension')),
+                ('extension', models.ForeignKey(on_delete=models.CASCADE, related_name='versions', 
to='extensions.Extension')),
             ],
             options={
                 'get_latest_by': 'version',
diff --git a/sweettooth/extensions/models.py b/sweettooth/extensions/models.py
index ce00d8a..5d31c53 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -92,7 +92,7 @@ class Extension(models.Model):
     name = models.CharField(max_length=200)
     uuid = models.CharField(max_length=200, unique=True, db_index=True)
     slug = autoslug.AutoSlugField(populate_from="name")
-    creator = models.ForeignKey(User, db_index=True)
+    creator = models.ForeignKey(User, db_index=True, on_delete=models.CASCADE)
     description = models.TextField(blank=True)
     url = models.URLField(blank=True)
     created = models.DateTimeField(auto_now_add=True)
@@ -173,7 +173,7 @@ class Extension(models.Model):
 
 class ExtensionPopularityItem(models.Model):
     extension = models.ForeignKey(Extension, db_index=True,
-                                  related_name='popularity_items')
+                                  on_delete=models.CASCADE, related_name='popularity_items')
     offset = models.IntegerField()
     date = models.DateTimeField(auto_now_add=True)
 
@@ -295,7 +295,7 @@ def make_filename(obj, filename=None):
 
 
 class ExtensionVersion(models.Model):
-    extension = models.ForeignKey(Extension, related_name="versions")
+    extension = models.ForeignKey(Extension, on_delete=models.CASCADE, related_name="versions")
     version = models.IntegerField(default=0)
     extra_json_fields = models.TextField()
     status = models.PositiveIntegerField(choices=STATUSES.items())
diff --git a/sweettooth/ratings/migrations/0001_initial.py b/sweettooth/ratings/migrations/0001_initial.py
index 766d63c..3b5662e 100644
--- a/sweettooth/ratings/migrations/0001_initial.py
+++ b/sweettooth/ratings/migrations/0001_initial.py
@@ -14,7 +14,7 @@ class Migration(migrations.Migration):
         migrations.CreateModel(
             name='RatingComment',
             fields=[
-                ('comment_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, 
serialize=False, to='django_comments.Comment')),
+                ('comment_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, 
serialize=False, on_delete=models.CASCADE, to='django_comments.Comment')),
                 ('rating', models.IntegerField(default=-1, blank=True)),
             ],
             options={
diff --git a/sweettooth/review/migrations/0001_initial.py b/sweettooth/review/migrations/0001_initial.py
index 269d220..c121a84 100644
--- a/sweettooth/review/migrations/0001_initial.py
+++ b/sweettooth/review/migrations/0001_initial.py
@@ -21,8 +21,8 @@ class Migration(migrations.Migration):
                 ('comments', models.TextField(blank=True)),
                 ('new_status', models.PositiveIntegerField(null=True, choices=[(0, 'Unreviewed'), (1, 
'Rejected'), (2, 'Inactive'), (3, 'Active'), (4, 'Waiting for author')])),
                 ('auto', models.BooleanField(default=False)),
-                ('reviewer', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
-                ('version', models.ForeignKey(related_name='reviews', to='extensions.ExtensionVersion')),
+                ('reviewer', models.ForeignKey(on_delete=models.CASCADE, to=settings.AUTH_USER_MODEL)),
+                ('version', models.ForeignKey(on_delete=models.CASCADE, related_name='reviews', 
to='extensions.ExtensionVersion')),
             ],
             options={
                 'permissions': (('can-review-extensions', 'Can review extensions'), ('trusted', 'Trusted 
author')),
diff --git a/sweettooth/review/models.py b/sweettooth/review/models.py
index 3dd1255..171dc80 100644
--- a/sweettooth/review/models.py
+++ b/sweettooth/review/models.py
@@ -14,10 +14,10 @@ def get_all_reviewers():
     return User.objects.filter(Q(is_superuser=True)|Q(user_permissions=perm)|Q(groups__in=groups)).distinct()
 
 class CodeReview(models.Model):
-    reviewer = models.ForeignKey(User)
+    reviewer = models.ForeignKey(User, on_delete=models.CASCADE)
     date = models.DateTimeField(auto_now_add=True)
     comments = models.TextField(blank=True)
-    version = models.ForeignKey(ExtensionVersion, related_name="reviews")
+    version = models.ForeignKey(ExtensionVersion, on_delete=models.CASCADE, related_name="reviews")
     new_status = models.PositiveIntegerField(choices=STATUSES.items(), null=True)
     auto = models.BooleanField(default=False)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]