summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/forms.py2
-rw-r--r--archaeological_finds/forms_treatments.py14
-rw-r--r--archaeological_finds/models_treatments.py84
3 files changed, 88 insertions, 12 deletions
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)