Skip to content

Commit

Permalink
Merge pull request #210 from UnitapApp/refactor/relocate-chain-configs
Browse files Browse the repository at this point in the history
Use core chain in prizetap
  • Loading branch information
ShayanShiravani authored Dec 5, 2023
2 parents e4a95b9 + e6cfd31 commit dfb919f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
20 changes: 20 additions & 0 deletions prizetap/migrations/0045_alter_raffle_chain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.0.4 on 2023-12-04 07:17

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('core', '0005_auto_20231203_0832'),
('prizetap', '0044_raffle_reversed_constraints'),
]

operations = [
migrations.AlterField(
model_name='raffle',
name='chain',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='raffles', to='core.chain'),
),
]
23 changes: 16 additions & 7 deletions prizetap/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
from django.utils.translation import gettext_lazy as _

from authentication.models import NetworkTypes, UserProfile
from core.models import BigNumField, UserConstraint
from core.models import BigNumField, Chain, UserConstraint
from faucet.constraints import OptimismClaimingGasConstraint, OptimismDonationConstraint
from faucet.models import Chain

from .constraints import HaveUnitapPass, NotHaveUnitapPass

Expand All @@ -33,15 +32,19 @@ class Status(models.TextChoices):
CLOSED = "CLOSED", _("Closed")

class Meta:
models.UniqueConstraint(fields=["chain", "contract", "raffleId"], name="unique_raffle")
models.UniqueConstraint(
fields=["chain", "contract", "raffleId"], name="unique_raffle"
)

name = models.CharField(max_length=256)
description = models.TextField(null=True, blank=True)
necessary_information = models.TextField(null=True, blank=True)
contract = models.CharField(max_length=256)
raffleId = models.BigIntegerField(null=True, blank=True)
creator_name = models.CharField(max_length=255, null=True, blank=True)
creator_profile = models.ForeignKey(UserProfile, on_delete=models.DO_NOTHING, related_name="raffles")
creator_profile = models.ForeignKey(
UserProfile, on_delete=models.DO_NOTHING, related_name="raffles"
)
creator_address = models.CharField(max_length=255)
creator_url = models.URLField(max_length=255, null=True, blank=True)
discord_url = models.URLField(max_length=255, null=True, blank=True)
Expand Down Expand Up @@ -73,7 +76,9 @@ class Meta:
max_multiplier = models.IntegerField(default=1, validators=[MinValueValidator(1)])
winners_count = models.IntegerField(default=1, validators=[MinValueValidator(1)])

status = models.CharField(max_length=10, choices=Status.choices, default=Status.PENDING)
status = models.CharField(
max_length=10, choices=Status.choices, default=Status.PENDING
)
rejection_reason = models.TextField(null=True, blank=True)
tx_hash = models.CharField(max_length=255, blank=True, null=True)
vrf_tx_hash = models.CharField(max_length=255, blank=True, null=True)
Expand Down Expand Up @@ -142,7 +147,9 @@ class Meta:
verbose_name_plural = "raffle entries"

raffle = models.ForeignKey(Raffle, on_delete=models.CASCADE, related_name="entries")
user_profile = models.ForeignKey(UserProfile, on_delete=models.CASCADE, related_name="raffle_entries")
user_profile = models.ForeignKey(
UserProfile, on_delete=models.CASCADE, related_name="raffle_entries"
)

created_at = models.DateTimeField(auto_now_add=True, editable=True)

Expand All @@ -165,7 +172,9 @@ def age(self):

class LineaRaffleEntries(models.Model):
wallet_address = models.CharField(max_length=255)
raffle = models.ForeignKey(Raffle, on_delete=models.CASCADE, related_name="linea_entries")
raffle = models.ForeignKey(
Raffle, on_delete=models.CASCADE, related_name="linea_entries"
)
is_winner = models.BooleanField(blank=True, default=False)
claim_tx = models.CharField(max_length=255, blank=True, null=True)

Expand Down

0 comments on commit dfb919f

Please sign in to comment.