diff options
Diffstat (limited to 'archaeological_finds/models_treatments.py')
| -rw-r--r-- | archaeological_finds/models_treatments.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index 6c173959a..b35912fd0 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -41,6 +41,8 @@ class TreatmentState(GeneralType): verbose_name = _(u"Treatment state type") verbose_name_plural = _(u"Treatment state types") ordering = ('label',) + + post_save.connect(post_save_cache, sender=TreatmentState) post_delete.connect(post_save_cache, sender=TreatmentState) @@ -71,6 +73,13 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem, # extra keys than can be passed to save method EXTRA_SAVED_KEYS = ('items', 'user') SLUG = 'treatment' + BASE_SEARCH_VECTORS = [ + 'treatment_types__label', 'treatment_state__label', 'label', 'goal', + 'external_id', 'comment', 'description', 'other_reference', + ] + INT_SEARCH_VECTORS = ["year", "index"] + M2M_SEARCH_VECTORS = ['downstream__cached_label', 'upstream__cached_label'] + PARENT_SEARCH_VECTORS = ['person', 'organization'] label = models.CharField(_(u"Label"), blank=True, null=True, max_length=200) other_reference = models.CharField(_(u"Other ref."), blank=True, null=True, @@ -277,6 +286,7 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem, return "-".join([str(slugify(getattr(self, attr))) for attr in ('year', 'index', 'label')]) + post_save.connect(cached_label_changed, sender=Treatment) @@ -293,6 +303,7 @@ def pre_delete_treatment(sender, **kwargs): find.downstream_treatment = None find.save() + pre_delete.connect(pre_delete_treatment, sender=Treatment) @@ -470,6 +481,8 @@ class TreatmentFileType(GeneralType): verbose_name = _(u"Treatment request type") verbose_name_plural = _(u"Treatment request types") ordering = ('label',) + + post_save.connect(post_save_cache, sender=TreatmentFileType) post_delete.connect(post_save_cache, sender=TreatmentFileType) @@ -479,6 +492,11 @@ class TreatmentFile(DashboardFormItem, ClosedItem, BaseHistorizedItem, SLUG = 'treatmentfile' SHOW_URL = 'show-treatmentfile' TABLE_COLS = ['type', 'year', 'index', 'internal_reference', 'name'] + BASE_SEARCH_VECTORS = [ + 'type__label', 'internal_reference', 'name', 'comment' + ] + INT_SEARCH_VECTORS = ['year', 'index'] + PARENT_SEARCH_VECTORS = ['in_charge', 'applicant', 'applicant_organisation'] SLUG = 'treatmentfile' # fields @@ -594,6 +612,7 @@ class TreatmentSource(Source): TABLE_COLS = ['treatment__cached_label'] + Source.TABLE_COLS COL_LABELS = {'treatment__cached_label': _(u"Treatment")} SHOW_URL = 'show-treatmentsource' + PARENT_SEARCH_VECTORS = Source.PARENT_SEARCH_VECTORS + ['treatment'] class Meta: verbose_name = _(u"Treatment documentation") @@ -628,6 +647,7 @@ class TreatmentFileSource(Source): TABLE_COLS = ['treatment_file__cached_label'] + Source.TABLE_COLS COL_LABELS = {'treatment_file__cached_label': _(u"Treatment file")} SHOW_URL = 'show-treatmentfilesource' + PARENT_SEARCH_VECTORS = Source.PARENT_SEARCH_VECTORS + ['treatment_file'] class Meta: verbose_name = _(u"Treatment request documentation") |
