0001-cells-add-invalid-fields-38009.patch
combo/data/migrations/0044_validity_info.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
from __future__ import unicode_literals |
|
3 | ||
4 |
from django.db import migrations, models |
|
5 |
import django.db.models.deletion |
|
6 | ||
7 | ||
8 |
class Migration(migrations.Migration): |
|
9 | ||
10 |
dependencies = [ |
|
11 |
('contenttypes', '0002_remove_content_type_name'), |
|
12 |
('data', '0043_delete_externallinksearchitem'), |
|
13 |
] |
|
14 | ||
15 |
operations = [ |
|
16 |
migrations.CreateModel( |
|
17 |
name='ValidityInfo', |
|
18 |
fields=[ |
|
19 |
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
|
20 |
('object_id', models.PositiveIntegerField()), |
|
21 |
('invalid_reason_code', models.CharField(blank=True, editable=False, max_length=100, null=True)), |
|
22 |
('invalid_since', models.DateTimeField(blank=True, editable=False, null=True)), |
|
23 |
('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')), |
|
24 |
], |
|
25 |
), |
|
26 |
migrations.AlterUniqueTogether( |
|
27 |
name='validityinfo', |
|
28 |
unique_together=set([('content_type', 'object_id')]), |
|
29 |
), |
|
30 |
] |
combo/data/models.py | ||
---|---|---|
30 | 30 |
from django.apps import apps |
31 | 31 |
from django.conf import settings |
32 | 32 |
from django.contrib.auth.models import Group |
33 |
from django.contrib.contenttypes.fields import GenericForeignKey |
|
34 |
from django.contrib.contenttypes.fields import GenericRelation |
|
35 |
from django.contrib.contenttypes.models import ContentType |
|
33 | 36 |
from django.core.cache import cache |
34 | 37 |
from django.core.exceptions import ObjectDoesNotExist, ValidationError, PermissionDenied |
35 | 38 |
from django.core import serializers |
... | ... | |
526 | 529 |
ordering = ('creation_timestamp',) |
527 | 530 | |
528 | 531 | |
532 |
class ValidityInfo(models.Model): |
|
533 |
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) |
|
534 |
object_id = models.PositiveIntegerField() |
|
535 |
content_object = GenericForeignKey('content_type', 'object_id') |
|
536 | ||
537 |
invalid_reason_code = models.CharField(max_length=100, blank=True, null=True, editable=False) |
|
538 |
invalid_since = models.DateTimeField(blank=True, null=True, editable=False) |
|
539 | ||
540 |
class Meta: |
|
541 |
unique_together = [('content_type', 'object_id')] |
|
542 | ||
543 | ||
529 | 544 |
class CellMeta(MediaDefiningClass, ModelBase): |
530 | 545 |
pass |
531 | 546 | |
... | ... | |
548 | 563 |
groups = models.ManyToManyField(Group, verbose_name=_('Groups'), blank=True) |
549 | 564 |
last_update_timestamp = models.DateTimeField(auto_now=True) |
550 | 565 | |
566 |
validity_info = GenericRelation(ValidityInfo) |
|
567 | ||
551 | 568 |
default_form_class = None |
552 | 569 |
manager_form_factory_kwargs = {} |
553 | 570 |
manager_form_template = 'combo/cell_form.html' |
554 |
- |