Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed record urls #621

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
)
]
Loading