Skip to content

Commit

Permalink
fixed record urls
Browse files Browse the repository at this point in the history
  • Loading branch information
alimaktabi committed Sep 13, 2024
1 parent a55624e commit 3e7f124
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
32 changes: 32 additions & 0 deletions prizetap/migrations/0079_fix_raffle_image_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.0.4 on 2024-08-25 09:12

from django.db import migrations, models


def fix_raffle_images_prefix(apps, schema):
Raffle = apps.get_model("prizetap", "Raffle")

raffles = Raffle.objects.all()

for raffle in raffles:
if (
raffle.image
and raffle.image.name
and raffle.image.name.startswith("https://imagedelivery.net")
):
# split the url to get the image id
raffle.image.name = raffle.image.name.split("/")[-2]
raffle.save()


class Migration(migrations.Migration):

dependencies = [
("tokenTap", "0078_alter_constraint_name"),
]

operations = [
migrations.RunPython(
fix_raffle_images_prefix, reverse_code=migrations.RunPython.noop
)
]
40 changes: 40 additions & 0 deletions tokenTap/migrations/0065_fix_token_image_prefix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 4.0.4 on 2024-08-25 09:12

from django.db import migrations, models


def fix_token_images_prefix(apps, schema_editor):
TokenDistribution = apps.get_model("tokenTap", "TokenDistribution")

tokens = TokenDistribution.objects.all()

for token in tokens:
if (
token.image
and token.image.name
and token.image.name.startswith("https://imagedelivery.net")
):
# split the url to get the image id
token.image.name = token.image.name.split("/")[-2]
token.save()

if (
token.token_image
and token.token_image.name
and token.token_image.name.startswith("https://imagedelivery.net")
):
token.token_image.name = token.token_image.name.split("/")[-2]
token.save()


class Migration(migrations.Migration):

dependencies = [
("tokenTap", "0064_alter_constraint_name"),
]

operations = [
migrations.RunPython(
fix_token_images_prefix, reverse_code=migrations.RunPython.noop
)
]

0 comments on commit 3e7f124

Please sign in to comment.