Re-enable the custom Radio IRI model form/field.
This commit is contained in:
parent
f3ec6a1ae3
commit
d866ce7cda
4 changed files with 13 additions and 35 deletions
|
@ -2,11 +2,12 @@
|
|||
Custom model fields for the Save Point Radio project.
|
||||
'''
|
||||
|
||||
from django.core import validators
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from .forms import ALLOWED_SCHEMES, RadioIRIFormField
|
||||
from core.validators import RadioIRIValidator
|
||||
|
||||
from .forms import RadioIRIFormField
|
||||
|
||||
|
||||
class RadioIRIField(models.TextField):
|
||||
|
@ -19,13 +20,7 @@ class RadioIRIField(models.TextField):
|
|||
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)]
|
||||
default_validators = [RadioIRIValidator()]
|
||||
description = _("Long IRI")
|
||||
|
||||
def __init__(self, verbose_name=None, name=None, **kwargs):
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
Custom forms/formfields for the Save Point Radio project.
|
||||
'''
|
||||
|
||||
from django.core import validators
|
||||
from django.forms.fields import URLField
|
||||
|
||||
|
||||
ALLOWED_SCHEMES = ['http', 'https', 'file', 'ftp', 'ftps', 's3']
|
||||
from core.validators import RadioIRIValidator
|
||||
|
||||
|
||||
class RadioIRIFormField(URLField):
|
||||
|
@ -19,10 +17,4 @@ class RadioIRIFormField(URLField):
|
|||
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)]
|
||||
default_validators = [RadioIRIValidator()]
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
# Generated by Django 2.2.1 on 2019-06-03 18:39
|
||||
# Generated by Django 2.2.1 on 2019-06-06 19:06
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import radio.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -18,7 +19,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', models.TextField(verbose_name='IRI path to song file')),
|
||||
('iri', radio.fields.RadioIRIField(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)')),
|
||||
|
|
|
@ -9,11 +9,11 @@ from django.apps import apps
|
|||
from django.core.validators import MinValueValidator
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_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,17 +104,7 @@ class Store(Timestampable, models.Model):
|
|||
'''
|
||||
A model to represent various data locations (stores) for the song.
|
||||
'''
|
||||
# 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'))
|
||||
iri = RadioIRIField(_('IRI path to song file'))
|
||||
mime_type = models.CharField(_('file MIME type'),
|
||||
max_length=64,
|
||||
blank=True)
|
||||
|
|
Loading…
Reference in a new issue