diff --git a/combo/data/migrations/0044_validity_info.py b/combo/data/migrations/0044_validity_info.py new file mode 100644 index 00000000..191dafbc --- /dev/null +++ b/combo/data/migrations/0044_validity_info.py @@ -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')]), + ), + ] diff --git a/combo/data/models.py b/combo/data/models.py index 00867d94..93f26212 100644 --- a/combo/data/models.py +++ b/combo/data/models.py @@ -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'