From 55ae322fb45987f449a6d479d000cc6e3acfc3bd Mon Sep 17 00:00:00 2001 From: John Wong Date: Tue, 17 Sep 2024 21:20:07 +0800 Subject: [PATCH] Replace deprecated django-update-from-dict package (#42) --- backend/requirements.txt | 1 - .../authentication/migrations/0001_initial.py | 3 +-- .../migrations/0002_openidauthentication.py | 3 +-- .../migrations/0003_auto_20210709_1926.py | 3 +-- .../migrations/0005_facebookauthentication.py | 3 +-- backend/treeckle/bookings/migrations/0001_initial.py | 3 +-- backend/treeckle/comments/migrations/0001_initial.py | 5 ++--- .../migrations/0001_initial.py | 3 +-- backend/treeckle/events/migrations/0001_initial.py | 11 +++++------ .../treeckle/organizations/migrations/0001_initial.py | 3 +-- .../migrations/0002_auto_20201223_1002.py | 3 +-- backend/treeckle/treeckle/common/models.py | 11 ++++++----- .../users/migrations/0009_gmailauthentication.py | 3 +-- backend/treeckle/venues/migrations/0001_initial.py | 5 ++--- .../venues/migrations/0016_auto_20210706_1742.py | 3 +-- 15 files changed, 25 insertions(+), 38 deletions(-) diff --git a/backend/requirements.txt b/backend/requirements.txt index 255511e..d4c1f1c 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -7,7 +7,6 @@ psycopg2-binary==2.9.1 python-dotenv==0.19.0 django-anymail[sendinblue]==8.4 djangorestframework-camel-case -django-update-from-dict django-cors-headers django-jazzmin django[argon2] diff --git a/backend/treeckle/authentication/migrations/0001_initial.py b/backend/treeckle/authentication/migrations/0001_initial.py index 0d2c11c..3d58d13 100644 --- a/backend/treeckle/authentication/migrations/0001_initial.py +++ b/backend/treeckle/authentication/migrations/0001_initial.py @@ -2,7 +2,6 @@ from django.db import migrations, models import django.db.models.deletion -import django_update_from_dict class Migration(migrations.Migration): @@ -26,6 +25,6 @@ class Migration(migrations.Migration): options={ 'abstract': False, }, - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), ] diff --git a/backend/treeckle/authentication/migrations/0002_openidauthentication.py b/backend/treeckle/authentication/migrations/0002_openidauthentication.py index 6710ddf..80a9ce5 100644 --- a/backend/treeckle/authentication/migrations/0002_openidauthentication.py +++ b/backend/treeckle/authentication/migrations/0002_openidauthentication.py @@ -2,7 +2,6 @@ from django.db import migrations, models import django.db.models.deletion -import django_update_from_dict class Migration(migrations.Migration): @@ -25,6 +24,6 @@ class Migration(migrations.Migration): options={ 'abstract': False, }, - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), ] diff --git a/backend/treeckle/authentication/migrations/0003_auto_20210709_1926.py b/backend/treeckle/authentication/migrations/0003_auto_20210709_1926.py index 05e6d20..75781f8 100644 --- a/backend/treeckle/authentication/migrations/0003_auto_20210709_1926.py +++ b/backend/treeckle/authentication/migrations/0003_auto_20210709_1926.py @@ -2,7 +2,6 @@ from django.db import migrations, models import django.db.models.deletion -import django_update_from_dict class Migration(migrations.Migration): @@ -35,6 +34,6 @@ class Migration(migrations.Migration): options={ 'abstract': False, }, - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), ] diff --git a/backend/treeckle/authentication/migrations/0005_facebookauthentication.py b/backend/treeckle/authentication/migrations/0005_facebookauthentication.py index 994b43c..4aa6904 100644 --- a/backend/treeckle/authentication/migrations/0005_facebookauthentication.py +++ b/backend/treeckle/authentication/migrations/0005_facebookauthentication.py @@ -2,7 +2,6 @@ from django.db import migrations, models import django.db.models.deletion -import django_update_from_dict class Migration(migrations.Migration): @@ -25,6 +24,6 @@ class Migration(migrations.Migration): options={ 'abstract': False, }, - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), ] diff --git a/backend/treeckle/bookings/migrations/0001_initial.py b/backend/treeckle/bookings/migrations/0001_initial.py index dba1383..142f516 100644 --- a/backend/treeckle/bookings/migrations/0001_initial.py +++ b/backend/treeckle/bookings/migrations/0001_initial.py @@ -3,7 +3,6 @@ from django.db import migrations, models import django.db.models.deletion import django.db.models.expressions -import django_update_from_dict class Migration(migrations.Migration): @@ -32,7 +31,7 @@ class Migration(migrations.Migration): options={ 'ordering': ['-created_at'], }, - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), migrations.AddConstraint( model_name='booking', diff --git a/backend/treeckle/comments/migrations/0001_initial.py b/backend/treeckle/comments/migrations/0001_initial.py index 31c7172..df1f42d 100644 --- a/backend/treeckle/comments/migrations/0001_initial.py +++ b/backend/treeckle/comments/migrations/0001_initial.py @@ -2,7 +2,6 @@ from django.db import migrations, models import django.db.models.deletion -import django_update_from_dict class Migration(migrations.Migration): @@ -27,7 +26,7 @@ class Migration(migrations.Migration): options={ 'ordering': ['-created_at'], }, - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), migrations.CreateModel( name='CommentRead', @@ -38,7 +37,7 @@ class Migration(migrations.Migration): ('comment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='comments.comment')), ('reader', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='users.user')), ], - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), migrations.CreateModel( name='BookingComment', diff --git a/backend/treeckle/content_delivery_service/migrations/0001_initial.py b/backend/treeckle/content_delivery_service/migrations/0001_initial.py index 1ed77f5..c2c76f2 100644 --- a/backend/treeckle/content_delivery_service/migrations/0001_initial.py +++ b/backend/treeckle/content_delivery_service/migrations/0001_initial.py @@ -1,7 +1,6 @@ # Generated by Django 3.2.5 on 2021-07-28 07:56 from django.db import migrations, models -import django_update_from_dict class Migration(migrations.Migration): @@ -24,6 +23,6 @@ class Migration(migrations.Migration): options={ 'abstract': False, }, - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), ] diff --git a/backend/treeckle/events/migrations/0001_initial.py b/backend/treeckle/events/migrations/0001_initial.py index bd546a0..b5f3380 100644 --- a/backend/treeckle/events/migrations/0001_initial.py +++ b/backend/treeckle/events/migrations/0001_initial.py @@ -3,7 +3,6 @@ import django.core.validators from django.db import migrations, models import django.db.models.deletion -import django_update_from_dict class Migration(migrations.Migration): @@ -38,7 +37,7 @@ class Migration(migrations.Migration): options={ 'ordering': ['-created_at'], }, - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), migrations.CreateModel( name='EventCategoryType', @@ -52,7 +51,7 @@ class Migration(migrations.Migration): options={ 'ordering': ['name'], }, - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), migrations.CreateModel( name='EventSignUp', @@ -67,7 +66,7 @@ class Migration(migrations.Migration): options={ 'ordering': ['-status', 'created_at'], }, - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), migrations.CreateModel( name='EventCategoryTypeSubscription', @@ -78,7 +77,7 @@ class Migration(migrations.Migration): ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='events.eventcategorytype')), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='users.user')), ], - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), migrations.CreateModel( name='EventCategory', @@ -89,7 +88,7 @@ class Migration(migrations.Migration): ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='events.eventcategorytype')), ('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='events.event')), ], - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), migrations.AddConstraint( model_name='eventsignup', diff --git a/backend/treeckle/organizations/migrations/0001_initial.py b/backend/treeckle/organizations/migrations/0001_initial.py index 671150a..91a593e 100644 --- a/backend/treeckle/organizations/migrations/0001_initial.py +++ b/backend/treeckle/organizations/migrations/0001_initial.py @@ -1,7 +1,6 @@ # Generated by Django 3.1.3 on 2020-12-23 09:50 from django.db import migrations, models -import django_update_from_dict class Migration(migrations.Migration): @@ -23,6 +22,6 @@ class Migration(migrations.Migration): options={ 'ordering': ['name'], }, - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), ] diff --git a/backend/treeckle/organizations/migrations/0002_auto_20201223_1002.py b/backend/treeckle/organizations/migrations/0002_auto_20201223_1002.py index ba512a8..597af49 100644 --- a/backend/treeckle/organizations/migrations/0002_auto_20201223_1002.py +++ b/backend/treeckle/organizations/migrations/0002_auto_20201223_1002.py @@ -2,7 +2,6 @@ from django.db import migrations, models import django.db.models.deletion -import django_update_from_dict class Migration(migrations.Migration): @@ -25,7 +24,7 @@ class Migration(migrations.Migration): options={ 'ordering': ['name'], }, - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), migrations.AddConstraint( model_name='organizationlistener', diff --git a/backend/treeckle/treeckle/common/models.py b/backend/treeckle/treeckle/common/models.py index a9d2402..8f16893 100644 --- a/backend/treeckle/treeckle/common/models.py +++ b/backend/treeckle/treeckle/common/models.py @@ -1,11 +1,12 @@ from django.db import models -from django_update_from_dict import UpdateFromDictMixin - - -class TimestampedModel(UpdateFromDictMixin, models.Model): +class TimestampedModel(models.Model): created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class Meta: - abstract = True \ No newline at end of file + abstract = True + + def update_from_dict(self, update_dict): + for field, value in update_dict.items(): + setattr(self, field, value) \ No newline at end of file diff --git a/backend/treeckle/users/migrations/0009_gmailauthentication.py b/backend/treeckle/users/migrations/0009_gmailauthentication.py index 8d90e50..bdd75a9 100644 --- a/backend/treeckle/users/migrations/0009_gmailauthentication.py +++ b/backend/treeckle/users/migrations/0009_gmailauthentication.py @@ -2,7 +2,6 @@ from django.db import migrations, models import django.db.models.deletion -import django_update_from_dict class Migration(migrations.Migration): @@ -24,6 +23,6 @@ class Migration(migrations.Migration): options={ 'abstract': False, }, - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), ] diff --git a/backend/treeckle/venues/migrations/0001_initial.py b/backend/treeckle/venues/migrations/0001_initial.py index 4c5bb14..d38c15e 100644 --- a/backend/treeckle/venues/migrations/0001_initial.py +++ b/backend/treeckle/venues/migrations/0001_initial.py @@ -2,7 +2,6 @@ from django.db import migrations, models import django.db.models.deletion -import django_update_from_dict class Migration(migrations.Migration): @@ -26,7 +25,7 @@ class Migration(migrations.Migration): options={ 'ordering': ['name'], }, - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), migrations.CreateModel( name='Venue', @@ -46,7 +45,7 @@ class Migration(migrations.Migration): options={ 'ordering': ['name'], }, - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), migrations.AddConstraint( model_name='venuecategory', diff --git a/backend/treeckle/venues/migrations/0016_auto_20210706_1742.py b/backend/treeckle/venues/migrations/0016_auto_20210706_1742.py index 5a042ab..dcbafb5 100644 --- a/backend/treeckle/venues/migrations/0016_auto_20210706_1742.py +++ b/backend/treeckle/venues/migrations/0016_auto_20210706_1742.py @@ -2,7 +2,6 @@ from django.db import migrations, models import django.db.models.deletion -import django_update_from_dict class Migration(migrations.Migration): @@ -22,7 +21,7 @@ class Migration(migrations.Migration): ('email', models.EmailField(max_length=254)), ('venue', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='venues.venue')), ], - bases=(django_update_from_dict.UpdateFromDictMixin, models.Model), + bases=(models.Model,), ), migrations.AddConstraint( model_name='venuebookingnotificationsubscription',