summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ishtar/furnitures/forms.py52
-rw-r--r--ishtar/furnitures/menus.py2
-rw-r--r--ishtar/furnitures/models.py2
-rw-r--r--ishtar/furnitures/urls.py4
-rw-r--r--ishtar/furnitures/views.py4
5 files changed, 48 insertions, 16 deletions
diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py
index 821ef1bb9..ba3ba826b 100644
--- a/ishtar/furnitures/forms.py
+++ b/ishtar/furnitures/forms.py
@@ -733,7 +733,7 @@ class FileSelect(forms.Form):
year = forms.IntegerField(label=_("Year"))
class FileFormSelection(forms.Form):
- form_label = _("Archaelogical file")
+ form_label = _("Archaeological file")
associated_models = {'pk':models.File}
currents = {'pk':models.File}
pk = forms.IntegerField(label="", required=False,
@@ -747,17 +747,6 @@ class FileFormSelection(forms.Form):
raise forms.ValidationError(_(u"You should select a file."))
return cleaned_data
-"""
-class FileFormSelection(forms.Form):
- form_label = _("Archaelogical file")
- associated_models = {'pk':models.File}
- currents = {'pk':models.File}
- pk = forms.IntegerField(label=_("References/location"),
- widget=widgets.JQueryAutoComplete(reverse_lazy('autocomplete-file'),
- associated_model=models.File),
- validators=[models.valid_id(models.File)])
-"""
-
class FileFormGeneral(forms.Form):
form_label = _("General")
associated_models = {'in_charge':models.Person,
@@ -1671,11 +1660,36 @@ class RecordWizard(Wizard):
obj.datings.add(dating)
return res
+class RecordSelect(forms.Form):
+ parcel__town = forms.IntegerField(label=_(u"Town"),
+ widget=widgets.JQueryAutoComplete("/" + settings.URL_PATH + \
+ 'autocomplete-town', associated_model=models.Town),
+ validators=[models.valid_id(models.Town)])
+ parcel__operation__operation_type = forms.ChoiceField(
+ label=_("Operation type"), choices=models.OperationType.get_types())
+ parcel__year = forms.IntegerField(label=_("Year"))
+
+class RecordFormSelection(forms.Form):
+ form_label = _("Context record")
+ associated_models = {'pk':models.ContextRecord}
+ currents = {'pk':models.ContextRecord}
+ pk = forms.IntegerField(label="", required=False,
+ widget=widgets.JQueryJqGrid(reverse_lazy('get-contextrecord'),
+ RecordSelect(), models.ContextRecord),
+ validators=[models.valid_id(models.ContextRecord)])
+
+ def clean(self):
+ cleaned_data = self.cleaned_data
+ if 'pk' not in cleaned_data or not cleaned_data['pk']:
+ raise forms.ValidationError(_(u"You should select a context "
+ u"record."))
+ return cleaned_data
+
class RecordFormGeneral(forms.Form):
form_label = _("General")
associated_models = {'parcel':models.Parcel,}
- parcel = forms.ChoiceField(label=_("Parcel"), choices=[('', '--')])
+ parcel = forms.ChoiceField(label=_("Parcel"), choices=[])
label = forms.CharField(label=_(u"Label"),
validators=[validators.MaxLengthValidator(200)])
description = forms.CharField(label=_(u"Description"),
@@ -1700,7 +1714,8 @@ class RecordFormGeneral(forms.Form):
if 'files' in kwargs:
kwargs.pop('files')
super(RecordFormGeneral, self).__init__(*args, **kwargs)
- if operation and len(self.fields['parcel'].choices) == 1:
+ self.fields['parcel'].choices = [('', '--')]
+ if operation:
parcels = operation.parcels.all()
sort = lambda x: (x.town.name, x.section)
parcels = sorted(parcels, key=sort)
@@ -1762,3 +1777,12 @@ record_creation_wizard = RecordWizard([
('final-record_creation', FinalForm)],
url_name='record_creation',)
+record_modification_wizard = RecordWizard([
+ ('selec-record_modification', RecordFormSelection),
+ ('general-record_modification', RecordFormGeneral),
+ ('datings-record_modification', DatingFormSet),
+ ('units-record_modification', UnitFormSet),
+ ('interpretation-record_modification', RecordFormInterpretation),
+ ('final-record_modification', FinalForm)],
+ url_name='record_modification',)
+
diff --git a/ishtar/furnitures/menus.py b/ishtar/furnitures/menus.py
index d2fa5fba4..5f77f2507 100644
--- a/ishtar/furnitures/menus.py
+++ b/ishtar/furnitures/menus.py
@@ -169,7 +169,6 @@ class Menu:
],),
]),
SectionItem('record_management', _(u"Context record management"),
- childs=[SectionItem('by_operation', _(u"By operation"),
childs=[
MenuItem('record_creation', _(u"Creation"),
model=models.ContextRecord,
@@ -183,7 +182,6 @@ class Menu:
model=models.ContextRecord,
access_controls=['delete_contextrecord',
'delete_own_contextrecord']),
- ],),
])
]
self.items = {}
diff --git a/ishtar/furnitures/models.py b/ishtar/furnitures/models.py
index b9dc19afe..8826c0854 100644
--- a/ishtar/furnitures/models.py
+++ b/ishtar/furnitures/models.py
@@ -559,6 +559,8 @@ class Unit(GeneralType) :
return self.label
class ContextRecord(BaseHistorizedItem, OwnPerms):
+ TABLE_COLS = ['parcel.town', 'parcel.section', 'parcel.parcel_number',
+ 'label',]
parcel = models.ForeignKey(Parcel, verbose_name=_(u"Parcel"),
related_name='context_records')
label = models.CharField(_(u"Label"), max_length=200)
diff --git a/ishtar/furnitures/urls.py b/ishtar/furnitures/urls.py
index 71a3a116c..d2e55ac5e 100644
--- a/ishtar/furnitures/urls.py
+++ b/ishtar/furnitures/urls.py
@@ -65,6 +65,8 @@ urlpatterns = patterns('',
name='operation_administrativeact_deletion'),
url(BASE_URL + r'record_creation/(?P<step>.+)$',
ishtar_forms.record_creation_wizard, name='record_creation'),
+ url(BASE_URL + r'record_modification/(?P<step>.+)$',
+ ishtar_forms.record_modification_wizard, name='record_modification'),
)
for section in menu.childs:
for menu_item in section.childs:
@@ -105,4 +107,6 @@ urlpatterns += patterns('ishtar.furnitures.views',
name='update-current-item'),
url(BASE_URL + r'get-administrativeact/(?P<type>.+)?$',
'get_administrativeact', name='get-administrativeact'),
+ url(BASE_URL + r'get-contextrecord/(?P<type>.+)?$', 'get_contextrecord',
+ name='get-contextrecord'),
)
diff --git a/ishtar/furnitures/views.py b/ishtar/furnitures/views.py
index b22257839..43d5a46e2 100644
--- a/ishtar/furnitures/views.py
+++ b/ishtar/furnitures/views.py
@@ -377,6 +377,10 @@ def autocomplete_organization(request, orga_type=None):
return HttpResponse(data, mimetype='text/plain')
show_contextrecord = show_item(models.ContextRecord, 'contextrecord')
+get_contextrecord = get_item(models.ContextRecord,
+ 'get_contextrecord', 'contextrecord',
+ extra_request_keys={'parcel__town':'parcel__town__pk',
+ })
def action(request, action_slug, obj_id=None, *args, **kwargs):
"""