Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Remove unnecessary write-time validating URLTextField (#4322)
sarayourfriendbb2bfd5ee055
diff --git a/api/api/migrations/0061_convert_varchar_to_text.py b/api/api/migrations/0061_convert_varchar_to_text.pyindex cd907a4bc..4685533c4 100644--- a/api/api/migrations/0061_convert_varchar_to_text.py+++ b/api/api/migrations/0061_convert_varchar_to_text.py@@ -1,6 +1,5 @@# Generated by Django 4.2.11 on 2024-05-10 22:07-import api.models.fieldsfrom django.db import migrations, models@@ -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',@@ -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',@@ -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',@@ -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',@@ -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',@@ -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',@@ -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',@@ -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',@@ -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),),]diff --git a/api/api/models/fields.py b/api/api/models/fields.pydeleted file mode 100644index 208d26236..000000000--- a/api/api/models/fields.py+++ /dev/null@@ -1,21 +0,0 @@-from django import forms-from django.core import validators-from django.db import models-from django.utils.translation import gettext_lazy as _---class URLTextField(models.TextField):- """URL field which uses the underlying Postgres TEXT column type."""-- default_validators = [validators.URLValidator()]- description = _("URL")-- def formfield(self, **kwargs):- # As with CharField, this will cause URL validation to be performed- # twice.- return super().formfield(- **{- "form_class": forms.URLField,- **kwargs,- }- )diff --git a/api/api/models/mixins.py b/api/api/models/mixins.pyindex 4594cd24f..e1f77a465 100644--- a/api/api/models/mixins.py+++ b/api/api/models/mixins.py@@ -2,8 +2,6 @@ import mimetypesfrom django.db import models-from api.models import fields-class IdentifierMixin(models.Model):"""@@ -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"""@@ -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.",@@ -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,@@ -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.",@@ -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.",