diff options
Diffstat (limited to 'ishtar/ishtar_base')
-rw-r--r-- | ishtar/ishtar_base/forms.py | 1 | ||||
-rw-r--r-- | ishtar/ishtar_base/forms_context_records.py | 18 | ||||
-rw-r--r-- | ishtar/ishtar_base/models.py | 7 |
3 files changed, 19 insertions, 7 deletions
diff --git a/ishtar/ishtar_base/forms.py b/ishtar/ishtar_base/forms.py index 85c4371d4..f69b5dcd4 100644 --- a/ishtar/ishtar_base/forms.py +++ b/ishtar/ishtar_base/forms.py @@ -368,6 +368,7 @@ class Wizard(NamedUrlSessionFormWizard): dct[dependant_item] = c_item if 'pk' in dct: dct.pop('pk') + print self.get_saved_model() obj = self.get_saved_model()(**dct) obj.save() for k in adds: diff --git a/ishtar/ishtar_base/forms_context_records.py b/ishtar/ishtar_base/forms_context_records.py index 35b7b785c..27b7fc6f2 100644 --- a/ishtar/ishtar_base/forms_context_records.py +++ b/ishtar/ishtar_base/forms_context_records.py @@ -37,7 +37,7 @@ from forms import Wizard, FinalForm, FormSet, SearchWizard, DeletionWizard, \ formset_factory, get_now, reverse_lazy, get_form_selection from forms_common import get_town_field, SourceForm, SourceWizard, \ SourceSelect, AuthorFormset -from forms_operations import OperationFormSelection +from forms_operations import OperationSelect class RecordWizard(Wizard): model = models.ContextRecord @@ -51,7 +51,7 @@ class RecordWizard(Wizard): main_form_key = 'selec-' + self.url_name try: idx = int(self.session_get_value(request, storage, - main_form_key, 'pk')) + main_form_key, 'operation_id')) current_ope = models.Operation.objects.get(pk=idx) return current_ope except(TypeError, ValueError, ObjectDoesNotExist): @@ -95,7 +95,7 @@ class RecordWizard(Wizard): main_form_key = 'selec-' + self.url_name try: idx = int(self.session_get_value(request, storage, - main_form_key, 'pk')) + main_form_key, 'operation_id')) current_obj = models.Operation.objects.get(pk=idx) data['operation'] = current_obj except(TypeError, ValueError, ObjectDoesNotExist): @@ -163,12 +163,12 @@ class RecordFormGeneral(forms.Form): def __init__(self, *args, **kwargs): operation = None if 'data' in kwargs and kwargs['data'] and \ - ('operation' in kwargs['data'] or 'context_record' in kwargs['data']): + ('operation' in kwargs['data'] or 'context_record' in kwargs['data']): if 'operation' in kwargs['data']: operation = kwargs['data']['operation'] if 'context_record' in kwargs['data'] and \ kwargs['data']['context_record']: - operation = kwargs['data']['context_record'].parcel.operation + operation = kwargs['data']['context_record'].operation # clean data if not "real" data prefix_value = kwargs['prefix'] if not [k for k in kwargs['data'].keys() @@ -261,8 +261,14 @@ record_search_wizard = SearchWizard([ ('general-record_search', RecordFormSelection)], url_name='record_search',) +OperationRecordFormSelection = get_form_selection( + 'OperationRecordFormSelection', _(u"Operation search"), 'operation_id', + models.Operation, OperationSelect, 'get-operation', + _(u"You should select an operation.")) + + record_creation_wizard = RecordWizard([ - ('selec-record_creation', OperationFormSelection), + ('selec-record_creation', OperationRecordFormSelection), ('general-record_creation', RecordFormGeneral), ('datings-record_creation', DatingFormSet), ('interpretation-record_creation', RecordFormInterpretation), diff --git a/ishtar/ishtar_base/models.py b/ishtar/ishtar_base/models.py index 9874460b9..b4745741a 100644 --- a/ishtar/ishtar_base/models.py +++ b/ishtar/ishtar_base/models.py @@ -868,7 +868,12 @@ class ContextRecord(BaseHistorizedItem, OwnPerms): ) def __unicode__(self): - return JOINT.join((unicode(self.parcel), self.label)) + return self.short_label() + + def short_label(self): + return JOINT.join([unicode(item) for item in [self.parcel, + self.label] if item]) + def full_label(self): if not self.parcel.operation: |