diff options
Diffstat (limited to 'ishtar/ishtar_base/forms_context_records.py')
-rw-r--r-- | ishtar/ishtar_base/forms_context_records.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/ishtar/ishtar_base/forms_context_records.py b/ishtar/ishtar_base/forms_context_records.py index 07990ee43..b40f5ae80 100644 --- a/ishtar/ishtar_base/forms_context_records.py +++ b/ishtar/ishtar_base/forms_context_records.py @@ -116,6 +116,14 @@ class RecordSelect(forms.Form): choices=models.Period.get_types()) unit = forms.ChoiceField(label=_("Unit type"), choices=models.Unit.get_types()) + def __init__(self, *args, **kwargs): + super(RecordSelect, self).__init__(*args, **kwargs) + self.fields['datings__period'].choices = \ + models.Period.get_types() + self.fields['datings__period'].help_text = \ + models.Period.get_help() + self.fields['unit'].choices = models.Unit.get_types() + self.fields['unit'].help_text = models.Unit.get_help() class RecordFormSelection(forms.Form): form_label = _("Context record search") @@ -286,4 +294,60 @@ record_deletion_wizard = RecordDeletionWizard([ ('final-record_deletion', RecordDeletionForm)], url_name='record_deletion',) +######################################### +# Source management for context records # +######################################### + +class RecordSourceWizard(SourceWizard): + model = models.ContextRecordSource + +SourceRecordFormSelection = get_form_selection( + 'SourceRecordFormSelection', _(u"Context record search"), + 'context_record', models.ContextRecord, RecordSelect, 'get-contextrecord', + _(u"You should select a context record.")) + +record_source_creation_wizard = RecordSourceWizard([ + ('selec-record_source_creation', SourceRecordFormSelection), + ('source-record_source_creation', SourceForm), + ('authors-record_source_creation', AuthorFormset), + ('final-record_source_creation', FinalForm)], + url_name='record_source_creation',) + +class RecordSourceSelect(SourceSelect): + context_record__parcel__town = get_town_field() + context_record__operation__year = forms.IntegerField(label=_(u"Year")) + context_record__datings__period = forms.ChoiceField(label=_(u"Period"), + choices=models.Period.get_types()) + context_record__unit = forms.ChoiceField(label=_(u"Unit type"), + choices=models.Unit.get_types()) + def __init__(self, *args, **kwargs): + super(RecordSourceSelect, self).__init__(*args, **kwargs) + self.fields['context_record__datings__period'].choices = \ + models.Period.get_types() + self.fields['context_record__datings__period'].help_text = \ + models.Period.get_help() + self.fields['context_record__unit'].choices = models.Unit.get_types() + self.fields['context_record__unit'].help_text = models.Unit.get_help() + + +RecordSourceFormSelection = get_form_selection( + 'RecordSourceFormSelection', _(u"Documentation search"), 'pk', + models.ContextRecordSource, RecordSourceSelect, 'get-recordsource', + _(u"You should select a document.")) + +record_source_modification_wizard = RecordSourceWizard([ + ('selec-record_source_modification', RecordSourceFormSelection), + ('source-record_source_modification', SourceForm), + ('authors-record_source_modification', AuthorFormset), + ('final-record_source_modification', FinalForm)], + url_name='record_source_modification',) + +class RecordSourceDeletionWizard(DeletionWizard): + model = models.ContextRecordSource + fields = ['context_record', 'title', 'source_type', 'authors',] + +record_source_deletion_wizard = RecordSourceDeletionWizard([ + ('selec-record_source_deletion', RecordSourceFormSelection), + ('final-record_source_deletion', RecordDeletionForm)], + url_name='record_source_deletion',) |