diff options
Diffstat (limited to 'archaeological_context_records')
-rw-r--r-- | archaeological_context_records/admin.py | 4 | ||||
-rw-r--r-- | archaeological_context_records/forms.py | 135 | ||||
-rw-r--r-- | archaeological_context_records/ishtar_menu.py | 10 | ||||
-rw-r--r-- | archaeological_context_records/lookups.py | 2 | ||||
-rw-r--r-- | archaeological_context_records/models.py | 18 | ||||
-rw-r--r-- | archaeological_context_records/views.py | 14 |
6 files changed, 90 insertions, 93 deletions
diff --git a/archaeological_context_records/admin.py b/archaeological_context_records/admin.py index 9bd2f5c05..abee0a6d0 100644 --- a/archaeological_context_records/admin.py +++ b/archaeological_context_records/admin.py @@ -47,9 +47,9 @@ class AdminContextRecordForm(forms.ModelForm): class Meta: model = models.ContextRecord exclude = [] - point_2d = PointField(label=_(u"Point"), required=False, + point_2d = PointField(label=_("Point"), required=False, widget=OSMWidget) - multi_polygon = MultiPolygonField(label=_(u"Multi polygon"), required=False, + multi_polygon = MultiPolygonField(label=_("Multi polygon"), required=False, widget=OSMWidget) operation = AutoCompleteSelectField('operation') parcel = AutoCompleteSelectField('parcel', required=False) diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py index 357f5ce13..c4fa6f8fe 100644 --- a/archaeological_context_records/forms.py +++ b/archaeological_context_records/forms.py @@ -49,12 +49,12 @@ from ishtar_common import widgets class OperationFormSelection(CustomForm, forms.Form): form_label = _("Operation") - form_admin_name = _(u"Context record - 010 - Operation choice") + form_admin_name = _("Context record - 010 - Operation choice") form_slug = "contextrecord-010-operationchoice" associated_models = {'operation': Operation} currents = {'operation': Operation} operation = forms.IntegerField( - label=_(u"Operation"), required=False, + label=_("Operation"), required=False, widget=widgets.JQueryAutoComplete( reverse_lazy('autocomplete-operation'), associated_model=Operation), @@ -200,9 +200,12 @@ def get_init_parcel(form, operation, prefix=""): parcels = sorted(parcels, key=sort) for key, gparcels in groupby(parcels, sort): form.fields[prefix + 'parcel'].choices.append( - (" - ".join([k for k in key if k]), - [(parcel.pk, parcel.short_label) for parcel in gparcels]) + ( + " - ".join(k for k in key if k), + [(parcel.pk, parcel.short_label) for parcel in gparcels], + ) ) + if len(form.fields[prefix + 'parcel'].choices) == 1 and \ (prefix + 'town') in form.fields: # only the empty choice is available @@ -218,7 +221,7 @@ def get_init_parcel(form, operation, prefix=""): class RecordFormGeneral(CustomForm, ManageOldType): HEADERS = {} form_label = _("General") - form_admin_name = _(u"Context record - 020 - General") + form_admin_name = _("Context record - 020 - General") form_slug = "contextrecord-020-general" file_upload = True base_models = ["documentation"] @@ -230,58 +233,58 @@ class RecordFormGeneral(CustomForm, ManageOldType): 'excavation_technic': models.ExcavationTechnicType} pk = forms.IntegerField(required=False, widget=forms.HiddenInput) operation_id = forms.IntegerField(widget=forms.HiddenInput) - parcel = forms.ChoiceField(label=_(u"Parcel"), choices=[]) - town = forms.ChoiceField(label=_(u"Town"), choices=[], required=False) + parcel = forms.ChoiceField(label=_("Parcel"), choices=[]) + town = forms.ChoiceField(label=_("Town"), choices=[], required=False) archaeological_site = forms.ChoiceField( label=" ", choices=[], required=False, - help_text=_(u"Only the items associated to the operation can be " - u"selected.") + help_text=_("Only the items associated to the operation can be " + "selected.") ) - label = forms.CharField(label=_(u"ID"), + label = forms.CharField(label=_("ID"), validators=[validators.MaxLengthValidator(200)]) - unit = forms.ChoiceField(label=_(u"Context record type"), required=False, + unit = forms.ChoiceField(label=_("Context record type"), required=False, choices=[]) - description = forms.CharField(label=_(u"Description"), + description = forms.CharField(label=_("Description"), widget=forms.Textarea, required=False) - comment = forms.CharField(label=_(u"General comment"), + comment = forms.CharField(label=_("General comment"), widget=forms.Textarea, required=False) excavation_technic = forms.ChoiceField( - label=_(u"Excavation technique"), choices=[], required=False) + label=_("Excavation technique"), choices=[], required=False) surface = forms.IntegerField( required=False, widget=widgets.AreaWidget, - label=_(u"Total surface (m2)"), + label=_("Total surface (m2)"), validators=[validators.MinValueValidator(0), validators.MaxValueValidator(999999999)]) - length = forms.FloatField(label=_(u"Length (m)"), required=False) - width = forms.FloatField(label=_(u"Width (m)"), required=False) - thickness = forms.FloatField(label=_(u"Thickness (m)"), required=False) - diameter = forms.FloatField(label=_(u"Diameter (m)"), required=False) - depth = forms.FloatField(label=_(u"Depth (m)"), required=False) + length = forms.FloatField(label=_("Length (m)"), required=False) + width = forms.FloatField(label=_("Width (m)"), required=False) + thickness = forms.FloatField(label=_("Thickness (m)"), required=False) + diameter = forms.FloatField(label=_("Diameter (m)"), required=False) + depth = forms.FloatField(label=_("Depth (m)"), required=False) depth_of_appearance = forms.FloatField( - label=_(u"Depth of appearance (m)"), required=False) - opening_date = forms.DateField(label=_(u"Opening date"), + label=_("Depth of appearance (m)"), required=False) + opening_date = forms.DateField(label=_("Opening date"), widget=DatePicker, required=False) - closing_date = forms.DateField(label=_(u"Closing date"), + closing_date = forms.DateField(label=_("Closing date"), widget=DatePicker, required=False) documentation = forms.MultipleChoiceField( label=_("Documentation"), choices=[], required=False, widget=widgets.Select2Multiple) location = forms.CharField( - label=_(u"Location"), widget=forms.Textarea, + label=_("Location"), widget=forms.Textarea, required=False, validators=[validators.MaxLengthValidator(200)]) - HEADERS['x'] = FormHeader(_(u"Coordinates")) - x = forms.FloatField(label=_(u"X"), required=False) - estimated_error_x = forms.FloatField(label=_(u"Estimated error for X"), + HEADERS['x'] = FormHeader(_("Coordinates")) + x = forms.FloatField(label=_("X"), required=False) + estimated_error_x = forms.FloatField(label=_("Estimated error for X"), required=False) - y = forms.FloatField(label=_(u"Y"), required=False) - estimated_error_y = forms.FloatField(label=_(u"Estimated error for Y"), + y = forms.FloatField(label=_("Y"), required=False) + estimated_error_y = forms.FloatField(label=_("Estimated error for Y"), required=False) - z = forms.FloatField(label=_(u"Z"), required=False) - estimated_error_z = forms.FloatField(label=_(u"Estimated error for Z"), + z = forms.FloatField(label=_("Z"), required=False) + estimated_error_z = forms.FloatField(label=_("Estimated error for Z"), required=False) spatial_reference_system = forms.ChoiceField( - label=_(u"Spatial Reference System"), required=False, choices=[]) + label=_("Spatial Reference System"), required=False, choices=[]) TYPES = [ FieldType('unit', models.Unit), @@ -368,12 +371,12 @@ class RecordFormGeneral(CustomForm, ManageOldType): if 'pk' in cleaned_data and cleaned_data['pk']: cr = cr.exclude(pk=int(cleaned_data['pk'])) if cr.count(): - raise forms.ValidationError(_(u"This ID already exists for " - u"this operation.")) + raise forms.ValidationError(_("This ID already exists for " + "this operation.")) if not self.cleaned_data.get('parcel', None) and not \ self.cleaned_data.get('town', None): - raise forms.ValidationError(_(u"You have to choose a town or a " - u"parcel.")) + raise forms.ValidationError(_("You have to choose a town or a " + "parcel.")) return cleaned_data @@ -384,8 +387,8 @@ class DatingForm(ManageOldType, forms.Form): 'quality': models.DatingQuality, 'period': models.Period} period = forms.ChoiceField(label=_("Period"), choices=[]) - start_date = forms.IntegerField(label=_(u"Start date"), required=False) - end_date = forms.IntegerField(label=_(u"End date"), required=False) + start_date = forms.IntegerField(label=_("Start date"), required=False) + end_date = forms.IntegerField(label=_("End date"), required=False) quality = forms.ChoiceField(label=_("Quality"), required=False, choices=[]) dating_type = forms.ChoiceField(label=_("Dating type"), required=False, choices=[]) @@ -402,7 +405,7 @@ class DatingForm(ManageOldType, forms.Form): DatingFormSet = formset_factory(DatingForm, can_delete=True, formset=FormSet) DatingFormSet.form_label = _("Dating") -DatingFormSet.form_admin_name = _(u"Context record - 030 - Dating") +DatingFormSet.form_admin_name = _("Context record - 030 - Dating") DatingFormSet.form_slug = "contextrecord-030-datings" @@ -412,7 +415,7 @@ class RecordRelationsForm(OpeRecordRelationsForm): associated_models = {'right_record': models.ContextRecord, 'relation_type': models.RelationType} right_record = forms.ChoiceField( - label=_(u"Context record"), choices=[], required=False) + label=_("Context record"), choices=[], required=False) def __init__(self, *args, **kwargs): crs = None @@ -428,34 +431,34 @@ class RecordRelationsForm(OpeRecordRelationsForm): RecordRelationsFormSet = formset_factory( RecordRelationsForm, can_delete=True, formset=RecordRelationsFormSetBase) -RecordRelationsFormSet.form_label = _(u"Relations") -RecordRelationsFormSet.form_admin_name = _(u"Context record - 050 - Relations") +RecordRelationsFormSet.form_label = _("Relations") +RecordRelationsFormSet.form_admin_name = _("Context record - 050 - Relations") RecordRelationsFormSet.form_slug = "contextrecord-050-recordrelations" class RecordFormInterpretation(CustomForm, ManageOldType, forms.Form): - form_label = _(u"Interpretation") - form_admin_name = _(u"Context record - 040 - Interpretation") + form_label = _("Interpretation") + form_admin_name = _("Context record - 040 - Interpretation") form_slug = "contextrecord-040-interpretation" associated_models = {'activity': models.ActivityType, 'identification': models.IdentificationType} datings_comment = forms.CharField( - label=_(u"Comments on dating"), required=False, + label=_("Comments on dating"), required=False, widget=forms.Textarea) - filling = forms.CharField(label=_(u"Filling"), + filling = forms.CharField(label=_("Filling"), widget=forms.Textarea, required=False) - interpretation = forms.CharField(label=_(u"Interpretation"), + interpretation = forms.CharField(label=_("Interpretation"), widget=forms.Textarea, required=False) - activity = forms.ChoiceField(label=_(u"Activity"), required=False, + activity = forms.ChoiceField(label=_("Activity"), required=False, choices=[]) identification = forms.ChoiceField(label=_("Identification"), required=False, choices=[]) - taq = forms.IntegerField(label=_(u"TAQ"), required=False) - taq_estimated = forms.IntegerField(label=_(u"Estimated TAQ"), + taq = forms.IntegerField(label=_("TAQ"), required=False) + taq_estimated = forms.IntegerField(label=_("Estimated TAQ"), required=False) - tpq = forms.IntegerField(label=_(u"TPQ"), required=False) - tpq_estimated = forms.IntegerField(label=_(u"Estimated TPQ"), + tpq = forms.IntegerField(label=_("TPQ"), required=False) + tpq_estimated = forms.IntegerField(label=_("Estimated TPQ"), required=False) TYPES = [ @@ -465,27 +468,27 @@ class RecordFormInterpretation(CustomForm, ManageOldType, forms.Form): OperationRecordFormSelection = get_form_selection( - 'OperationRecordFormSelection', _(u"Operation search"), 'operation_id', + 'OperationRecordFormSelection', _("Operation search"), 'operation_id', Operation, OperationSelect, 'get-operation', - _(u"You should select an operation.")) + _("You should select an operation.")) class RecordDeletionForm(FinalForm): confirm_msg = " " - confirm_end_msg = _(u"Would you like to delete this context record?") + confirm_end_msg = _("Would you like to delete this context record?") class QAOperationCR(IshtarForm): - town = forms.ChoiceField(label=_(u"Town"), choices=[]) + town = forms.ChoiceField(label=_("Town"), choices=[]) archaeological_site = forms.ChoiceField( label=" ", choices=[], required=False, - help_text=_(u"Only the items associated to the operation can be " - u"selected.") + help_text=_("Only the items associated to the operation can be " + "selected.") ) - label = forms.CharField(label=_(u"ID"), + label = forms.CharField(label=_("ID"), validators=[validators.MaxLengthValidator(200)]) - parcel = forms.ChoiceField(label=_(u"Parcel"), choices=[], required=False) - unit = forms.ChoiceField(label=_(u"Context record type"), required=False, + parcel = forms.ChoiceField(label=_("Parcel"), choices=[], required=False) + unit = forms.ChoiceField(label=_("Context record type"), required=False, choices=[]) TYPES = [ @@ -517,8 +520,8 @@ class QAOperationCR(IshtarForm): ] if self.profil.parcel_mandatory: self.fields['parcel'].choices += [('', '--')] + [ - (str(parcel.pk), u"{} - {}".format(parcel.short_label, - parcel.town)) + (str(parcel.pk), "{} - {}".format(parcel.short_label, + parcel.town)) for parcel in operation.parcels.all()] def save(self, items): @@ -539,9 +542,9 @@ class QAOperationCR(IshtarForm): class QAContextRecordDuplicateForm(IshtarForm): qa_label = forms.CharField(label=_("ID"), max_length=None, required=True) - qa_parcel = forms.ChoiceField(label=_(u"Parcel"), choices=[]) - qa_town = forms.ChoiceField(label=_(u"Town"), choices=[], required=False) - qa_unit = forms.ChoiceField(label=_(u"Context record type"), required=False, + qa_parcel = forms.ChoiceField(label=_("Parcel"), choices=[]) + qa_town = forms.ChoiceField(label=_("Town"), choices=[], required=False) + qa_unit = forms.ChoiceField(label=_("Context record type"), required=False, choices=[]) TYPES = [ diff --git a/archaeological_context_records/ishtar_menu.py b/archaeological_context_records/ishtar_menu.py index fc02c5eef..a7efd8da4 100644 --- a/archaeological_context_records/ishtar_menu.py +++ b/archaeological_context_records/ishtar_menu.py @@ -26,22 +26,22 @@ from . import models # be carreful: each access_controls must be relevant with check_rights in urls MENU_SECTIONS = [ - (40, SectionItem('record_management', _(u"Context record"), + (40, SectionItem('record_management', _("Context record"), profile_restriction='context_record', css='menu-context-record', - childs=[MenuItem('record_search', _(u"Search"), + childs=[MenuItem('record_search', _("Search"), model=models.ContextRecord, access_controls=['view_contextrecord', 'view_own_contextrecord']), - MenuItem('record_creation', _(u"Creation"), + MenuItem('record_creation', _("Creation"), model=models.ContextRecord, access_controls=['add_contextrecord', 'add_own_contextrecord']), - MenuItem('record_modification', _(u"Modification"), + MenuItem('record_modification', _("Modification"), model=models.ContextRecord, access_controls=['change_contextrecord', 'change_own_contextrecord']), - MenuItem('record_deletion', _(u"Deletion"), + MenuItem('record_deletion', _("Deletion"), model=models.ContextRecord, access_controls=['delete_contextrecord', 'delete_own_contextrecord']), diff --git a/archaeological_context_records/lookups.py b/archaeological_context_records/lookups.py index 8356f5e12..7b7d5b85d 100644 --- a/archaeological_context_records/lookups.py +++ b/archaeological_context_records/lookups.py @@ -22,4 +22,4 @@ class ContextRecordLookup(LookupChannel): return self.model.objects.filter(query).order_by('cached_label')[:20] def format_item_display(self, item): - return u"<span class='ajax-label'>%s</span>" % item.cached_label + return "<span class='ajax-label'>%s</span>" % item.cached_label diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index ff5f937e3..1576088ed 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -217,16 +217,12 @@ class Dating(models.Model): return True def context_records_lbl(self): - return " - ".join( - [cr.cached_label for cr in self.context_records.all()] - ) + return " - ".join(cr.cached_label for cr in self.context_records.all()) context_records_lbl.short_description = _("Context record") context_records_lbl.admin_order_field = "context_records__cached_label" def finds_lbl(self): - return " - ".join( - [f.cached_label for f in self.find.all()] - ) + return " - ".join(f.cached_label for f in self.find.all()) finds_lbl.short_description = _("Find") finds_lbl.admin_order_field = "find__cached_label" @@ -514,14 +510,14 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem, QA_LOCK = QuickAction( url="contextrecord-qa-lock", icon_class="fa fa-lock", - text=_(u"Lock/Unlock"), target="many", + text=_("Lock/Unlock"), target="many", rights=['change_contextrecord', 'change_own_contextrecord'] ) QUICK_ACTIONS = [ QA_LOCK, QuickAction( url="contextrecord-qa-duplicate", icon_class="fa fa-clone", - text=_(u"Duplicate"), target="one", + text=_("Duplicate"), target="one", rights=['change_contextrecord', 'change_own_contextrecord']), ] @@ -861,8 +857,7 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem, return self.full_label() def _generate_cached_periods(self): - return " & ".join([dating.period.label - for dating in self.datings.all()]) + return " & ".join(dating.period.label for dating in self.datings.all()) def _generate_cached_related_context_records(self): return self.detailed_related_context_records() @@ -888,8 +883,7 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem, return self.archaeological_site.reference if self.operation.archaeological_sites.count(): return "-".join( - [a.reference for a in self.operation.archaeological_sites.all()] - ) + a.reference for a in self.operation.archaeological_sites.all()) return "" @property diff --git a/archaeological_context_records/views.py b/archaeological_context_records/views.py index 215dd2b4a..2de60dc2c 100644 --- a/archaeological_context_records/views.py +++ b/archaeological_context_records/views.py @@ -99,7 +99,7 @@ get_contextrecordrelationdetail = get_item( record_search_wizard = wizards.RecordSearch.as_view([ ('general-record_search', forms.RecordFormSelection)], - label=_(u"Context record search"), + label=_("Context record search"), url_name='record_search',) record_creation_steps = [ @@ -113,7 +113,7 @@ record_creation_steps = [ record_creation_wizard = wizards.RecordWizard.as_view( record_creation_steps, - label=_(u"New context record"), + label=_("New context record"), url_name='record_creation', ) @@ -129,7 +129,7 @@ record_modification_steps = [ record_modification_wizard = wizards.RecordModifWizard.as_view( record_modification_steps, - label=_(u"Context record modification"), + label=_("Context record modification"), url_name='record_modification', ) @@ -147,7 +147,7 @@ def record_modify(request, pk): record_deletion_wizard = wizards.RecordDeletionWizard.as_view([ ('selec-record_deletion', forms.RecordFormMultiSelection), ('final-record_deletion', forms.RecordDeletionForm)], - label=_(u"Context record deletion"), + label=_("Context record deletion"), url_name='record_deletion',) @@ -216,12 +216,12 @@ class QAOperationContextRecordView(QAItemForm): template_name = 'ishtar/forms/qa_operation_contextrecord.html' model = Operation form_class = forms.QAOperationCR - page_name = _(u"Context record") + page_name = _("Context record") def get_quick_action(self): return QuickAction( url="operation-qa-contextrecord", icon_class="fa fa-plus", - text=_(u"Add context record"), target="one", + text=_("Add context record"), target="one", rights=['add_contextrecord', 'add_own_contextrecord']) def form_valid(self, form): @@ -253,6 +253,6 @@ class QAContextRecordDuplicateFormView(QAItemForm): def get_context_data(self, **kwargs): data = super(QAContextRecordDuplicateFormView, self).get_context_data( **kwargs) - data['action_name'] = _(u"Duplicate") + data['action_name'] = _("Duplicate") data["operation"] = self.items[0].operation return data |