cells: add invalid fields (#38009)

This commit is contained in:
Lauréline Guérin 2020-02-17 10:07:57 +01:00
parent 0e445cf6b9
commit 957864921b
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('data', '0043_delete_externallinksearchitem'),
]
operations = [
migrations.CreateModel(
name='ValidityInfo',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('object_id', models.PositiveIntegerField()),
('invalid_reason_code', models.CharField(blank=True, editable=False, max_length=100, null=True)),
('invalid_since', models.DateTimeField(blank=True, editable=False, null=True)),
('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
],
),
migrations.AlterUniqueTogether(
name='validityinfo',
unique_together=set([('content_type', 'object_id')]),
),
]

View File

@ -30,6 +30,9 @@ import subprocess
from django.apps import apps
from django.conf import settings
from django.contrib.auth.models import Group
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.fields import GenericRelation
from django.contrib.contenttypes.models import ContentType
from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist, ValidationError, PermissionDenied
from django.core import serializers
@ -526,6 +529,18 @@ class Redirect(models.Model):
ordering = ('creation_timestamp',)
class ValidityInfo(models.Model):
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type', 'object_id')
invalid_reason_code = models.CharField(max_length=100, blank=True, null=True, editable=False)
invalid_since = models.DateTimeField(blank=True, null=True, editable=False)
class Meta:
unique_together = [('content_type', 'object_id')]
class CellMeta(MediaDefiningClass, ModelBase):
pass
@ -548,6 +563,8 @@ class CellBase(six.with_metaclass(CellMeta, models.Model)):
groups = models.ManyToManyField(Group, verbose_name=_('Groups'), blank=True)
last_update_timestamp = models.DateTimeField(auto_now=True)
validity_info = GenericRelation(ValidityInfo)
default_form_class = None
manager_form_factory_kwargs = {}
manager_form_template = 'combo/cell_form.html'