diff options
-rw-r--r-- | archaeological_context_records/forms.py | 2 | ||||
-rw-r--r-- | archaeological_files/forms.py | 6 | ||||
-rw-r--r-- | archaeological_finds/forms.py | 2 | ||||
-rw-r--r-- | archaeological_finds/forms_treatments.py | 14 | ||||
-rw-r--r-- | archaeological_finds/models_treatments.py | 84 | ||||
-rw-r--r-- | archaeological_operations/forms.py | 6 | ||||
-rw-r--r-- | archaeological_operations/models.py | 40 | ||||
-rw-r--r-- | archaeological_warehouse/forms.py | 4 | ||||
-rw-r--r-- | archaeological_warehouse/models.py | 2 | ||||
-rw-r--r-- | ishtar_common/forms_common.py | 8 |
10 files changed, 142 insertions, 26 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py index b659c64f1..0504577c5 100644 --- a/archaeological_context_records/forms.py +++ b/archaeological_context_records/forms.py @@ -57,7 +57,7 @@ class OperationFormSelection(CustomForm, forms.Form): validators=[valid_id(Operation)]) -class RecordSelect(CustomForm, TableSelect): # OK +class RecordSelect(CustomForm, TableSelect): _model = models.ContextRecord form_admin_name = _(u"Context record - 001 - Search") diff --git a/archaeological_files/forms.py b/archaeological_files/forms.py index f6c6bf48b..3d82dc83f 100644 --- a/archaeological_files/forms.py +++ b/archaeological_files/forms.py @@ -46,7 +46,7 @@ from ishtar_common import widgets from bootstrap_datepicker.widgets import DatePicker -class FileSelect(TableSelect): # OK +class FileSelect(TableSelect): _model = models.File search_vector = forms.CharField( @@ -401,7 +401,7 @@ class FinalFileDeleteForm(FinalForm): confirm_end_msg = _(u"Would you like to delete this archaeological file ?") -class AdministrativeActFileModifySelect(TableSelect): # OK +class AdministrativeActFileModifySelect(TableSelect): _model = AdministrativeAct search_vector = forms.CharField( @@ -434,7 +434,7 @@ class AdministrativeActFileModifySelect(TableSelect): # OK ('', '--')] + list(settings.ISHTAR_DPTS) -class AdministrativeActFileSelect(TableSelect): # OK +class AdministrativeActFileSelect(TableSelect): _model = AdministrativeAct search_vector = forms.CharField( diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index c575bc876..358b12477 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -406,7 +406,7 @@ DatingFormSet.form_admin_name = _(u"Find - 040 - Dating") DatingFormSet.form_slug = "find-040-dating" -class FindSelect(CustomForm, TableSelect): # OK +class FindSelect(CustomForm, TableSelect): _model = models.Find form_admin_name = _(u"Find - 001 - Search") diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py index ae6152951..11cfd3173 100644 --- a/archaeological_finds/forms_treatments.py +++ b/archaeological_finds/forms_treatments.py @@ -44,16 +44,19 @@ logger = logging.getLogger(__name__) class TreatmentSelect(TableSelect): + _model = models.Treatment + search_vector = forms.CharField( label=_(u"Full text search"), widget=widgets.SearchWidget( 'archaeological-finds', 'treatment' )) + label = forms.CharField(label=_(u"Label")) other_reference = forms.CharField(label=_(u"Other ref.")) year = forms.IntegerField(label=_(u"Year")) index = forms.IntegerField(label=_(u"Index")) treatment_types = forms.ChoiceField(label=_(u"Treatment type"), choices=[]) - image = forms.NullBooleanField(label=_(u"Has an image?")) + documents__image__isnull = forms.NullBooleanField(label=_(u"Has an image?")) def __init__(self, *args, **kwargs): super(TreatmentSelect, self).__init__(*args, **kwargs) @@ -324,6 +327,8 @@ class DashboardForm(IshtarForm): class AdministrativeActTreatmentSelect(TableSelect): + _model = AdministrativeAct + search_vector = forms.CharField( label=_(u"Full text search"), widget=widgets.SearchWidget( 'archaeological-operations', 'administrativeact' @@ -343,7 +348,7 @@ class AdministrativeActTreatmentSelect(TableSelect): 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( + treatment__other_reference = forms.CharField( max_length=200, label=_(u"Treatment internal reference")) treatment__treatment_types = forms.ChoiceField(label=_(u"Treatment type"), choices=[]) @@ -406,6 +411,7 @@ class TreatmentFileSelect(TableSelect): year = forms.IntegerField(label=_(u"Year")) index = forms.IntegerField(label=_(u"Index")) type = forms.ChoiceField(label=_(u"Type"), choices=[]) + in_charge = forms.IntegerField( label=_(u"In charge"), widget=widgets.JQueryAutoComplete( @@ -586,6 +592,8 @@ class DashboardTreatmentFileForm(IshtarForm): class AdministrativeActTreatmentFileSelect(TableSelect): + _model = AdministrativeAct + search_vector = forms.CharField( label=_(u"Full text search"), widget=widgets.SearchWidget( 'archaeological-operations', 'administrativeact' @@ -601,6 +609,7 @@ class AdministrativeActTreatmentFileSelect(TableSelect): label=_(u"Signature date after"), widget=DatePicker) signature_date_before = forms.DateField( label=_(u"Signature date before"), widget=DatePicker) + treatment_file__name = forms.CharField( label=_(u"Treatment request name"), max_length=200) treatment_file__year = forms.IntegerField( @@ -611,6 +620,7 @@ class AdministrativeActTreatmentFileSelect(TableSelect): max_length=200, label=_(u"Treatment request internal reference")) treatment_file__type = forms.ChoiceField( label=_(u"Treatment request type"), choices=[]) + history_modifier = forms.IntegerField( label=_(u"Modified by"), widget=widgets.JQueryAutoComplete( diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index 4ee5fe08b..68a6ebb13 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -24,7 +24,7 @@ from django.contrib.gis.db import models from django.db.models import Max, Q from django.db.models.signals import post_save, post_delete, pre_delete from django.template.defaultfilters import slugify -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ugettext_lazy as _, pgettext_lazy from archaeological_finds.models_finds import Find, FindBasket, TreatmentType from archaeological_operations.models import ClosedItem, Operation @@ -33,7 +33,8 @@ from ishtar_common.models import Document, GeneralType, \ ImageModel, BaseHistorizedItem, OwnPerms, HistoricalRecords, Person, \ Organization, ValueGetter, post_save_cache, ShortMenuItem, \ DashboardFormItem -from ishtar_common.utils import cached_label_changed, get_current_year +from ishtar_common.utils import cached_label_changed, get_current_year, \ + TXT_SEARCH_COMMENT class TreatmentState(GeneralType): @@ -49,20 +50,17 @@ post_delete.connect(post_save_cache, sender=TreatmentState) class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem): + SLUG = 'treatment' SHOW_URL = 'show-treatment' TABLE_COLS = ('year', 'index', 'treatment_types__label', 'treatment_state__label', 'label', 'person', 'start_date', 'downstream_cached_label', 'upstream_cached_label') - REVERSED_BOOL_FIELDS = ['image__isnull'] + REVERSED_BOOL_FIELDS = ['documents__image__isnull'] EXTRA_REQUEST_KEYS = { - "label": 'label__icontains', - "other_reference": 'other_reference__icontains', - "treatment_types": "treatment_types__pk", "downstream_cached_label": "downstream__cached_label", "upstream_cached_label": "upstream__cached_label", - 'image': 'image__isnull', } COL_LABELS = { "downstream_cached_label": _(u"Downstream find"), @@ -72,7 +70,37 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem, } # extra keys than can be passed to save method EXTRA_SAVED_KEYS = ('items', 'user') - SLUG = 'treatment' + + # alternative names of fields for searches + ALT_NAMES = { + 'label': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"label"), + 'label__icontains' + ), + 'other_reference': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"other-reference"), + 'other_reference__icontains' + ), + 'year': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"year"), + 'year' + ), + 'index': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"index"), + 'index' + ), + 'documents__image__isnull': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"has-image"), + 'documents__image__isnull' + ), + 'treatment_types': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"type"), + 'treatment_types__label__iexact' + ), + } + for v in ALT_NAMES.values(): + EXTRA_REQUEST_KEYS[v[0]] = v[1] + BASE_SEARCH_VECTORS = [ 'treatment_types__label', 'treatment_state__label', 'label', 'goal', 'external_id', 'comment', 'description', 'other_reference', @@ -497,7 +525,45 @@ class TreatmentFile(DashboardFormItem, ClosedItem, BaseHistorizedItem, ] INT_SEARCH_VECTORS = ['year', 'index'] PARENT_SEARCH_VECTORS = ['in_charge', 'applicant', 'applicant_organisation'] - SLUG = 'treatmentfile' + + EXTRA_REQUEST_KEYS = {} + # alternative names of fields for searches + ALT_NAMES = { + 'name': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"name"), + 'name__icontains' + ), + 'internal_reference': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"reference"), + 'internal_reference__icontains' + ), + 'year': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"year"), + 'year' + ), + 'index': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"index"), + 'index' + ), + 'type': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"type"), + 'type__label__iexact' + ), + 'in_charge': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"in-charge"), + 'in_charge__cached_label__iexact' + ), + 'applicant': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"applicant"), + 'applicant__cached_label__iexact' + ), + 'applicant_organisation': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"applicant-organisation"), + 'applicant_organisation__cached_label__iexact' + ), + } + for v in ALT_NAMES.values(): + EXTRA_REQUEST_KEYS[v[0]] = v[1] # fields year = models.IntegerField(_(u"Year"), default=get_current_year) diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index d57a890eb..cfb62d6ec 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -471,7 +471,7 @@ RecordRelationsFormSet.form_admin_name = _(u"Operation - 080 - Relations") RecordRelationsFormSet.form_slug = "operation-080-relations" -class OperationSelect(TableSelect): # OK +class OperationSelect(TableSelect): _model = models.Operation search_vector = forms.CharField( @@ -1230,7 +1230,7 @@ class OperationDeletionForm(FinalForm): ######### -class SiteSelect(TableSelect): # OK +class SiteSelect(TableSelect): _model = models.ArchaeologicalSite search_vector = forms.CharField( @@ -1376,7 +1376,7 @@ class SiteUnderwaterForm(ManageOldType): ################################################ -class AdministrativeActOpeSelect(TableSelect): # OK +class AdministrativeActOpeSelect(TableSelect): _model = models.AdministrativeAct search_vector = forms.CharField( diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 082bbd2fe..34a3d2a01 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -1472,6 +1472,46 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter): pgettext_lazy(TXT_SEARCH_COMMENT, u"file-permit-reference"), 'associated_file__permit_reference__iexact' ), + 'treatment__name': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"treatment-name"), + 'treatment__label__icontains' + ), + 'treatment__other_reference': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"treatment-reference"), + 'treatment__other_reference__icontains' + ), + 'treatment__year': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"treatment-year"), + 'treatment__year' + ), + 'treatment__index': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"treatment-index"), + 'treatment__index' + ), + 'treatment__treatment_types': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"treatment-type"), + 'treatment__treatment_types__label__iexact' + ), + 'treatment_file__name': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"treatment-file-name"), + 'treatment_file__name__icontains' + ), + 'treatment_file__internal_reference': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"treatment-file-reference"), + 'treatment_file__internal_reference__icontains' + ), + 'treatment_file__year': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"treatment-file-year"), + 'treatment_file__year' + ), + 'treatment_file__index': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"treatment-file-index"), + 'treatment_file__index' + ), + 'treatment_file__type': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"treatment-file-type"), + 'treatment_file__type__label__iexact' + ), } for v in ALT_NAMES.values(): EXTRA_REQUEST_KEYS[v[0]] = v[1] diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py index 8192e36df..57992c7e2 100644 --- a/archaeological_warehouse/forms.py +++ b/archaeological_warehouse/forms.py @@ -78,7 +78,7 @@ SelectedDivisionFormset.form_admin_name = _(u"Warehouse - 020 - Divisions") SelectedDivisionFormset.form_slug = "warehouse-020-divisions" -class WarehouseSelect(TableSelect): # OK +class WarehouseSelect(TableSelect): _model = models.Warehouse search_vector = forms.CharField( @@ -247,7 +247,7 @@ class ContainerModifyForm(ContainerForm): return cleaned_data -class ContainerSelect(TableSelect): # OK +class ContainerSelect(TableSelect): _model = models.Container search_vector = forms.CharField( diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 5105416d6..7ff85f276 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -321,7 +321,7 @@ class Container(LightHistorizedItem, ImageModel): ), 'container_type': ( pgettext_lazy(TXT_SEARCH_COMMENT, u"type"), - 'warehouse_type__label__iexact' + 'container_type__label__iexact' ), 'reference': ( pgettext_lazy(TXT_SEARCH_COMMENT, u"reference"), diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 3745d5f73..48e744c18 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -337,7 +337,7 @@ class OrganizationForm(ManageOldType, NewItemForm): return new_item -class OrganizationSelect(TableSelect): # OK +class OrganizationSelect(TableSelect): _model = models.Organization search_vector = forms.CharField( @@ -456,7 +456,7 @@ class BaseOrganizationForm(forms.ModelForm): 'town', 'postal_code'] -class PersonSelect(TableSelect): # OK +class PersonSelect(TableSelect): _model = models.Person search_vector = forms.CharField( @@ -589,7 +589,7 @@ class PersonUserFormSelection(PersonFormSelection): validators=[models.valid_id(models.Person)]) -class IshtarUserSelect(TableSelect): # OK +class IshtarUserSelect(TableSelect): _model = models.IshtarUser search_vector = forms.CharField( @@ -1183,7 +1183,7 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType): return item -class DocumentSelect(TableSelect): # OK +class DocumentSelect(TableSelect): _model = models.Document search_vector = forms.CharField( |