diff options
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index ae86a42ef..977fbdb4a 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -24,7 +24,7 @@ from django.conf import settings from django.contrib.gis.db import models from django.core.urlresolvers import reverse from django.db.models import Q, Count, Sum, Max, Avg -from django.db.models.signals import post_save, m2m_changed +from django.db.models.signals import post_save, m2m_changed, post_delete from django.forms import ValidationError from django.utils.translation import ugettext_lazy as _, ugettext @@ -33,7 +33,8 @@ from ishtar_common.utils import cached_label_changed from ishtar_common.models import GeneralType, BaseHistorizedItem, \ HistoricalRecords, LightHistorizedItem, OwnPerms, Department, Source,\ Person, Organization, Town, Dashboard, IshtarUser, ValueGetter, \ - DocumentTemplate, ShortMenuItem, DashboardFormItem + DocumentTemplate, ShortMenuItem, DashboardFormItem, GeneralRelationType,\ + GeneralRecordRelations, post_delete_record_relation FILES_AVAILABLE = 'archaeological_files' in settings.INSTALLED_APPS @@ -473,6 +474,31 @@ def operation_post_save(sender, **kwargs): post_save.connect(operation_post_save, sender=Operation) +class RelationType(GeneralRelationType): + inverse_relation = models.ForeignKey( + 'RelationType', verbose_name=_(u"Inverse relation"), blank=True, + null=True) + + class Meta: + verbose_name = _(u"Operation relation type") + verbose_name_plural = _(u"Operation relation types") + ordering = ('order',) + + +class RecordRelations(GeneralRecordRelations, models.Model): + left_record = models.ForeignKey(Operation, + related_name='right_relations') + right_record = models.ForeignKey(Operation, + related_name='left_relations') + relation_type = models.ForeignKey(RelationType) + + class Meta: + verbose_name = _(u"Operation record relation") + verbose_name_plural = _(u"Operation record relations") + +post_delete.connect(post_delete_record_relation, sender=RecordRelations) + + class OperationByDepartment(models.Model): ''' Database view for dashboard |