diff options
Diffstat (limited to 'archaeological_finds')
-rw-r--r-- | archaeological_finds/admin.py | 29 | ||||
-rw-r--r-- | archaeological_finds/forms.py | 111 | ||||
-rw-r--r-- | archaeological_finds/forms_treatments.py | 99 | ||||
-rw-r--r-- | archaeological_finds/ishtar_menu.py | 74 | ||||
-rw-r--r-- | archaeological_finds/models.py | 27 | ||||
-rw-r--r-- | archaeological_finds/models_finds.py | 80 | ||||
-rw-r--r-- | archaeological_finds/models_treatments.py | 80 | ||||
-rw-r--r-- | archaeological_finds/templates/ishtar/sheet_treatment.html | 2 | ||||
-rw-r--r-- | archaeological_finds/templates/ishtar/sheet_treatmentfile.html | 2 | ||||
-rw-r--r-- | archaeological_finds/urls.py | 75 | ||||
-rw-r--r-- | archaeological_finds/views.py | 162 | ||||
-rw-r--r-- | archaeological_finds/wizards.py | 28 |
12 files changed, 58 insertions, 711 deletions
diff --git a/archaeological_finds/admin.py b/archaeological_finds/admin.py index 970cd8845..0e2b31b20 100644 --- a/archaeological_finds/admin.py +++ b/archaeological_finds/admin.py @@ -72,20 +72,8 @@ class FindAdmin(HistorizedObjectAdmin): 'datings', 'cached_label' ] -admin_site.register(models.Find, FindAdmin) - -class FindSourceAdmin(admin.ModelAdmin): - list_display = ('find', 'title', 'source_type',) - list_filter = ('source_type',) - search_fields = ('title', ) - model = models.FindSource - form = make_ajax_form(model, { - 'authors': 'author', - 'find': 'find' - }) - -admin_site.register(models.FindSource, FindSourceAdmin) +admin_site.register(models.Find, FindAdmin) class PropertyAdmin(HistorizedObjectAdmin): @@ -102,6 +90,7 @@ class PropertyAdmin(HistorizedObjectAdmin): def has_add_permission(self, request): return False + admin_site.register(models.Property, PropertyAdmin) @@ -144,20 +133,8 @@ class TreatmentFileAdmin(HistorizedObjectAdmin): 'cached_label', ] -admin_site.register(models.TreatmentFile, TreatmentFileAdmin) - - -class TreatmentSourceAdmin(admin.ModelAdmin): - list_display = ('title', 'treatment', 'source_type',) - list_filter = ('source_type',) - search_fields = ('title', 'treatment__cached_label') - model = models.TreatmentSource - form = make_ajax_form(model, { - 'treatment': 'treatment', - 'authors': 'author' - }) -admin_site.register(models.TreatmentSource, TreatmentSourceAdmin) +admin_site.register(models.TreatmentFile, TreatmentFileAdmin) class HierarchicalTypeAdmin(GeneralTypeAdmin): diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index 6107b744e..1636c7897 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -24,33 +24,14 @@ Finds forms definitions import logging from django import forms -from django.conf import settings from django.core import validators from django.core.exceptions import PermissionDenied from django.forms.formsets import formset_factory from django.utils.translation import ugettext_lazy as _ -from ishtar_common.models import valid_id, valid_ids, get_current_profile, \ - SpatialReferenceSystem -from archaeological_operations.models import Period, ArchaeologicalSite, \ - RelationType as OpeRelationType +import models from archaeological_context_records.models import DatingType, DatingQuality, \ ContextRecord, RelationType as CRRelationType -import models - -from ishtar_common.forms import FormSet, FloatField, \ - get_form_selection, reverse_lazy, TableSelect, get_now, FinalForm, \ - ManageOldType, FieldType, IshtarForm, FormHeader - -from ishtar_common.forms_common import get_town_field, \ - SourceSelect, CustomForm, BaseImageForm, BaseImageFormset, SourceForm -from ishtar_common.utils import convert_coordinates_to_point -from ishtar_common import widgets -from bootstrap_datepicker.widgets import DatePicker -from archaeological_operations.widgets import OAWidget - -from archaeological_warehouse.models import Warehouse - from archaeological_finds.forms_treatments import TreatmentSelect, \ TreatmentFormSelection, BaseTreatmentForm, TreatmentModifyForm, \ AdministrativeActTreatmentForm, TreatmentFormFileChoice, \ @@ -60,11 +41,23 @@ from archaeological_finds.forms_treatments import TreatmentSelect, \ AdministrativeActTreatmentModifForm, \ AdministrativeActTreatmentFileForm, \ AdministrativeActTreatmentFileFormSelection, \ - AdministrativeActTreatmentFileModifForm, SourceTreatmentFormSelection, \ - SourceTreatmentFileFormSelection, TreatmentSourceFormSelection, \ - TreatmentFileSourceFormSelection, DashboardForm as DashboardTreatmentForm, \ - DashboardTreatmentFileForm, TreatmentImagesFormset, \ - TreatmentFileSourceForm, TreatmentSourceForm + AdministrativeActTreatmentFileModifForm, \ + DashboardForm as DashboardTreatmentForm, \ + DashboardTreatmentFileForm +from archaeological_operations.models import Period, ArchaeologicalSite, \ + RelationType as OpeRelationType +from archaeological_operations.widgets import OAWidget +from archaeological_warehouse.models import Warehouse +from bootstrap_datepicker.widgets import DatePicker +from ishtar_common import widgets +from ishtar_common.forms import FormSet, FloatField, \ + reverse_lazy, TableSelect, get_now, FinalForm, \ + ManageOldType, FieldType, IshtarForm, FormHeader +from ishtar_common.forms_common import get_town_field, \ + CustomForm +from ishtar_common.models import valid_id, valid_ids, get_current_profile, \ + SpatialReferenceSystem +from ishtar_common.utils import convert_coordinates_to_point __all__ = [ 'TreatmentSelect', 'TreatmentFormSelection', 'BaseTreatmentForm', @@ -76,22 +69,17 @@ __all__ = [ 'AdministrativeActTreatmentFileForm', 'AdministrativeActTreatmentFileFormSelection', 'AdministrativeActTreatmentFormSelection', - 'AdministrativeActTreatmentFileModifForm', 'SourceTreatmentFormSelection', - 'SourceTreatmentFileFormSelection', 'TreatmentSourceFormSelection', - 'TreatmentFileSourceFormSelection', 'DashboardTreatmentForm', - 'DashboardTreatmentFileForm', 'TreatmentSourceForm', - 'TreatmentFileSourceForm', + 'AdministrativeActTreatmentFileModifForm', + 'DashboardTreatmentForm', 'DashboardTreatmentFileForm', 'RecordFormSelection', 'FindForm', 'DateForm', 'DatingFormSet', - 'PreservationForm', 'ImagesFormset', + 'PreservationForm', 'FindSelect', 'FindFormSelection', 'FindFormSelectionWarehouseModule', 'MultipleFindFormSelection', 'MultipleFindFormSelectionWarehouseModule', 'FindMultipleFormSelection', 'check_form', 'check_exist', 'check_not_exist', 'check_value', 'check_type_field', 'check_type_not_field', 'check_treatment', 'ResultFindForm', 'ResultFindFormSet', - 'FindDeletionForm', 'UpstreamFindFormSelection', 'SourceFindFormSelection', - 'FindSourceSelect', 'FindSourceFormSelection', 'NewFindBasketForm', + 'FindDeletionForm', 'UpstreamFindFormSelection', 'NewFindBasketForm', 'SelectFindBasketForm', 'DeleteFindBasketForm', 'FindBasketAddItemForm', - 'TreatmentImagesFormset', 'FindSourceForm' ] logger = logging.getLogger(__name__) @@ -327,14 +315,6 @@ class FindForm(CustomForm, ManageOldType): return self.cleaned_data -ImagesFormset = formset_factory(BaseImageForm, can_delete=True, - formset=BaseImageFormset) -ImagesFormset.file_upload = True -ImagesFormset.form_label = _(u"Images") -ImagesFormset.form_admin_name = _(u"Find - 025 - Images") -ImagesFormset.form_slug = "find-025-images" - - class PreservationForm(CustomForm, ManageOldType): form_label = _("Preservation") form_admin_name = _(u"Find - 030 - Preservation") @@ -747,49 +727,6 @@ class UpstreamFindFormSelection(FindFormSelection): self.fields['resulting_pk'] = self.fields.pop('pk') -############################################## -# Source management for archaeological finds # -############################################## - -SourceFindFormSelection = get_form_selection( - 'SourceFindFormSelection', _(u"Archaeological find search"), 'find', - models.Find, FindSelect, 'get-find', - _(u"You should select an archaeological find.")) - - -class FindSourceSelect(SourceSelect): - find__base_finds__context_record__operation__year = forms.IntegerField( - label=_(u"Year of the operation")) - find__base_finds__context_record__operation__operation_code = \ - forms.IntegerField(label=_(u"Numeric reference")) - if settings.COUNTRY == 'fr': - find__base_finds__context_record__operation__code_patriarche = \ - forms.IntegerField( - widget=OAWidget, - label="Code PATRIARCHE") - find__datings__period = forms.ChoiceField( - label=_(u"Period of the archaeological find"), choices=[]) - find__material_type = forms.ChoiceField( - label=_("Material type of the archaeological find"), choices=[]) - find__description = forms.CharField( - label=_(u"Description of the archaeological find")) - - def __init__(self, *args, **kwargs): - super(FindSourceSelect, self).__init__(*args, **kwargs) - self.fields['find__datings__period'].choices = Period.get_types() - self.fields['find__datings__period'].help_text = Period.get_help() - self.fields['find__material_type'].choices = \ - models.MaterialType.get_types() - self.fields['find__material_type'].help_text = \ - models.MaterialType.get_help() - -FindSourceFormSelection = get_form_selection( - 'FindSourceFormSelection', _(u"Documentation search"), 'pk', - models.FindSource, FindSourceSelect, 'get-findsource', - _(u"You should select a document."), - get_full_url='get-findsource-full') - - class NewFindBasketForm(forms.ModelForm): class Meta: model = models.FindBasket @@ -867,7 +804,3 @@ class FindBasketAddItemForm(forms.Form): raise PermissionDenied basket.items.add(item) return basket - - -class FindSourceForm(SourceForm): - form_slug = "findsource-general" diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py index a61e56f5e..f2a47e727 100644 --- a/archaeological_finds/forms_treatments.py +++ b/archaeological_finds/forms_treatments.py @@ -17,31 +17,26 @@ # See the file COPYING for details. -from collections import OrderedDict import datetime import logging +from collections import OrderedDict from django import forms from django.core import validators from django.forms.formsets import formset_factory from django.utils.translation import ugettext_lazy as _ -from ishtar_common.models import Person, valid_id, Organization, \ - get_current_profile -from archaeological_operations.models import ActType, AdministrativeAct -from archaeological_warehouse.models import Warehouse, Container import models - from archaeological_operations.forms import AdministrativeActForm, \ AdministrativeActOpeFormSelection, AdministrativeActModifForm - -from ishtar_common.forms import reverse_lazy, TableSelect, FinalForm, \ - ManageOldType, get_form_selection, CustomForm, FieldType, IshtarForm -from ishtar_common.forms_common import SourceSelect, BaseImageForm, \ - BaseImageFormset, SourceForm - -from ishtar_common import widgets +from archaeological_operations.models import ActType, AdministrativeAct +from archaeological_warehouse.models import Warehouse, Container from bootstrap_datepicker.widgets import DatePicker +from ishtar_common import widgets +from ishtar_common.forms import reverse_lazy, TableSelect, FinalForm, \ + ManageOldType, CustomForm, FieldType, IshtarForm +from ishtar_common.models import Person, valid_id, Organization, \ + get_current_profile logger = logging.getLogger(__name__) @@ -258,14 +253,6 @@ class TreatmentModifyForm(BaseTreatmentForm): return cleaned_data -TreatmentImagesFormset = formset_factory(BaseImageForm, can_delete=True, - formset=BaseImageFormset) -TreatmentImagesFormset.file_upload = True -TreatmentImagesFormset.form_label = _(u"Images") -TreatmentImagesFormset.form_admin_name = _(u"Treatment - 025 - Images") -TreatmentImagesFormset.form_slug = "treatment-025-images" - - class TreatmentFormFileChoice(CustomForm, forms.Form): form_label = _(u"Associated request") form_admin_name = _(u"Treatment - 010 - Request choice") @@ -662,73 +649,3 @@ class AdministrativeActTreatmentFileModifForm( AdministrativeActModifForm, AdministrativeActTreatmentFileForm): pk = forms.IntegerField(required=False, widget=forms.HiddenInput) index = forms.IntegerField(label=_("Index"), required=False) - - -SourceTreatmentFormSelection = get_form_selection( - 'SourceTreatmentFormSelection', _(u"Treatment search"), 'treatment', - models.Treatment, TreatmentSelect, 'get-treatment', - _(u"You should select a treatment.")) - -SourceTreatmentFileFormSelection = get_form_selection( - 'SourceTreatmentFileFormSelection', _(u"Treatment request search"), - 'treatment_file', - models.TreatmentFile, TreatmentFileSelect, 'get-treatmentfile', - _(u"You should select a treatment request.")) - - -class TreatmentSourceSelect(SourceSelect): - treatment__name = forms.CharField( - label=_(u"Treatment name"), max_length=200) - treatment__year = forms.IntegerField(label=_(u"Treatment year")) - treatment__index = forms.IntegerField(label=_(u"Treatment index")) - treatment__internal_reference = forms.CharField( - max_length=200, label=_(u"Treatment internal reference")) - treatment__treatment_types = forms.ChoiceField(label=_(u"Treatment type"), - choices=[]) - - def __init__(self, *args, **kwargs): - super(TreatmentSourceSelect, self).__init__(*args, **kwargs) - self.fields['treatment__treatment_types'].choices = \ - models.TreatmentType.get_types() - self.fields['treatment__treatment_types'].help_text = \ - models.TreatmentType.get_help() - - -TreatmentSourceFormSelection = get_form_selection( - 'TreatmentSourceFormSelection', _(u"Documentation search"), 'pk', - models.TreatmentSource, TreatmentSourceSelect, 'get-treatmentsource', - _(u"You should select a document.")) - - -class TreatmentSourceForm(SourceForm): - form_slug = "treatmentsource-general" - - -class TreatmentFileSourceSelect(SourceSelect): - treatment_file__name = forms.CharField( - label=_(u"Treatment request name"), max_length=200) - treatment_file__year = forms.IntegerField( - label=_(u"Treatment request year")) - treatment_file__index = forms.IntegerField( - label=_(u"Treatment request index")) - treatment_file__internal_reference = forms.CharField( - max_length=200, label=_(u"Treatment request internal reference")) - treatment_file__type = forms.ChoiceField( - label=_(u"Treatment request type"), choices=[]) - - def __init__(self, *args, **kwargs): - super(TreatmentFileSourceSelect, self).__init__(*args, **kwargs) - self.fields['treatment_file__type'].choices = \ - models.TreatmentFileType.get_types() - self.fields['treatment_file__type'].help_text = \ - models.TreatmentFileType.get_help() - - -TreatmentFileSourceFormSelection = get_form_selection( - 'TreatmentFileSourceFormSelection', _(u"Documentation search"), 'pk', - models.TreatmentFileSource, TreatmentFileSourceSelect, - 'get-treatmentfilesource', _(u"You should select a document.")) - - -class TreatmentFileSourceForm(SourceForm): - form_slug = "treatmentfilesource-general" diff --git a/archaeological_finds/ishtar_menu.py b/archaeological_finds/ishtar_menu.py index 4877e442c..715644b61 100644 --- a/archaeological_finds/ishtar_menu.py +++ b/archaeological_finds/ishtar_menu.py @@ -73,30 +73,6 @@ MENU_SECTIONS = [ access_controls=['change_find', 'change_own_find']), ]), - SectionItem( - 'find_source', _(u"Documentation"), - childs=[ - MenuItem('find_source_search', - _(u"Search"), - model=models.FindSource, - access_controls=['view_find', - 'view_own_find']), - MenuItem('find_source_creation', - _(u"Creation"), - model=models.FindSource, - access_controls=['change_find', - 'change_own_find']), - MenuItem('find_source_modification', - _(u"Modification"), - model=models.FindSource, - access_controls=['change_find', - 'change_own_find']), - MenuItem('find_source_deletion', - _(u"Deletion"), - model=models.FindSource, - access_controls=['change_find', - 'change_own_find']), - ]), # MenuItem( # 'treatment_creation', _(u"Add a treatment"), # model=models.Treatment, @@ -153,31 +129,6 @@ MENU_SECTIONS = [ access_controls=['change_administrativeact']), ] ), - SectionItem( - 'treatmentfile_source', _(u"Source"), - childs=[ - MenuItem('treatmentfile_source_search', - _(u"Search"), - model=models.TreatmentFileSource, - access_controls=['view_treatmentfile', - 'view_own_treatmentfile']), - MenuItem('treatmentfile_source_creation', - _(u"Creation"), - model=models.TreatmentFileSource, - access_controls=['change_treatmentfile', - 'change_own_treatmentfile']), - MenuItem('treatmentfile_source_modification', - _(u"Modification"), - model=models.TreatmentFileSource, - access_controls=['change_treatmentfile', - 'change_own_treatmentfile']), - MenuItem('treatmentfile_source_deletion', - _(u"Deletion"), - model=models.TreatmentFileSource, - access_controls=['change_treatmentfile', - 'change_own_treatmentfile']), - ] - ), ] )), (70, @@ -234,31 +185,6 @@ MENU_SECTIONS = [ model=AdministrativeAct, access_controls=['change_administrativeact']), ]), - SectionItem( - 'treatment_source', _(u"Source"), - childs=[ - MenuItem('treatment_source_search', - _(u"Search"), - model=models.TreatmentSource, - access_controls=['view_treatment', - 'view_own_treatment']), - MenuItem('treatment_source_creation', - _(u"Creation"), - model=models.TreatmentSource, - access_controls=['change_treatment', - 'change_own_treatment']), - MenuItem('treatment_source_modification', - _(u"Modification"), - model=models.TreatmentSource, - access_controls=['change_treatment', - 'change_own_treatment']), - MenuItem('treatment_source_deletion', - _(u"Deletion"), - model=models.TreatmentSource, - access_controls=['change_treatment', - 'change_own_treatment']), - ] - ), ] )), ] diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index 7e53b514d..1052edb19 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -1,23 +1,20 @@ -from archaeological_finds.models_finds import MaterialType, ConservatoryState,\ +from archaeological_finds.models_finds import MaterialType, ConservatoryState, \ IntegrityType, RemarkabilityType, ObjectType, BaseFind, \ - FindBasket, Find, FindSource, Property, CHECK_CHOICES, BatchType, \ + FindBasket, Find, Property, CHECK_CHOICES, BatchType, \ BFBulkView, FBulkView, FirstBaseFindView, AlterationType, \ AlterationCauseType, TreatmentEmergencyType, TreatmentType, \ - CommunicabilityType, MaterialTypeQualityType, ObjectTypeQualityType, \ - FindImage + CommunicabilityType, MaterialTypeQualityType, ObjectTypeQualityType from archaeological_finds.models_treatments import Treatment, \ AbsFindTreatments, FindUpstreamTreatments, FindDownstreamTreatments, \ - FindTreatments, TreatmentSource, TreatmentFile, TreatmentFileType, \ - TreatmentFileSource, TreatmentState, TreatmentImage + FindTreatments, TreatmentFile, TreatmentFileType, \ + TreatmentState -__all__ = ['MaterialType', 'ConservatoryState', - 'IntegrityType', 'RemarkabilityType', 'ObjectType', - 'BaseFind', 'FindBasket', 'Find', 'FindSource', 'Property', - 'BFBulkView', 'FBulkView', 'FirstBaseFindView', 'AlterationType', - 'AlterationCauseType', 'TreatmentEmergencyType', +__all__ = ['MaterialType', 'ConservatoryState', 'IntegrityType', + 'RemarkabilityType', 'ObjectType', 'BaseFind', 'FindBasket', 'Find', + 'Property', 'BFBulkView', 'FBulkView', 'FirstBaseFindView', + 'AlterationType', 'AlterationCauseType', 'TreatmentEmergencyType', 'CHECK_CHOICES', 'BatchType', 'TreatmentType', 'TreatmentState', 'Treatment', 'AbsFindTreatments', 'FindUpstreamTreatments', - 'FindDownstreamTreatments', 'FindTreatments', 'TreatmentSource', - 'TreatmentFile', 'TreatmentFileType', 'TreatmentFileSource', - 'CommunicabilityType', 'MaterialTypeQualityType', - 'ObjectTypeQualityType', 'TreatmentImage', 'FindImage'] + 'FindDownstreamTreatments', 'FindTreatments', 'TreatmentFile', + 'TreatmentFileType', 'CommunicabilityType', + 'MaterialTypeQualityType', 'ObjectTypeQualityType'] diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 0e36cf29a..72e4d8607 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -32,10 +32,10 @@ from django.utils.translation import ugettext_lazy as _ from ishtar_common.data_importer import post_importer_action, ImporterError from ishtar_common.utils import cached_label_changed, post_save_point -from ishtar_common.models import BaseSource, Document, GeneralType, \ +from ishtar_common.models import Document, GeneralType, \ HierarchicalType, BaseHistorizedItem, ShortMenuItem, LightHistorizedItem, \ HistoricalRecords, OwnPerms, Person, Basket, post_save_cache, \ - ValueGetter, get_current_profile, IshtarImage, ThroughImage + ValueGetter, get_current_profile from archaeological_operations.models import AdministrativeAct, Operation from archaeological_context_records.models import ContextRecord, Dating @@ -831,8 +831,6 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms, documents = models.ManyToManyField( Document, related_name='finds', verbose_name=_(u"Documents"), blank=True) - images = models.ManyToManyField(IshtarImage, verbose_name=_(u"Images"), - blank=True, through='FindImage') cached_label = models.TextField(_(u"Cached name"), null=True, blank=True, db_index=True) history = HistoricalRecords() @@ -1441,80 +1439,6 @@ def base_find_find_changed(sender, **kwargs): m2m_changed.connect(base_find_find_changed, sender=Find.base_finds.through) -class FindImage(ThroughImage): - item = models.ForeignKey(Find, on_delete=models.CASCADE, - related_name='associated_images') - - -class FindSource(BaseSource): - SHOW_URL = 'show-findsource' - MODIFY_URL = 'find_source_modify' - TABLE_COLS = [ - 'find__base_finds__context_record__operation', - 'find__base_finds__context_record', 'find'] + \ - BaseSource.TABLE_COLS - - # search parameters - BOOL_FIELDS = ['duplicate'] - RELATIVE_SESSION_NAMES = [ - ('find', 'find__pk'), - ('contextrecord', 'find__base_finds__context_record__pk'), - ('operation', 'find__base_finds__context_record__operation__pk'), - ('file', - 'find__base_finds__context_record__operation__associated_file__pk') - ] - EXTRA_REQUEST_KEYS = { - 'title': 'title__icontains', - 'description': 'description__icontains', - 'comment': 'comment__icontains', - 'additional_information': 'additional_information__icontains', - 'person': 'authors__person__pk', - 'find__base_finds__context_record__operation__year': - 'find__base_finds__context_record__operation__year', - 'find__base_finds__context_record__operation__operation_code': - 'find__base_finds__context_record__operation__operation_code', - 'find__base_finds__context_record__operation__code_patriarche': - 'find__base_finds__context_record__operation__code_patriarche', - 'find__datings__period': 'find__datings__period__pk', - 'find__description': 'find__description__icontains', - } - PARENT_SEARCH_VECTORS = BaseSource.PARENT_SEARCH_VECTORS + ['find'] - - class Meta: - verbose_name = _(u"Find documentation") - verbose_name_plural = _(u"Find documentations") - permissions = ( - ("view_findsource", - u"Can view all Find sources"), - ("view_own_findsource", - u"Can view own Find source"), - ("add_own_findsource", - u"Can add own Find source"), - ("change_own_findsource", - u"Can change own Find source"), - ("delete_own_findsource", - u"Can delete own Find source"), - ) - find = models.ForeignKey(Find, verbose_name=_(u"Find"), - related_name="source") - - @property - def owner(self): - return self.find - - @classmethod - def get_query_owns(cls, ishtaruser): - q = cls._construct_query_own( - 'find__base_finds__context_record__operation__', - Operation._get_query_owns_dicts(ishtaruser) - ) | cls._construct_query_own('', [ - {'find__history_creator': ishtaruser.user_ptr}, - {'find__base_finds__context_record__operation__end_date__isnull': - True} - ]) - return q - - class Property(LightHistorizedItem): find = models.ForeignKey(Find, verbose_name=_(u"Find")) administrative_act = models.ForeignKey( diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index 19f00de1f..4ee5fe08b 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -29,10 +29,10 @@ from django.utils.translation import ugettext_lazy as _ from archaeological_finds.models_finds import Find, FindBasket, TreatmentType from archaeological_operations.models import ClosedItem, Operation from archaeological_warehouse.models import Warehouse, Container -from ishtar_common.models import BaseSource, Document, GeneralType, \ +from ishtar_common.models import Document, GeneralType, \ ImageModel, BaseHistorizedItem, OwnPerms, HistoricalRecords, Person, \ Organization, ValueGetter, post_save_cache, ShortMenuItem, \ - DashboardFormItem, IshtarImage, ThroughImage + DashboardFormItem from ishtar_common.utils import cached_label_changed, get_current_year @@ -127,8 +127,6 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem, documents = models.ManyToManyField( Document, related_name='treatments', verbose_name=_(u"Documents"), blank=True) - images = models.ManyToManyField(IshtarImage, verbose_name=_(u"Images"), - blank=True, through='TreatmentImage') cached_label = models.TextField(_(u"Cached name"), null=True, blank=True, db_index=True) history = HistoricalRecords() @@ -309,11 +307,6 @@ def pre_delete_treatment(sender, **kwargs): pre_delete.connect(pre_delete_treatment, sender=Treatment) -class TreatmentImage(ThroughImage): - item = models.ForeignKey(Treatment, on_delete=models.CASCADE, - related_name='associated_images') - - class AbsFindTreatments(models.Model): find = models.ForeignKey(Find, verbose_name=_(u"Find"), related_name='%(class)s_related') @@ -614,72 +607,3 @@ class TreatmentFile(DashboardFormItem, ClosedItem, BaseHistorizedItem, post_save.connect(cached_label_changed, sender=TreatmentFile) - - -class TreatmentSource(BaseSource): - treatment = models.ForeignKey( - Treatment, verbose_name=_(u"Treatment"), related_name="source") - BOOL_FIELDS = ['duplicate'] - TABLE_COLS = ['treatment__cached_label'] + BaseSource.TABLE_COLS - COL_LABELS = {'treatment__cached_label': _(u"Treatment")} - SHOW_URL = 'show-treatmentsource' - PARENT_SEARCH_VECTORS = BaseSource.PARENT_SEARCH_VECTORS + ['treatment'] - - class Meta: - verbose_name = _(u"Treatment documentation") - verbose_name_plural = _(u"Treament documentations") - permissions = ( - ("view_treatmentsource", - u"Can view all Treatment sources"), - ("view_own_treatmentsource", - u"Can view own Treatment source"), - ("add_own_treatmentsource", - u"Can add own Treatment source"), - ("change_own_treatmentsource", - u"Can change own Treatment source"), - ("delete_own_treatmentsource", - u"Can delete own Treatment source"), - ) - - @property - def owner(self): - return self.treatment - - def _get_base_image_path(self): - return u"{}/source".format(self.treatment._get_base_image_path()) - - -class TreatmentFileSource(BaseSource): - treatment_file = models.ForeignKey( - TreatmentFile, verbose_name=_(u"Treatment request"), - related_name="source") - BOOL_FIELDS = ['duplicate'] - TABLE_COLS = ['treatment_file__cached_label'] + BaseSource.TABLE_COLS - COL_LABELS = {'treatment_file__cached_label': _(u"Treatment file")} - SHOW_URL = 'show-treatmentfilesource' - PARENT_SEARCH_VECTORS = BaseSource.PARENT_SEARCH_VECTORS + [ - 'treatment_file'] - - class Meta: - verbose_name = _(u"Treatment request documentation") - verbose_name_plural = _(u"Treatment request documentations") - permissions = ( - ("view_filetreatmentsource", - u"Can view Treatment request source"), - ("view_own_filetreatmentsource", - u"Can view own Treatment request source"), - ("add_own_filetreatmentsource", - u"Can add own Treatment request source"), - ("change_own_filetreatmentsource", - u"Can change own Treatment request source"), - ("delete_own_filetreatmentsource", - u"Can delete own Treatment request source"), - ) - - @property - def owner(self): - return self.treatment_file - - def _get_base_image_path(self): - return u"treatmentfile/{}/{}/source".format( - self.treatment_file.year, self.treatment_file.index) diff --git a/archaeological_finds/templates/ishtar/sheet_treatment.html b/archaeological_finds/templates/ishtar/sheet_treatment.html index 21f0e5370..1a3bb931f 100644 --- a/archaeological_finds/templates/ishtar/sheet_treatment.html +++ b/archaeological_finds/templates/ishtar/sheet_treatment.html @@ -66,10 +66,12 @@ {% trans "Related operations" as related_operations %} {% dynamic_table_document related_operations 'operations' 'related_treatment' item.pk 'TABLE_COLS' output %} +{% comment %} {% if item.source.count %} {% trans "Associated documents" as associated_docs %} {% dynamic_table_document associated_docs 'treatments_docs' 'treatment' item.pk '' output %} {% endif %} +{% endcomment %} {% if item.administrative_act.count %} {% trans "Administrative acts" as admact_lbl %} diff --git a/archaeological_finds/templates/ishtar/sheet_treatmentfile.html b/archaeological_finds/templates/ishtar/sheet_treatmentfile.html index f474aab7c..08398a6c2 100644 --- a/archaeological_finds/templates/ishtar/sheet_treatmentfile.html +++ b/archaeological_finds/templates/ishtar/sheet_treatmentfile.html @@ -62,10 +62,12 @@ {% dynamic_table_document treatments 'treatments' 'file' item.pk '' output '' 'treatment' %} {% endif %} +{% comment %} {% if item.source.count %} {% trans "Associated documents" as associated_docs %} {% dynamic_table_document associated_docs 'treatmentfiles_docs' 'treatment_file' item.pk '' output %} {% endif %} +{% endcomment %} {% if item.administrative_act.count %} {% trans "Administrative acts" as admact_lbl %} diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py index c9aaae2a2..bd466a1af 100644 --- a/archaeological_finds/urls.py +++ b/archaeological_finds/urls.py @@ -43,24 +43,6 @@ urlpatterns = [ views.find_deletion_wizard), name='find_deletion'), url(r'find_modify/(?P<pk>.+)/$', views.find_modify, name='find_modify'), - url(r'find_source_search/(?P<step>.+)?$', - check_rights(['view_find', 'view_own_find'])( - views.find_source_search_wizard), - name='find_source_search'), - url(r'find_source_creation/(?P<step>.+)?$', - check_rights(['change_find', 'change_own_find'])( - views.find_source_creation_wizard), - name='find_source_creation'), - url(r'find_source_modification/(?P<step>.+)?$', - check_rights(['change_find', 'change_own_find'])( - views.find_source_modification_wizard), - name='find_source_modification'), - url(r'find_source_modify/(?P<pk>.+)/$', - views.find_source_modify, name='find_source_modify'), - url(r'find_source_deletion/(?P<step>.+)?$', - check_rights(['change_find', 'change_own_find'])( - views.find_source_deletion_wizard), - name='find_source_deletion'), url(r'^find_basket_creation/$', check_rights(['change_find', 'change_own_find'])( views.NewFindBasketView.as_view()), name='new_findbasket'), @@ -105,31 +87,6 @@ urlpatterns = [ check_rights(['change_find', 'change_own_find'])( views.treatment_deletion_wizard), name='treatment_deletion'), - url(r'^show-treatmentsource(?:/(?P<pk>.+))?/(?P<type>.+)?$', - views.show_treatmentsource, - name=models.TreatmentSource.SHOW_URL), - url(r'^get-treatmentsource/(?P<type>.+)?$', - views.get_treatmentsource, - name='get-treatmentsource'), - url(r'^treatment_source_search/(?P<step>.+)?$', - check_rights(['view_treatment', 'view_own_treatment'])( - views.treatment_source_search_wizard), - name='treatment_source_search'), - url(r'^treatment_source_creation/(?P<step>.+)?$', - check_rights(['change_treatment', 'change_own_treatment'])( - views.treatment_source_creation_wizard), - name='treatment_source_creation'), - url(r'^treatment_source_modification/(?P<step>.+)?$', - check_rights(['change_treatment', 'change_own_treatment'])( - views.treatment_source_modification_wizard), - name='treatment_source_modification'), - url(r'^treatment_source_modify/(?P<pk>.+)/$', - views.treatment_source_modify, name='treatment_source_modify'), - url(r'^treatment_source_deletion/(?P<step>.+)?$', - check_rights(['change_treatment', 'change_own_treatment'])( - views.treatment_source_deletion_wizard), - name='treatment_source_deletion'), - url(r'^treatment_admacttreatment_search/(?P<step>.+)?$', check_rights(['change_administrativeact'])( views.treatment_administrativeact_search_wizard), @@ -173,30 +130,6 @@ urlpatterns = [ views.treatmentfile_admacttreatmentfile_deletion_wizard), name='treatmentfle_admacttreatmentfle_deletion'), - url(r'^show-treatmentfilesource(?:/(?P<pk>.+))?/(?P<type>.+)?$', - views.show_treatmentfilesource, - name=models.TreatmentFileSource.SHOW_URL), - url(r'^get-treatmentfilesource/(?P<type>.+)?$', - views.get_treatmentfilesource, - name='get-treatmentfilesource'), - url(r'^treatmentfile_source_search/(?P<step>.+)?$', - check_rights(['view_treatmentfile', 'view_own_treatmentfile'])( - views.treatmentfile_source_search_wizard), - name='treatmentfile_source_search'), - url(r'^treatmentfile_source_creation/(?P<step>.+)?$', - check_rights(['change_treatmentfile', 'change_own_treatmentfile'])( - views.treatmentfile_source_creation_wizard), - name='treatmentfile_source_creation'), - url(r'^treatmentfile_source_modification/(?P<step>.+)?$', - check_rights(['change_treatmentfile', 'change_own_treatmentfile'])( - views.treatmentfile_source_modification_wizard), - name='treatmentfile_source_modification'), - url(r'^treatmentfile_source_modify/(?P<pk>.+)/$', - views.treatmentfile_source_modify, name='treatmentfile_source_modify'), - url(r'^treatmentfile_source_deletion/(?P<step>.+)?$', - check_rights(['change_treatmentfile', 'change_own_treatmentfile'])( - views.treatmentfile_source_deletion_wizard), - name='treatmentfile_source_deletion'), url(r'^treatmentfle_search/(?P<step>.+)?$', check_rights(['change_find', 'change_own_find'])( views.treatmentfile_search_wizard), @@ -253,14 +186,6 @@ urlpatterns = [ url(r'get-find-shortcut/(?P<type>.+)?$', views.get_find, name='get-find-shortcut', kwargs={'full': 'shortcut'}), - url(r'get-findsource/(?P<type>.+)?$', - views.get_findsource, name='get-findsource'), - url(r'get-findsource-full/(?P<type>.+)?$', - views.get_findsource, name='get-findsource-full', - kwargs={'full': True}), - url(r'^show-findsource(?:/(?P<pk>.+))?/(?P<type>.+)?$', - views.show_findsource, - name=models.FindSource.SHOW_URL), url(r'^show-find/basket-(?P<pk>.+)/(?P<type>.+)?$', views.show_findbasket, name='show-findbasket'), url(r'^display-find/basket-(?P<pk>.+)/$', views.display_findbasket, diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py index 04264080e..2dc599807 100644 --- a/archaeological_finds/views.py +++ b/archaeological_finds/views.py @@ -19,7 +19,6 @@ import json -from django.core.exceptions import PermissionDenied from django.core.urlresolvers import reverse from django.db.models import Q from django.http import HttpResponseRedirect, HttpResponse @@ -28,25 +27,17 @@ from django.utils.translation import ugettext_lazy as _ from django.views.generic import TemplateView from django.views.generic.edit import CreateView, FormView -from ishtar_common.models import IshtarUser, get_current_profile -from archaeological_operations.models import AdministrativeAct - -from ishtar_common.forms import FinalForm -from ishtar_common.forms_common import SourceForm, AuthorFormset, \ - SourceDeletionForm -from archaeological_operations.forms import FinalAdministrativeActDeleteForm from archaeological_context_records.forms \ import RecordFormSelection as RecordFormSelectionTable - +from archaeological_operations.forms import FinalAdministrativeActDeleteForm +from archaeological_operations.wizards import AdministrativeActDeletionWizard +from forms import * +from ishtar_common.forms import FinalForm +from ishtar_common.models import IshtarUser, get_current_profile from ishtar_common.views import get_item, show_item, display_item, \ revert_item, get_autocomplete_generic, IshtarMixin, LoginRequiredMixin - from ishtar_common.wizards import SearchWizard -from archaeological_operations.wizards import AdministrativeActDeletionWizard - from wizards import * -from forms import * -import models get_find = get_item(models.Find, 'get_find', 'find') @@ -107,9 +98,6 @@ def autocomplete_treatmentfile(request): return HttpResponse(data, content_type='text/plain') -show_findsource = show_item(models.FindSource, 'findsource') - -get_findsource = get_item(models.FindSource, 'get_findsource', 'findsource') show_find = show_item(models.Find, 'find') display_find = display_item(models.Find) revert_find = revert_item(models.Find) @@ -134,7 +122,6 @@ def check_not_warehouse_module(self): find_creation_steps = [ ('selecrecord-find_creation', RecordFormSelectionTable), ('find-find_creation', FindForm), - ('images-find_creation', ImagesFormset), ('preservation-find_creation', PreservationForm), ('dating-find_creation', DatingFormSet), ('final-find_creation', FinalForm) @@ -174,7 +161,6 @@ find_modification_steps = [ ('selecw-find_modification', FindFormSelectionWarehouseModule), ('selecrecord-find_modification', RecordFormSelection), ('find-find_modification', FindForm), - ('images-find_modification', ImagesFormset), ('preservation-find_modification', PreservationForm), ('dating-find_modification', DatingFormSet), ('final-find_modification', FinalForm) @@ -215,42 +201,6 @@ find_deletion_wizard = FindDeletionWizard.as_view( label=_(u"Find deletion"), url_name='find_deletion',) -find_source_search_wizard = SearchWizard.as_view([ - ('selec-find_source_search', FindSourceFormSelection)], - label=_(u"Find: source search"), - url_name='find_source_search',) - -find_source_creation_wizard = FindSourceWizard.as_view([ - ('selec-find_source_creation', SourceFindFormSelection), - ('source-find_source_creation', FindSourceForm), - ('authors-find_source_creation', AuthorFormset), - ('final-find_source_creation', FinalForm)], - label=_(u"Find: new source"), - url_name='find_source_creation',) - -find_source_modification_wizard = FindSourceWizard.as_view([ - ('selec-find_source_modification', FindSourceFormSelection), - ('source-find_source_modification', FindSourceForm), - ('authors-find_source_modification', AuthorFormset), - ('final-find_source_modification', FinalForm)], - label=_(u"Find: source modification"), - url_name='find_source_modification',) - - -def find_source_modify(request, pk): - find_source_modification_wizard(request) - FindSourceWizard.session_set_value( - request, 'selec-find_source_modification', 'pk', pk, reset=True) - return redirect(reverse( - 'find_source_modification', - kwargs={'step': 'source-find_source_modification'})) - -find_source_deletion_wizard = FindSourceDeletionWizard.as_view([ - ('selec-find_source_deletion', FindSourceFormSelection), - ('final-find_source_deletion', SourceDeletionForm)], - label=_(u"Find: source deletion"), - url_name='find_source_deletion',) - autocomplete_objecttype = get_autocomplete_generic(models.ObjectType) autocomplete_materialtype = get_autocomplete_generic(models.MaterialType) autocomplete_treatmenttype = get_autocomplete_generic(models.TreatmentType) @@ -414,7 +364,6 @@ treatment_wizard_steps = [ ('basetreatment-treatment_creation', BaseTreatmentForm), ('selecfind-treatment_creation', UpstreamFindFormSelection), ('selecbasket-treatment_creation', SelectFindBasketForm), - ('images-treatment_creation', TreatmentImagesFormset), # ('resultfind-treatment_creation', ResultFindForm), # ('resultfinds-treatment_creation', ResultFindFormSet), ('final-treatment_creation', FinalForm) @@ -451,7 +400,6 @@ treatment_modification_wizard = TreatmentModificationWizard.as_view( [('selec-treatment_modification', TreatmentFormSelection), ('file-treatment_modification', TreatmentFormFileChoice), ('basetreatment-treatment_modification', TreatmentModifyForm), - ('images-treatment_creation', TreatmentImagesFormset), ('final-treatment_modification', FinalForm)], label=_(u"Treatment modification"), url_name='treatment_modification', @@ -615,106 +563,12 @@ def treatmentfile_administrativeacttreatmentfile_modify(request, pk): 'admact-treatmentfle_admacttreatmentfle_modification' })) -# sources - -show_treatmentsource = show_item(models.TreatmentSource, 'treatmentsource') -get_treatmentsource = get_item(models.TreatmentSource, 'get_treatmentsource', - 'treatmentsource') - -treatment_source_search_wizard = SearchWizard.as_view([ - ('selec-treatment_source_search', TreatmentSourceFormSelection)], - label=_(u"Treatment: source search"), - url_name='treatment_source_search',) - -treatment_source_creation_wizard = TreatmentSourceWizard.as_view([ - ('selec-treatment_source_creation', SourceTreatmentFormSelection), - ('source-treatment_source_creation', SourceForm), - ('authors-treatment_source_creation', AuthorFormset), - ('final-treatment_source_creation', FinalForm)], - label=_(u"Treatment: new source"), - url_name='treatment_source_creation',) - -treatment_source_modification_wizard = TreatmentSourceWizard.as_view([ - ('selec-treatment_source_modification', TreatmentSourceFormSelection), - ('source-treatment_source_modification', SourceForm), - ('authors-treatment_source_modification', AuthorFormset), - ('final-treatment_source_modification', FinalForm)], - label=_(u"Treatment: source modification"), - url_name='treatment_source_modification',) - - -def treatment_source_modify(request, pk): - treatment_source_modification_wizard(request) - TreatmentSourceWizard.session_set_value( - request, 'selec-treatment_source_modification', 'pk', pk, reset=True) - return redirect(reverse( - 'treatment_source_modification', - kwargs={'step': 'source-treatment_source_modification'})) - -treatment_source_deletion_wizard = TreatmentSourceDeletionWizard.as_view([ - ('selec-treatment_source_deletion', TreatmentSourceFormSelection), - ('final-treatment_source_deletion', SourceDeletionForm)], - label=_(u"Treatment: source deletion"), - url_name='treatment_source_deletion',) - -# treatment request sources - -show_treatmentfilesource = show_item(models.TreatmentFileSource, - 'treatmentfilesource') -get_treatmentfilesource = get_item( - models.TreatmentFileSource, 'get_treatmentfilesource', - 'treatmentfilesource') - -treatmentfile_source_search_wizard = SearchWizard.as_view([ - ('selec-treatmentfile_source_search', TreatmentFileSourceFormSelection)], - label=_(u"Treatment request: source search"), - url_name='treatmentfile_source_search',) - -treatmentfile_source_creation_wizard = TreatmentFileSourceWizard.as_view([ - ('selec-treatmentfile_source_creation', SourceTreatmentFileFormSelection), - ('source-treatmentfile_source_creation', SourceForm), - ('authors-treatmentfile_source_creation', AuthorFormset), - ('final-treatmentfile_source_creation', FinalForm)], - label=_(u"Treatment request: new source"), - url_name='treatmentfile_source_creation',) - -treatmentfile_source_modification_wizard = TreatmentFileSourceWizard.as_view([ - ('selec-treatmentfile_source_modification', - TreatmentFileSourceFormSelection), - ('source-treatmentfile_source_modification', SourceForm), - ('authors-treatmentfile_source_modification', AuthorFormset), - ('final-treatmentfile_source_modification', FinalForm)], - label=_(u"Treatment request: source modification"), - url_name='treatmentfile_source_modification',) - - -def treatmentfile_source_modify(request, pk): - treatmentfile_source_modification_wizard(request) - TreatmentFileSourceWizard.session_set_value( - request, 'selec-treatmentfile_source_modification', 'pk', pk, - reset=True) - return redirect(reverse( - 'treatmentfile_source_modification', - kwargs={'step': 'source-treatmentfile_source_modification'})) - - -treatmentfile_source_deletion_wizard = \ - TreatmentFileSourceDeletionWizard.as_view([ - ('selec-treatmentfile_source_deletion', - TreatmentFileSourceFormSelection), - ('final-treatmentfile_source_deletion', SourceDeletionForm)], - label=_(u"Treatment request: source deletion"), - url_name='treatmentfile_source_deletion',) - def reset_wizards(request): for wizard_class, url_name in ( (FindWizard, 'find_creation'), (FindModificationWizard, 'find_modification'), (FindDeletionWizard, 'find_deletion'), - (FindSourceWizard, 'find_source_creation'), - (FindSourceWizard, 'find_source_modification'), - (FindSourceDeletionWizard, 'find_source_deletion'), (TreatmentWizard, 'treatement_creation'), (TreatmentModificationWizard, 'treatment_modification'), (TreatmentDeletionWizard, 'treatment_deletion'), @@ -731,11 +585,5 @@ def reset_wizards(request): 'treatmentfle_admacttreatmentfle_modification'), (AdministrativeActDeletionWizard, 'treatmentfle_admacttreatmentfle_deletion'), - (TreatmentSourceWizard, 'treatment_source_creation'), - (TreatmentSourceWizard, 'treatment_source_modification'), - (TreatmentSourceDeletionWizard, 'treatment_source_deletion'), - (TreatmentFileSourceWizard, 'treatmentfile_source_creation'), - (TreatmentFileSourceWizard, 'treatmentfile_source_modification'), - (TreatmentFileSourceDeletionWizard, 'treatmentfile_source_deletion') ): wizard_class.session_reset(request, url_name) diff --git a/archaeological_finds/wizards.py b/archaeological_finds/wizards.py index b244118cd..b15948dce 100644 --- a/archaeological_finds/wizards.py +++ b/archaeological_finds/wizards.py @@ -218,31 +218,3 @@ class TreatmentFileEditAdministrativeActWizard( def get_associated_item(self, dct): return self.get_current_object().treatment_file - - -class FindSourceWizard(SourceWizard): - wizard_done_window = reverse_lazy('show-findsource') - model = models.FindSource - - -class FindSourceDeletionWizard(DeletionWizard): - model = models.FindSource - fields = ['item', 'title', 'source_type', 'authors', ] - - -class TreatmentSourceWizard(SourceWizard): - model = models.TreatmentSource - - -class TreatmentSourceDeletionWizard(DeletionWizard): - model = models.TreatmentSource - fields = ['treatment', 'title', 'source_type', 'authors'] - - -class TreatmentFileSourceWizard(SourceWizard): - model = models.TreatmentFileSource - - -class TreatmentFileSourceDeletionWizard(DeletionWizard): - model = models.TreatmentFileSource - fields = ['treatment_file', 'title', 'source_type', 'authors'] |