From 23817922d36d7d840a797c31892bb298dbc1de73 Mon Sep 17 00:00:00 2001 From: Mohamad Bastin Date: Fri, 27 Oct 2023 20:32:16 +0200 Subject: [PATCH 1/2] db error permissions --- ...eetverification_permission_ptr_and_more.py | 51 --------------- ...eekverification_permission_ptr_and_more.py | 23 +++++++ permissions/migrations/0007_initial.py | 63 ------------------- permissions/serializers.py | 51 ++++++++------- .../migrations/0003_raffle_permissions.py | 1 + .../0002_tokendistribution_permissions.py | 1 + .../migrations/0020_alter_constraint_name.py | 18 ++++++ 7 files changed, 68 insertions(+), 140 deletions(-) delete mode 100644 permissions/migrations/0006_remove_brightidmeetverification_permission_ptr_and_more.py create mode 100644 permissions/migrations/0006_remove_onceperweekverification_permission_ptr_and_more.py delete mode 100644 permissions/migrations/0007_initial.py create mode 100644 tokenTap/migrations/0020_alter_constraint_name.py diff --git a/permissions/migrations/0006_remove_brightidmeetverification_permission_ptr_and_more.py b/permissions/migrations/0006_remove_brightidmeetverification_permission_ptr_and_more.py deleted file mode 100644 index 0ae46b1b..00000000 --- a/permissions/migrations/0006_remove_brightidmeetverification_permission_ptr_and_more.py +++ /dev/null @@ -1,51 +0,0 @@ -# Generated by Django 4.0.4 on 2023-10-26 21:20 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('permissions', '0005_onceinalifetimeverification'), - ] - - operations = [ - migrations.RemoveField( - model_name='brightidmeetverification', - name='permission_ptr', - ), - migrations.RemoveField( - model_name='onceinalifetimeverification', - name='permission_ptr', - ), - migrations.RemoveField( - model_name='oncepermonthverification', - name='permission_ptr', - ), - migrations.RemoveField( - model_name='onceperweekverification', - name='permission_ptr', - ), - migrations.RemoveField( - model_name='permission', - name='polymorphic_ctype', - ), - migrations.DeleteModel( - name='BrightIDAuraVerification', - ), - migrations.DeleteModel( - name='BrightIDMeetVerification', - ), - migrations.DeleteModel( - name='OnceInALifeTimeVerification', - ), - migrations.DeleteModel( - name='OncePerMonthVerification', - ), - migrations.DeleteModel( - name='OncePerWeekVerification', - ), - migrations.DeleteModel( - name='Permission', - ), - ] diff --git a/permissions/migrations/0006_remove_onceperweekverification_permission_ptr_and_more.py b/permissions/migrations/0006_remove_onceperweekverification_permission_ptr_and_more.py new file mode 100644 index 00000000..f5edd017 --- /dev/null +++ b/permissions/migrations/0006_remove_onceperweekverification_permission_ptr_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 4.0.4 on 2023-10-27 18:29 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('permissions', '0005_onceinalifetimeverification'), + ] + + operations = [ + migrations.RemoveField( + model_name='onceperweekverification', + name='permission_ptr', + ), + migrations.DeleteModel( + name='OncePerMonthVerification', + ), + migrations.DeleteModel( + name='OncePerWeekVerification', + ), + ] diff --git a/permissions/migrations/0007_initial.py b/permissions/migrations/0007_initial.py deleted file mode 100644 index 44aafc09..00000000 --- a/permissions/migrations/0007_initial.py +++ /dev/null @@ -1,63 +0,0 @@ -# Generated by Django 4.0.4 on 2023-10-26 21:41 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ('contenttypes', '0002_remove_content_type_name'), - ('permissions', '0006_remove_brightidmeetverification_permission_ptr_and_more'), - ] - - operations = [ - migrations.CreateModel( - name='Permission', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=200)), - ('description', models.TextField(blank=True, null=True)), - ('polymorphic_ctype', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_%(app_label)s.%(class)s_set+', to='contenttypes.contenttype')), - ], - options={ - 'abstract': False, - 'base_manager_name': 'objects', - }, - ), - migrations.CreateModel( - name='BrightIDAuraVerification', - fields=[ - ('permission_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='permissions.permission')), - ], - options={ - 'abstract': False, - 'base_manager_name': 'objects', - }, - bases=('permissions.permission',), - ), - migrations.CreateModel( - name='BrightIDMeetVerification', - fields=[ - ('permission_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='permissions.permission')), - ], - options={ - 'abstract': False, - 'base_manager_name': 'objects', - }, - bases=('permissions.permission',), - ), - migrations.CreateModel( - name='OnceInALifeTimeVerification', - fields=[ - ('permission_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='permissions.permission')), - ], - options={ - 'abstract': False, - 'base_manager_name': 'objects', - }, - bases=('permissions.permission',), - ), - ] diff --git a/permissions/serializers.py b/permissions/serializers.py index 1e89ca06..42d21590 100644 --- a/permissions/serializers.py +++ b/permissions/serializers.py @@ -1,35 +1,34 @@ -# from rest_framework import serializers -# from rest_polymorphic.serializers import PolymorphicSerializer +from rest_framework import serializers +from rest_polymorphic.serializers import PolymorphicSerializer +from permissions.models import ( + BrightIDAuraVerification, + BrightIDMeetVerification, + Permission, +) -# from permissions.models import ( -# Permission, -# BrightIDMeetVerification, -# BrightIDAuraVerification, -# ) +class PermissionBaseSerializer(serializers.ModelSerializer): + class Meta: + model = Permission + fields = ["id", "name", "description"] -# class PermissionBaseSerializer(serializers.ModelSerializer): -# class Meta: -# model = Permission -# fields = ["id", "name", "description"] +class BrightIDMeetVerificationSerializer(PermissionBaseSerializer): + class Meta: + model = BrightIDMeetVerification + fields = ["id", "name", "description"] -# class BrightIDMeetVerificationSerializer(PermissionBaseSerializer): -# class Meta: -# model = BrightIDMeetVerification -# fields = ["id", "name", "description"] +class BrightIDAuraVerificationSerializer(PermissionBaseSerializer): + class Meta: + model = BrightIDAuraVerification + fields = ["id", "name", "description"] -# class BrightIDAuraVerificationSerializer(PermissionBaseSerializer): -# class Meta: -# model = BrightIDAuraVerification -# fields = ["id", "name", "description"] - -# class PermissionSerializer(PolymorphicSerializer): -# model_serializer_mapping = { -# Permission: PermissionBaseSerializer, -# BrightIDMeetVerification: BrightIDMeetVerificationSerializer, -# BrightIDAuraVerification: BrightIDAuraVerificationSerializer, -# } +class PermissionSerializer(PolymorphicSerializer): + model_serializer_mapping = { + Permission: PermissionBaseSerializer, + BrightIDMeetVerification: BrightIDMeetVerificationSerializer, + BrightIDAuraVerification: BrightIDAuraVerificationSerializer, + } diff --git a/prizetap/migrations/0003_raffle_permissions.py b/prizetap/migrations/0003_raffle_permissions.py index 9461baf4..201b70e2 100644 --- a/prizetap/migrations/0003_raffle_permissions.py +++ b/prizetap/migrations/0003_raffle_permissions.py @@ -6,6 +6,7 @@ class Migration(migrations.Migration): dependencies = [ + ('permissions', '0004_oncepermonthverification'), ('prizetap', '0002_raffle_is_prize_nft'), ] diff --git a/tokenTap/migrations/0002_tokendistribution_permissions.py b/tokenTap/migrations/0002_tokendistribution_permissions.py index a1698c55..3666fc02 100644 --- a/tokenTap/migrations/0002_tokendistribution_permissions.py +++ b/tokenTap/migrations/0002_tokendistribution_permissions.py @@ -6,6 +6,7 @@ class Migration(migrations.Migration): dependencies = [ + ('permissions', '0001_initial'), ('tokenTap', '0001_initial'), ] diff --git a/tokenTap/migrations/0020_alter_constraint_name.py b/tokenTap/migrations/0020_alter_constraint_name.py new file mode 100644 index 00000000..7093dbb3 --- /dev/null +++ b/tokenTap/migrations/0020_alter_constraint_name.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.4 on 2023-10-27 18:29 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('tokenTap', '0019_alter_constraint_name'), + ] + + operations = [ + migrations.AlterField( + model_name='constraint', + name='name', + field=models.CharField(choices=[('BrightIDMeetVerification', 'BrightIDMeetVerification'), ('BrightIDAuraVerification', 'BrightIDAuraVerification'), ('OncePerMonthVerification', 'OncePerMonthVerification'), ('OnceInALifeTimeVerification', 'OnceInALifeTimeVerification'), ('OptimismHasClaimedGasInThisRound', 'OptimismHasClaimedGasInThisRound')], max_length=255, unique=True), + ), + ] From 9149c884b572c837dc9a13d45de91a414a86af7f Mon Sep 17 00:00:00 2001 From: Mohamad Bastin Date: Fri, 27 Oct 2023 20:37:40 +0200 Subject: [PATCH 2/2] db error permissions --- ...ove_onceperweekverification_permission_ptr_and_more.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/permissions/migrations/0006_remove_onceperweekverification_permission_ptr_and_more.py b/permissions/migrations/0006_remove_onceperweekverification_permission_ptr_and_more.py index f5edd017..57417c8c 100644 --- a/permissions/migrations/0006_remove_onceperweekverification_permission_ptr_and_more.py +++ b/permissions/migrations/0006_remove_onceperweekverification_permission_ptr_and_more.py @@ -10,10 +10,10 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RemoveField( - model_name='onceperweekverification', - name='permission_ptr', - ), + # migrations.RemoveField( + # model_name='onceperweekverification', + # name='permission_ptr', + # ), migrations.DeleteModel( name='OncePerMonthVerification', ),