Commit e87d0045 authored by fred's avatar fred

adjust for django 2.2

parent be9b7055
......@@ -9,7 +9,7 @@ from django.forms import fields
from django.forms import ValidationError
from django.core.files.storage import DefaultStorage
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import force_text
......
......@@ -16,7 +16,7 @@ from optparse import make_option
from django.conf import settings
from django.core.files import File
from django.core.management.base import BaseCommand, CommandError
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.utils.html import strip_tags
from django.utils.text import slugify
......
......@@ -164,7 +164,8 @@ class Migration(migrations.Migration):
('has_focus', models.BooleanField(default=False)),
('creation_timestamp', models.DateTimeField(auto_now_add=True, null=True)),
('last_update_timestamp', models.DateTimeField(auto_now=True, null=True)),
('emission', models.ForeignKey(verbose_name='Emission', to='emissions.Emission')),
('emission', models.ForeignKey(verbose_name='Emission',
to='emissions.Emission', on_delete=models.CASCADE)),
(
'tags',
taggit.managers.TaggableManager(
......@@ -200,12 +201,16 @@ class Migration(migrations.Migration):
(
'emission',
models.ForeignKey(
verbose_name='Emission', blank=True, to='emissions.Emission', null=True
verbose_name='Emission', blank=True,
to='emissions.Emission', null=True,
on_delete=models.CASCADE
),
),
(
'episode',
models.ForeignKey(verbose_name='Episode', blank=True, to='emissions.Episode', null=True),
models.ForeignKey(verbose_name='Episode', blank=True,
to='emissions.Episode', null=True,
on_delete=models.CASCADE),
),
],
options={},
......@@ -274,13 +279,17 @@ class Migration(migrations.Migration):
(
'category',
models.ForeignKey(
verbose_name='Category', blank=True, to='emissions.NewsCategory', null=True
verbose_name='Category', blank=True,
to='emissions.NewsCategory', null=True,
on_delete=models.SET_NULL
),
),
(
'emission',
models.ForeignKey(
verbose_name='Emission', blank=True, to='emissions.Emission', null=True
verbose_name='Emission', blank=True,
to='emissions.Emission', null=True,
on_delete=models.CASCADE
),
),
(
......@@ -352,7 +361,8 @@ class Migration(migrations.Migration):
help_text='In minutes', null=True, verbose_name='Duration', blank=True
),
),
('emission', models.ForeignKey(verbose_name='Emission', to='emissions.Emission')),
('emission', models.ForeignKey(verbose_name='Emission',
to='emissions.Emission', on_delete=models.CASCADE)),
],
options={
'ordering': ['datetime'],
......@@ -398,10 +408,13 @@ class Migration(migrations.Migration):
('has_focus', models.BooleanField(default=False)),
('creation_timestamp', models.DateTimeField(auto_now_add=True, null=True)),
('last_update_timestamp', models.DateTimeField(auto_now=True, null=True)),
('episode', models.ForeignKey(verbose_name='Episode', to='emissions.Episode')),
('episode', models.ForeignKey(verbose_name='Episode',
to='emissions.Episode', on_delete=models.CASCADE)),
(
'format',
models.ForeignKey(verbose_name='Format', blank=True, to='emissions.Format', null=True),
models.ForeignKey(verbose_name='Format', blank=True,
to='emissions.Format', null=True,
on_delete=models.SET_NULL),
),
],
options={
......@@ -413,27 +426,35 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='focus',
name='newsitem',
field=models.ForeignKey(verbose_name='News Item', blank=True, to='emissions.NewsItem', null=True),
field=models.ForeignKey(verbose_name='News Item', blank=True,
to='emissions.NewsItem', null=True,
on_delete=models.CASCADE
),
preserve_default=True,
),
migrations.AddField(
model_name='focus',
name='soundfile',
field=models.ForeignKey(
verbose_name='Sound file', blank=True, to='emissions.SoundFile', null=True
verbose_name='Sound file', blank=True,
to='emissions.SoundFile', null=True,
on_delete=models.CASCADE
),
preserve_default=True,
),
migrations.AddField(
model_name='diffusion',
name='episode',
field=models.ForeignKey(verbose_name='Episode', to='emissions.Episode'),
field=models.ForeignKey(verbose_name='Episode',
to='emissions.Episode',
on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AddField(
model_name='absence',
name='emission',
field=models.ForeignKey(verbose_name='Emission', to='emissions.Emission'),
field=models.ForeignKey(verbose_name='Emission',
to='emissions.Emission', on_delete=models.CASCADE),
preserve_default=True,
),
]
......@@ -15,7 +15,8 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='focus',
name='page',
field=models.ForeignKey(verbose_name='Page', blank=True, to='data.Page', null=True),
field=models.ForeignKey(verbose_name='Page', blank=True,
to='data.Page', null=True, on_delete=models.SET_NULL),
preserve_default=True,
),
]
......@@ -30,7 +30,7 @@ class Migration(migrations.Migration):
),
),
('order', models.PositiveIntegerField()),
('episode', models.ForeignKey(to='emissions.Episode', null=True)),
('episode', models.ForeignKey(to='emissions.Episode', null=True, on_delete=models.CASCADE)),
],
options={
'ordering': ['order'],
......
# Generated by Django 2.2.19 on 2021-03-26 13:24
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('emissions', '0016_soundfile_download_count'),
]
operations = [
migrations.AlterField(
model_name='focus',
name='page',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='data.Page', verbose_name='Page'),
),
]
......@@ -4,7 +4,7 @@ import os
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.forms import fields
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
......@@ -239,7 +239,7 @@ class Schedule(models.Model, WeekdayMixin):
(0b0101, _('First and third week')),
(0b1010, _('Second and fourth week')),
)
emission = models.ForeignKey('Emission', verbose_name=u'Emission')
emission = models.ForeignKey('Emission', verbose_name=u'Emission', on_delete=models.CASCADE)
datetime = models.DateTimeField()
weeks = models.IntegerField(_('Weeks'), default=15, choices=WEEK_CHOICES)
rerun = models.BooleanField(_('Rerun'), default=False)
......@@ -343,7 +343,7 @@ class Episode(models.Model):
verbose_name_plural = _('Episodes')
ordering = ['title']
emission = models.ForeignKey('Emission', verbose_name=_('Emission'))
emission = models.ForeignKey('Emission', verbose_name=_('Emission'), on_delete=models.CASCADE)
title = models.CharField(_('Title'), max_length=200)
slug = models.SlugField(max_length=200)
subtitle = models.CharField(_('Subtitle'), max_length=150, null=True, blank=True)
......@@ -446,7 +446,7 @@ class Diffusion(models.Model, WeekdayMixin):
verbose_name_plural = _('Diffusions')
ordering = ['datetime']
episode = models.ForeignKey('Episode', verbose_name=_('Episode'))
episode = models.ForeignKey('Episode', verbose_name=_('Episode'), on_delete=models.CASCADE)
datetime = models.DateTimeField(_('Date/time'), db_index=True)
def __str__(self):
......@@ -470,7 +470,7 @@ class Absence(models.Model):
verbose_name = _('Absence')
verbose_name_plural = _('Absences')
emission = models.ForeignKey('Emission', verbose_name=u'Emission')
emission = models.ForeignKey('Emission', verbose_name=u'Emission', on_delete=models.CASCADE)
datetime = models.DateTimeField(_('Date/time'), db_index=True)
def __str__(self):
......@@ -488,7 +488,7 @@ class SoundFile(models.Model):
verbose_name_plural = _('Sound files')
ordering = ['creation_timestamp']
episode = models.ForeignKey('Episode', verbose_name=_('Episode'))
episode = models.ForeignKey('Episode', verbose_name=_('Episode'), on_delete=models.CASCADE)
file = models.FileField(_('File'), upload_to=get_sound_path, max_length=250)
podcastable = models.BooleanField(
_('Podcastable'),
......@@ -505,7 +505,7 @@ class SoundFile(models.Model):
title = models.CharField(_('Title'), max_length=200)
duration = models.IntegerField(_('Duration'), null=True, help_text=_('In seconds'))
format = models.ForeignKey('Format', verbose_name=_('Format'), null=True, blank=True)
format = models.ForeignKey('Format', verbose_name=_('Format'), null=True, blank=True, on_delete=models.SET_NULL)
license = models.CharField(_('License'), max_length=20, blank=True, default='', choices=LICENSES)
# denormalized from Focus
......@@ -591,8 +591,10 @@ class NewsItem(models.Model):
)
tags = TaggableManager(_('Tags'), blank=True)
category = models.ForeignKey('NewsCategory', verbose_name=_('Category'), null=True, blank=True)
emission = models.ForeignKey('Emission', verbose_name=_('Emission'), null=True, blank=True)
category = models.ForeignKey('NewsCategory', verbose_name=_('Category'),
null=True, blank=True, on_delete=models.SET_NULL)
emission = models.ForeignKey('Emission', verbose_name=_('Emission'),
null=True, blank=True, on_delete=models.CASCADE)
expiration_date = models.DateField(_('Expiration Date'), null=True, blank=True)
event_date = models.DateField(
......@@ -641,11 +643,16 @@ class Nonstop(models.Model):
@python_2_unicode_compatible
class Focus(models.Model):
title = models.CharField(_('Alternate Title'), max_length=50, null=True, blank=True)
newsitem = models.ForeignKey('NewsItem', verbose_name=_('News Item'), null=True, blank=True)
emission = models.ForeignKey('Emission', verbose_name=_('Emission'), null=True, blank=True)
episode = models.ForeignKey('Episode', verbose_name=_('Episode'), null=True, blank=True)
soundfile = models.ForeignKey('SoundFile', verbose_name=_('Sound file'), null=True, blank=True)
page = models.ForeignKey('data.Page', verbose_name=_('Page'), null=True, blank=True)
newsitem = models.ForeignKey('NewsItem', verbose_name=_('News Item'), null=True, blank=True,
on_delete=models.CASCADE)
emission = models.ForeignKey('Emission', verbose_name=_('Emission'), null=True, blank=True,
on_delete=models.CASCADE)
episode = models.ForeignKey('Episode', verbose_name=_('Episode'), null=True, blank=True,
on_delete=models.CASCADE)
soundfile = models.ForeignKey('SoundFile', verbose_name=_('Sound file'), null=True, blank=True,
on_delete=models.CASCADE)
page = models.ForeignKey('data.Page', verbose_name=_('Page'), null=True, blank=True,
on_delete=models.CASCADE)
current = models.BooleanField('Current', default=True)
creation_timestamp = models.DateTimeField(auto_now_add=True, null=True)
......@@ -751,7 +758,7 @@ def get_playlist_sound_path(instance, filename):
class PlaylistElement(models.Model):
episode = models.ForeignKey('Episode', null=True)
episode = models.ForeignKey('Episode', null=True, on_delete=models.CASCADE)
title = models.CharField(_('Title'), max_length=200)
notes = models.CharField(_('Notes'), max_length=200, blank=True, default='')
sound = models.FileField(_('Sound'), upload_to=get_playlist_sound_path, max_length=250)
......
......@@ -6,9 +6,9 @@ import time
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.core.files.storage import DefaultStorage
from django.core.urlresolvers import reverse_lazy
from django.urls import reverse_lazy
from django.http import HttpResponse, Http404, HttpResponseRedirect
from django.core.urlresolvers import reverse, reverse_lazy
from django.urls import reverse, reverse_lazy
from django.shortcuts import redirect
from django.utils.translation import ugettext as _, ugettext_lazy
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment