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

Remove unnecessary write-time validating URLTextField #4322

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 12 additions & 13 deletions api/api/migrations/0061_convert_varchar_to_text.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Generated by Django 4.2.11 on 2024-05-10 22:07

import api.models.fields
from django.db import migrations, models


Expand All @@ -24,7 +23,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='audio',
name='creator_url',
field=api.models.fields.URLTextField(blank=True, help_text='A direct link to the media creator.', max_length=2000, null=True),
field=models.TextField(blank=True, help_text='A direct link to the media creator.', max_length=2000, null=True),
),
migrations.AlterField(
model_name='audio',
Expand All @@ -34,12 +33,12 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='audio',
name='foreign_landing_url',
field=api.models.fields.URLTextField(blank=True, help_text='The landing page of the work.', null=True),
field=models.TextField(blank=True, help_text='The landing page of the work.', null=True),
),
migrations.AlterField(
model_name='audio',
name='thumbnail',
field=api.models.fields.URLTextField(blank=True, help_text='The thumbnail for the media.', null=True),
field=models.TextField(blank=True, help_text='The thumbnail for the media.', null=True),
),
migrations.AlterField(
model_name='audio',
Expand All @@ -49,7 +48,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='audio',
name='url',
field=api.models.fields.URLTextField(blank=True, help_text='The actual URL to the media file.', max_length=1000, null=True, unique=True),
field=models.TextField(blank=True, help_text='The actual URL to the media file.', max_length=1000, null=True, unique=True),
),
migrations.AlterField(
model_name='audioset',
Expand All @@ -59,7 +58,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='audioset',
name='creator_url',
field=api.models.fields.URLTextField(blank=True, help_text='A direct link to the media creator.', max_length=2000, null=True),
field=models.TextField(blank=True, help_text='A direct link to the media creator.', max_length=2000, null=True),
),
migrations.AlterField(
model_name='audioset',
Expand All @@ -69,12 +68,12 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='audioset',
name='foreign_landing_url',
field=api.models.fields.URLTextField(blank=True, help_text='The landing page of the work.', null=True),
field=models.TextField(blank=True, help_text='The landing page of the work.', null=True),
),
migrations.AlterField(
model_name='audioset',
name='thumbnail',
field=api.models.fields.URLTextField(blank=True, help_text='The thumbnail for the media.', null=True),
field=models.TextField(blank=True, help_text='The thumbnail for the media.', null=True),
),
migrations.AlterField(
model_name='audioset',
Expand All @@ -84,7 +83,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='audioset',
name='url',
field=api.models.fields.URLTextField(blank=True, help_text='The actual URL to the media file.', max_length=1000, null=True, unique=True),
field=models.TextField(blank=True, help_text='The actual URL to the media file.', max_length=1000, null=True, unique=True),
),
migrations.AlterField(
model_name='image',
Expand All @@ -94,7 +93,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='image',
name='creator_url',
field=api.models.fields.URLTextField(blank=True, help_text='A direct link to the media creator.', max_length=2000, null=True),
field=models.TextField(blank=True, help_text='A direct link to the media creator.', max_length=2000, null=True),
),
migrations.AlterField(
model_name='image',
Expand All @@ -104,12 +103,12 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='image',
name='foreign_landing_url',
field=api.models.fields.URLTextField(blank=True, help_text='The landing page of the work.', null=True),
field=models.TextField(blank=True, help_text='The landing page of the work.', null=True),
),
migrations.AlterField(
model_name='image',
name='thumbnail',
field=api.models.fields.URLTextField(blank=True, help_text='The thumbnail for the media.', null=True),
field=models.TextField(blank=True, help_text='The thumbnail for the media.', null=True),
),
migrations.AlterField(
model_name='image',
Expand All @@ -119,6 +118,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='image',
name='url',
field=api.models.fields.URLTextField(blank=True, help_text='The actual URL to the media file.', max_length=1000, null=True, unique=True),
field=models.TextField(blank=True, help_text='The actual URL to the media file.', max_length=1000, null=True, unique=True),
),
]
21 changes: 0 additions & 21 deletions api/api/models/fields.py

This file was deleted.

18 changes: 8 additions & 10 deletions api/api/models/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from django.db import models

from api.models import fields


class IdentifierMixin(models.Model):
"""
Expand Down Expand Up @@ -57,10 +55,10 @@ class MediaMixin(models.Model):
The mixin adds

- title: TextField
- foreign_landing_url: URLTextField
- foreign_landing_url: TextField
- creator: TextField
- creator_url: URLTextField
- thumbnail: URLTextField
- creator_url: TextField
- thumbnail: TextField
- provider: CharField
"""

Expand All @@ -69,7 +67,7 @@ class MediaMixin(models.Model):
null=True,
help_text="The name of the media.",
)
foreign_landing_url = fields.URLTextField(
foreign_landing_url = models.TextField(
blank=True,
null=True,
help_text="The landing page of the work.",
Expand All @@ -80,7 +78,7 @@ class MediaMixin(models.Model):
null=True,
help_text="The name of the media creator.",
)
creator_url = fields.URLTextField(
creator_url = models.TextField(
max_length=2000,
blank=True,
null=True,
Expand All @@ -90,7 +88,7 @@ class MediaMixin(models.Model):
# Because all forms of media have a thumbnail for visual representation
# For images, this field is not used as images are generated using Photon.
# For audio, this field points to the artwork, or is ``null``.
thumbnail = fields.URLTextField(
thumbnail = models.TextField(
blank=True,
null=True,
help_text="The thumbnail for the media.",
Expand All @@ -117,12 +115,12 @@ class FileMixin(models.Model):

This mixin adds

- url: URLTextField
- url: TextField
- filesize: IntegerField
- filetype: CharField
"""

url = fields.URLTextField(
url = models.TextField(
unique=True,
max_length=1000,
help_text="The actual URL to the media file.",
Expand Down
Loading