diff --git a/brightIDfaucet/settings.py b/brightIDfaucet/settings.py index 1c7f162c..9a2c923e 100644 --- a/brightIDfaucet/settings.py +++ b/brightIDfaucet/settings.py @@ -113,7 +113,7 @@ def before_send(event, hint): "faucet.apps.FaucetConfig", "tokenTap.apps.TokentapConfig", "prizetap.apps.PrizetapConfig", - "permissions.apps.PermissionsConfig", + # "permissions.apps.PermissionsConfig", "authentication.apps.AuthenticationConfig", "rest_framework", "rest_framework.authtoken", diff --git a/permissions/__init__.py b/permissions/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/permissions/admin.py b/permissions/admin.py deleted file mode 100644 index 018dd20c..00000000 --- a/permissions/admin.py +++ /dev/null @@ -1,38 +0,0 @@ -from django.contrib import admin - -from .models import ( - BrightIDAuraVerification, - BrightIDMeetVerification, - OnceInALifeTimeVerification, - OncePerMonthVerification, - OncePerWeekVerification, -) - -# Register your models here. - - -class BrightIDMeetVerificationAdmin(admin.ModelAdmin): - list_display = ["pk", "name"] - - -class BrightIDAuraVerificationAdmin(admin.ModelAdmin): - list_display = ["pk", "name"] - - -class OncePerWeekVerificationAdmin(admin.ModelAdmin): - list_display = ["pk", "name"] - - -class OncePerMonthVerificationAdmin(admin.ModelAdmin): - list_display = ["pk", "name"] - - -class OnceInALifeTimeVerificationAdmin(admin.ModelAdmin): - list_display = ["pk", "name"] - - -admin.site.register(BrightIDMeetVerification, BrightIDMeetVerificationAdmin) -admin.site.register(BrightIDAuraVerification, BrightIDAuraVerificationAdmin) -admin.site.register(OncePerWeekVerification, OncePerWeekVerificationAdmin) -admin.site.register(OncePerMonthVerification, OncePerMonthVerificationAdmin) -admin.site.register(OnceInALifeTimeVerification, OnceInALifeTimeVerificationAdmin) diff --git a/permissions/apps.py b/permissions/apps.py deleted file mode 100644 index a34c8fda..00000000 --- a/permissions/apps.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.apps import AppConfig - - -class PermissionsConfig(AppConfig): - default_auto_field = 'django.db.models.BigAutoField' - name = 'permissions' diff --git a/permissions/migrations/0001_initial.py b/permissions/migrations/0001_initial.py deleted file mode 100644 index 061cab1e..00000000 --- a/permissions/migrations/0001_initial.py +++ /dev/null @@ -1,50 +0,0 @@ -# Generated by Django 4.0.4 on 2023-05-09 19:19 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ('contenttypes', '0002_remove_content_type_name'), - ] - - 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)), - ('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',), - ), - ] diff --git a/permissions/migrations/0002_permission_description.py b/permissions/migrations/0002_permission_description.py deleted file mode 100644 index 891dc499..00000000 --- a/permissions/migrations/0002_permission_description.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.0.4 on 2023-05-12 08:51 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('permissions', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='permission', - name='description', - field=models.TextField(blank=True, null=True), - ), - ] diff --git a/permissions/migrations/0003_onceperweekverification.py b/permissions/migrations/0003_onceperweekverification.py deleted file mode 100644 index 61942a7a..00000000 --- a/permissions/migrations/0003_onceperweekverification.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by Django 4.0.4 on 2023-05-21 06:20 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('permissions', '0002_permission_description'), - ] - - operations = [ - migrations.CreateModel( - name='OncePerWeekVerification', - 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/migrations/0004_oncepermonthverification.py b/permissions/migrations/0004_oncepermonthverification.py deleted file mode 100644 index 2994d0d1..00000000 --- a/permissions/migrations/0004_oncepermonthverification.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by Django 4.0.4 on 2023-05-21 06:33 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('permissions', '0003_onceperweekverification'), - ] - - operations = [ - migrations.CreateModel( - name='OncePerMonthVerification', - 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/migrations/0005_onceinalifetimeverification.py b/permissions/migrations/0005_onceinalifetimeverification.py deleted file mode 100644 index 0d998174..00000000 --- a/permissions/migrations/0005_onceinalifetimeverification.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by Django 4.0.4 on 2023-06-09 15:18 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('permissions', '0004_oncepermonthverification'), - ] - - operations = [ - 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/migrations/__init__.py b/permissions/migrations/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/permissions/models.py b/permissions/models.py deleted file mode 100644 index c1d5e0a7..00000000 --- a/permissions/models.py +++ /dev/null @@ -1,74 +0,0 @@ -from django.db import models -from polymorphic.models import PolymorphicModel - -from faucet.faucet_manager.credit_strategy import RoundCreditStrategy - - -class Permission(PolymorphicModel): - name = models.CharField(max_length=200) - description = models.TextField(null=True, blank=True) - - def is_valid(self, *args, **kwargs): - # Override this method in subclasses - return False - - def __str__(self): - return self.name - - -class BrightIDMeetVerification(Permission): - def is_valid(self, user_profile, *args, **kwargs): - return user_profile.is_meet_verified - - def response(self): - return "You must be verified on BrightID to claim this token." - - -class BrightIDAuraVerification(Permission): - def is_valid(self, user_profile, *args, **kwargs): - return user_profile.is_aura_verified - - def response(self): - return "You must be Aura verified on BrightID to claim this token." - - -class OncePerWeekVerification(Permission): - def is_valid(self, user_profile, *args, **kwargs): - token_distribution = kwargs.get("token_distribution") - return not token_distribution.claims.filter( - user_profile=user_profile, - created_at__gte=RoundCreditStrategy.get_start_of_the_round(), - ).exists() - - def response(self): - return "You have already claimed this token this week" - - -class OncePerMonthVerification(Permission): - def is_valid(self, user_profile, *args, **kwargs): - token_distribution = kwargs.get("token_distribution") - return not token_distribution.claims.filter( - user_profile=user_profile, - created_at__gte=RoundCreditStrategy.get_start_of_the_round(), - ).exists() - - def response(self): - return "You have already claimed this token this month" - - -class OnceInALifeTimeVerification(Permission): - def is_valid(self, user_profile, *args, **kwargs): - token_distribution = kwargs.get("token_distribution") - return not token_distribution.claims.filter( - user_profile=user_profile, - ).exists() - - def response(self): - return "You have already claimed this token" - - -# class WhitelistVerification(Permission): -# def is_valid(self, user_profile, *args, **kwargs): -# if user_profile.wallets.filter(wallet_type="EVM").exists(): -# return user_profile.wallets.filter(wallet_type="EVM").first().address in [] -# return False diff --git a/permissions/serializers.py b/permissions/serializers.py deleted file mode 100644 index 42d21590..00000000 --- a/permissions/serializers.py +++ /dev/null @@ -1,34 +0,0 @@ -from rest_framework import serializers -from rest_polymorphic.serializers import PolymorphicSerializer - -from permissions.models import ( - BrightIDAuraVerification, - BrightIDMeetVerification, - Permission, -) - - -class PermissionBaseSerializer(serializers.ModelSerializer): - class Meta: - model = Permission - 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 PermissionSerializer(PolymorphicSerializer): - model_serializer_mapping = { - Permission: PermissionBaseSerializer, - BrightIDMeetVerification: BrightIDMeetVerificationSerializer, - BrightIDAuraVerification: BrightIDAuraVerificationSerializer, - } diff --git a/permissions/tests.py b/permissions/tests.py deleted file mode 100644 index 3487ab0b..00000000 --- a/permissions/tests.py +++ /dev/null @@ -1,28 +0,0 @@ -# from rest_framework.test import APITestCase -# from .models import * - - -# class PermissionsTestCase(APITestCase): -# def setUp(self) -> None: -# pass - -# def test_permissions_creation(self): -# p = BrightIDMeetVerification.objects.create(name="BrightID Meet Verification") -# self.assertEqual(Permission.objects.count(), 1) -# self.assertEqual(Permission.objects.first(), p) - -# p2 = BrightIDAuraVerification.objects.create(name="BrightID Aura Verification") -# self.assertEqual(Permission.objects.count(), 2) -# self.assertEqual(Permission.objects.last(), p2) - -# p3 = OncePerWeekVerification.objects.create(name="Once Per Week Verification") -# self.assertEqual(Permission.objects.count(), 3) -# self.assertEqual(Permission.objects.last(), p3) - -# p4 = OncePerMonthVerification.objects.create(name="Once Per Month Verification") -# self.assertEqual(Permission.objects.count(), 4) -# self.assertEqual(Permission.objects.last(), p4) - -# p5 = OnceInALifeTimeVerification.objects.create(name="Once In A Life Time Verification") -# self.assertEqual(Permission.objects.count(), 5) -# self.assertEqual(Permission.objects.last(), p5) diff --git a/permissions/views.py b/permissions/views.py deleted file mode 100644 index 91ea44a2..00000000 --- a/permissions/views.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.shortcuts import render - -# Create your views here. diff --git a/prizetap/migrations/0003_raffle_permissions.py b/prizetap/migrations/0003_raffle_permissions.py index 201b70e2..f78f3a80 100644 --- a/prizetap/migrations/0003_raffle_permissions.py +++ b/prizetap/migrations/0003_raffle_permissions.py @@ -6,14 +6,14 @@ class Migration(migrations.Migration): dependencies = [ - ('permissions', '0004_oncepermonthverification'), + # ('permissions', '0004_oncepermonthverification'), ('prizetap', '0002_raffle_is_prize_nft'), ] operations = [ - migrations.AddField( - model_name='raffle', - name='permissions', - field=models.ManyToManyField(blank=True, to='permissions.permission'), - ), + # migrations.AddField( + # model_name='raffle', + # name='permissions', + # field=models.ManyToManyField(blank=True, to='permissions.permission'), + # ), ] diff --git a/prizetap/migrations/0009_constraint_remove_raffle_permissions_and_more.py b/prizetap/migrations/0009_constraint_remove_raffle_permissions_and_more.py index b62f3a71..7002f114 100644 --- a/prizetap/migrations/0009_constraint_remove_raffle_permissions_and_more.py +++ b/prizetap/migrations/0009_constraint_remove_raffle_permissions_and_more.py @@ -21,10 +21,10 @@ class Migration(migrations.Migration): 'abstract': False, }, ), - migrations.RemoveField( - model_name='raffle', - name='permissions', - ), + # migrations.RemoveField( + # model_name='raffle', + # name='permissions', + # ), migrations.AddField( model_name='raffle', name='constraints', diff --git a/tokenTap/migrations/0002_tokendistribution_permissions.py b/tokenTap/migrations/0002_tokendistribution_permissions.py index 3666fc02..b087f2aa 100644 --- a/tokenTap/migrations/0002_tokendistribution_permissions.py +++ b/tokenTap/migrations/0002_tokendistribution_permissions.py @@ -6,14 +6,14 @@ class Migration(migrations.Migration): dependencies = [ - ('permissions', '0001_initial'), + # ('permissions', '0001_initial'), ('tokenTap', '0001_initial'), ] operations = [ - migrations.AddField( - model_name='tokendistribution', - name='permissions', - field=models.ManyToManyField(blank=True, to='permissions.permission'), - ), + # migrations.AddField( + # model_name='tokendistribution', + # name='permissions', + # field=models.ManyToManyField(blank=True, to='permissions.permission'), + # ), ] diff --git a/tokenTap/migrations/0015_constraint_alter_tokendistribution_permissions.py b/tokenTap/migrations/0015_constraint_alter_tokendistribution_permissions.py index 02e2678e..994c44b2 100644 --- a/tokenTap/migrations/0015_constraint_alter_tokendistribution_permissions.py +++ b/tokenTap/migrations/0015_constraint_alter_tokendistribution_permissions.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): 'abstract': False, }, ), - migrations.AlterField( + migrations.AddField( model_name='tokendistribution', name='permissions', field=models.ManyToManyField(blank=True, to='tokenTap.constraint'),