summaryrefslogtreecommitdiff
path: root/archaeological_context_records/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r--archaeological_context_records/models.py85
1 files changed, 4 insertions, 81 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index b12a31516..11b7732f8 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -30,11 +30,11 @@ from django.utils.text import slugify
from ishtar_common.utils import cached_label_changed
-from ishtar_common.models import BaseSource, Document, GeneralType, \
+from ishtar_common.models import Document, GeneralType, \
BaseHistorizedItem, HistoricalRecords, OwnPerms, ShortMenuItem, \
GeneralRelationType, GeneralRecordRelations, post_delete_record_relation,\
- get_image_path, post_save_cache, ValueGetter, BulkUpdatedItem, \
- IshtarImage, RelationItem, ThroughImage, Town
+ post_save_cache, ValueGetter, BulkUpdatedItem, \
+ RelationItem, Town
from archaeological_operations.models import Operation, Period, Parcel, \
ArchaeologicalSite
@@ -329,8 +329,6 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
documents = models.ManyToManyField(
Document, related_name='context_records', verbose_name=_(u"Documents"),
blank=True)
- images = models.ManyToManyField(IshtarImage, verbose_name=_(u"Images"),
- blank=True, through='ContextRecordImage')
cached_label = models.TextField(_(u"Cached name"), null=True, blank=True,
db_index=True)
PARENT_SEARCH_VECTORS = ['operation']
@@ -554,8 +552,7 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
return u" ; ".join(crs)
def find_docs_q(self):
- from archaeological_finds.models import FindSource
- return FindSource.objects.filter(find__base_finds__context_record=self)
+ return Document.objects.filter(finds__base_finds__context_record=self)
def fix(self):
"""
@@ -575,11 +572,6 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
post_save.connect(cached_label_changed, sender=ContextRecord)
-class ContextRecordImage(ThroughImage):
- item = models.ForeignKey(ContextRecord, on_delete=models.CASCADE,
- related_name='associated_images')
-
-
class RelationType(GeneralRelationType):
class Meta:
verbose_name = _(u"Relation type")
@@ -679,72 +671,3 @@ class RecordRelationView(models.Model):
def __unicode__(self):
return u"{} \"{}\"".format(self.relation_type, self.right_record)
-
-
-class ContextRecordSource(BaseSource):
- SHOW_URL = 'show-contextrecordsource'
- MODIFY_URL = 'record_source_modify'
- TABLE_COLS = ['context_record__operation__cached_label', 'context_record']\
- + BaseSource.TABLE_COLS
- COL_LABELS = {'context_record__operation__cached_label': _(u"Operation")}
-
- # search parameters
- RELATIVE_SESSION_NAMES = [
- ('contextrecord', 'context_record__pk'),
- ('operation', 'context_record__operation__pk'),
- ('file', 'context_record__operation__associated_file__pk')]
- BOOL_FIELDS = ['duplicate']
- EXTRA_REQUEST_KEYS = {
- 'title': 'title__icontains',
- 'description': 'description__icontains',
- 'comment': 'comment__icontains',
- 'person': 'authors__person__pk',
- 'additional_information': 'additional_information__icontains',
- 'context_record__town': 'context_record__town__pk',
- 'context_record__operation__year': 'context_record__operation__year',
- 'context_record__operation__operation_code':
- 'context_record__operation__operation_code',
- 'context_record__operation__code_patriarche':
- 'context_record__operation__code_patriarche',
- 'context_record__operation': 'context_record__operation__pk',
- 'context_record__datings__period':
- 'context_record__datings__period__pk',
- 'context_record__unit': 'context_record__unit__pk',
- }
- PARENT_SEARCH_VECTORS = BaseSource.PARENT_SEARCH_VECTORS + [
- 'context_record']
-
- class Meta:
- verbose_name = _(u"Context record documentation")
- verbose_name_plural = _(u"Context record documentations")
- permissions = (
- ("view_contextrecordsource",
- u"Can view all Context record sources"),
- ("view_own_contextrecordsource",
- u"Can view own Context record source"),
- ("add_own_contextrecordsource",
- u"Can add own Context record source"),
- ("change_own_contextrecordsource",
- u"Can change own Context record source"),
- ("delete_own_contextrecordsource",
- u"Can delete own Context record source"),
- )
- context_record = models.ForeignKey(
- ContextRecord, verbose_name=_(u"Context record"),
- related_name="source")
-
- @property
- def owner(self):
- return self.context_record
-
- @classmethod
- def get_query_owns(cls, ishtaruser):
- q = cls._construct_query_own(
- 'context_record__operation__',
- Operation._get_query_owns_dicts(ishtaruser)
- ) | cls._construct_query_own('', [
- {'context_record__history_creator': ishtaruser.user_ptr},
- {'context_record__operation__end_date__isnull': True}
- ])
- return q
-