From eed7aee5960430ef2bc416e75717f29b27ef6fdb Mon Sep 17 00:00:00 2001 From: RecursiveGreen Date: Mon, 3 Jun 2019 14:41:23 -0400 Subject: [PATCH] Temporarily disable custom ModelField for IRI. --- savepointradio/radio/fields.py | 7 +++++++ savepointradio/radio/forms.py | 7 +++++++ .../migrations/0004_new_song_path_structure.py | 5 ++--- savepointradio/radio/models.py | 14 ++++++++++++-- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/savepointradio/radio/fields.py b/savepointradio/radio/fields.py index 8cc2b5d..ae70834 100644 --- a/savepointradio/radio/fields.py +++ b/savepointradio/radio/fields.py @@ -18,6 +18,13 @@ class RadioIRIField(models.TextField): https://code.djangoproject.com/ticket/25594 https://stackoverflow.com/questions/41756572/ ''' + + # TODO: Because of a shortcoming of Django's URLValidator code, the + # 'file://' scheme does not validate properly on most cases due to + # incompatibilities with optional hostnames. Disabling the custom field + # for now until I can figure out a non-lethal way of handling this. + # https://code.djangoproject.com/ticket/25595 + default_validators = [validators.URLValidator(schemes=ALLOWED_SCHEMES)] description = _("Long IRI") diff --git a/savepointradio/radio/forms.py b/savepointradio/radio/forms.py index 48c0667..0ae9eb8 100644 --- a/savepointradio/radio/forms.py +++ b/savepointradio/radio/forms.py @@ -18,4 +18,11 @@ class RadioIRIFormField(URLField): https://code.djangoproject.com/ticket/25594 https://stackoverflow.com/questions/41756572/ ''' + + # TODO: Because of a shortcoming of Django's URLValidator code, the + # 'file://' scheme does not validate properly on most cases due to + # incompatibilities with optional hostnames. Disabling the custom field + # for now until I can figure out a non-lethal way of handling this. + # https://code.djangoproject.com/ticket/25595 + default_validators = [validators.URLValidator(schemes=ALLOWED_SCHEMES)] diff --git a/savepointradio/radio/migrations/0004_new_song_path_structure.py b/savepointradio/radio/migrations/0004_new_song_path_structure.py index 691ed25..8ba7077 100644 --- a/savepointradio/radio/migrations/0004_new_song_path_structure.py +++ b/savepointradio/radio/migrations/0004_new_song_path_structure.py @@ -1,9 +1,8 @@ -# Generated by Django 2.2.1 on 2019-05-31 03:00 +# Generated by Django 2.2.1 on 2019-06-03 18:39 import django.core.validators from django.db import migrations, models import django.db.models.deletion -import radio.fields class Migration(migrations.Migration): @@ -19,7 +18,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created_date', models.DateTimeField(auto_now_add=True, verbose_name='added on')), ('modified_date', models.DateTimeField(auto_now=True, verbose_name='last modified')), - ('iri', radio.fields.RadioIRIField()), + ('iri', models.TextField(verbose_name='IRI path to song file')), ('mime_type', models.CharField(blank=True, max_length=64, verbose_name='file MIME type')), ('file_size', models.BigIntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0)], verbose_name='file size')), ('length', models.DecimalField(blank=True, decimal_places=2, max_digits=8, null=True, verbose_name='song length (in seconds)')), diff --git a/savepointradio/radio/models.py b/savepointradio/radio/models.py index d2d6187..9d020f8 100644 --- a/savepointradio/radio/models.py +++ b/savepointradio/radio/models.py @@ -13,7 +13,7 @@ from django.utils.translation import ugettext_lazy as _ from core.behaviors import Disableable, Publishable, Timestampable from core.utils import get_setting -from .fields import RadioIRIField +# from .fields import RadioIRIField from .managers import RadioManager, SongManager @@ -104,7 +104,17 @@ class Store(Timestampable, models.Model): ''' A model to represent various data locations (stores) for the song. ''' - iri = RadioIRIField() + # TODO: Because of a shortcoming of Django's URLValidator code, the + # 'file://' scheme does not validate properly on most cases due to + # incompatibilities with optional hostnames. Disabling the custom field + # for now until I can figure out a non-lethal way of handling this. + # https://code.djangoproject.com/ticket/25594 + # https://code.djangoproject.com/ticket/25595 + # https://stackoverflow.com/questions/41756572/ + + # iri = RadioIRIField() + + iri = models.TextField(_('IRI path to song file')) mime_type = models.CharField(_('file MIME type'), max_length=64, blank=True)