summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_finds/forms.py24
-rw-r--r--archaeological_finds/templates/ishtar/sheet_find.html13
-rw-r--r--ishtar_common/admin.py6
3 files changed, 39 insertions, 4 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py
index d05b67470..11ecf8152 100644
--- a/archaeological_finds/forms.py
+++ b/archaeological_finds/forms.py
@@ -31,7 +31,8 @@ from django.forms.formsets import formset_factory
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
-from ishtar_common.models import valid_id, valid_ids, get_current_profile
+from ishtar_common.models import valid_id, valid_ids, get_current_profile, \
+ SpatialReferenceSystem
from archaeological_operations.models import Period, ArchaeologicalSite, \
RelationType as OpeRelationType
from archaeological_context_records.models import DatingType, DatingQuality, \
@@ -128,7 +129,9 @@ class FindForm(ManageOldType, forms.Form):
'object_type': models.ObjectType,
'preservation_to_consider': models.PreservationType,
'integritie': models.IntegrityType,
- 'remarkabilitie': models.RemarkabilityType}
+ 'remarkabilitie': models.RemarkabilityType,
+ 'get_first_base_find__spatial_reference_system':
+ SpatialReferenceSystem}
label = forms.CharField(
label=_(u"Free ID"),
validators=[validators.MaxLengthValidator(60)])
@@ -172,7 +175,8 @@ class FindForm(ManageOldType, forms.Form):
get_first_base_find__estimated_error_z = \
forms.FloatField(label=_(u"Estimated error for Z"), required=False)
get_first_base_find__spatial_reference_system = \
- forms.FloatField(label=_(u"Spatial Reference System"), required=False)
+ forms.ChoiceField(label=_(u"Spatial Reference System"), required=False,
+ choices=[])
length = FloatField(label=_(u"Length (cm)"), required=False)
width = FloatField(label=_(u"Width (cm)"), required=False)
height = FloatField(label=_(u"Height (cm)"), required=False)
@@ -212,6 +216,13 @@ class FindForm(ManageOldType, forms.Form):
'get_first_base_find__estimated_error_z',
'get_first_base_find__spatial_reference_system',]:
self.fields.pop(k)
+ else:
+ srs = 'get_first_base_find__spatial_reference_system'
+ self.fields[srs].choices = \
+ SpatialReferenceSystem.get_types(
+ initial=self.init_data.get(srs))
+ self.fields[srs].help_text = \
+ SpatialReferenceSystem.get_help()
self.fields['checked'].choices = models.CHECK_CHOICES
self.fields['material_type'].help_text = models.MaterialType.get_help()
self.fields['conservatory_state'].choices = \
@@ -246,8 +257,13 @@ class FindForm(ManageOldType, forms.Form):
return self.cleaned_data
x = self.cleaned_data.get('get_first_base_find__x', None)
y = self.cleaned_data.get('get_first_base_find__y', None)
- s = 'get_first_base_find__get_first_base_find__spatial_reference_system'
+ s = 'get_first_base_find__spatial_reference_system'
srs = self.cleaned_data.get(s, None)
+ if srs:
+ try:
+ srs = SpatialReferenceSystem.objects.get(pk=srs)
+ except SpatialReferenceSystem.DoesNotExist:
+ srs = None
if x and y and not srs:
raise forms.ValidationError(
_(u"You should at least provide X, Y and the spatial "
diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html
index 0b4ac227d..40ccdd713 100644
--- a/archaeological_finds/templates/ishtar/sheet_find.html
+++ b/archaeological_finds/templates/ishtar/sheet_find.html
@@ -200,6 +200,19 @@
{% field_li "Parcel" base_find.context_record.parcel %}
{% field_li_detail "Operation" base_find.context_record.operation %}
{% field_li "Point of topographic reference" base_find.topographic_localisation %}
+
+{% if base_find.x or base_find.y %}
+ <li><label>{% trans "Coordinates:" %}</label>
+ <span class="value">
+ {% trans "X:"%} {{base_find.x|default_if_none:"-"}},
+ {% trans "Y:"%} {{base_find.y|default_if_none:"-"}},
+ {% trans "Z:"%} {{base_find.z|default_if_none:"-"}}
+ {% if base_find.spatial_reference_system %}
+ ({{base_find.spatial_reference_system.label}}{% if base_find.spatial_reference_system.srid %} -
+ {% trans "SRID:"%} {{base_find.spatial_reference_system.srid}}{% endif %})
+ {% endif %}
+ </span>
+{% endif %}
</ul>
{% field "Description" base_find.description "<pre>" "</pre>" %}
diff --git a/ishtar_common/admin.py b/ishtar_common/admin.py
index aa04a7b1c..efb452e74 100644
--- a/ishtar_common/admin.py
+++ b/ishtar_common/admin.py
@@ -235,6 +235,12 @@ class OperationTypeAdmin(GeneralTypeAdmin):
admin.site.register(models.OperationType, OperationTypeAdmin)
+class SpatialReferenceSystemAdmin(GeneralTypeAdmin):
+ list_display = GeneralTypeAdmin.list_display + ['order', 'srid']
+ model = models.SpatialReferenceSystem
+admin.site.register(models.SpatialReferenceSystem, SpatialReferenceSystemAdmin)
+
+
class IshtarUserAdmin(admin.ModelAdmin):
readonly_fields = ('password',)