Skip to content

Commit b0b0f3e

Browse files
committed
Merge remote-tracking branch 'origin/merge_2025_b' into v3.0-rc_or1
2 parents 93e17e6 + 4c8db79 commit b0b0f3e

4 files changed

Lines changed: 57 additions & 17 deletions

File tree

layers/serializers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ def get_companion_layers(obj):
3535
# Now, use `layer_instance` to filter Companionship instances
3636
companionships = Companionship.objects.filter(layer=layer_instance)
3737
companion_layers = []
38-
for companionship in companionships:
39-
companion_layers.extend(companionship.companions.all())
38+
if layer_instance.has_companion:
39+
for companionship in companionships:
40+
companion_layers.extend(companionship.companions.all())
41+
else:
42+
for companionship in layer_instance.companion_to.all():
43+
companion_layers.append(companionship.layer)
4044
return companion_layers
4145

4246
def get_serialized_sublayers(obj):

layers/static/layers/js/admin_layer_form.js

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const AdminLayerForm = (() => {
7979
show_spinner();
8080
var url = $('#id_url').val();
8181
$.ajax({
82-
url: '/data_manager/wms_capabilities/',
82+
url: '/layers/wms_capabilities/',
8383
data: {
8484
url: url
8585
},
@@ -88,12 +88,33 @@ const AdminLayerForm = (() => {
8888
var blank_option = '<option value="">_________</option>';
8989

9090
// Replace WMS Layer Name
91+
let layer_name_value = '';
92+
let layer_name_title = '';
93+
let layer_option_html = ''
9194
var slug_val = $('#id_layerwms_set-0-wms_slug').val();
9295
var layer_name_html = '<select id="id_layerwms_set-0-wms_slug" name="layerwms_set-0-wms_slug">';
9396
layer_name_html += blank_option;
9497
for (var i = 0; i < data.layers.length; i++) {
9598
var opt_val = data.layers[i];
96-
layer_name_html += '<option value="' + opt_val + '">' + opt_val + '</option>';
99+
if (typeof(opt_val) == "object"){
100+
if (opt_val.hasOwnProperty('key') && opt_val.hasOwnProperty('title')) {
101+
layer_name_value = opt_val['key'];
102+
layer_name_title = opt_val['title'];
103+
} else {
104+
layer_name_value = opt_val['key'];
105+
layer_name_title = opt_val['key'];
106+
}
107+
// } else if (typeof(opt_val) == "string") {
108+
} else {
109+
layer_name_value = opt_val;
110+
layer_name_title = opt_val;
111+
}
112+
layer_option_html = '<option value="' + layer_name_value + '"';
113+
if (slug_val === layer_name_value) {
114+
layer_option_html += ' selected';
115+
}
116+
layer_option_html += '>' + layer_name_title + '</option>';
117+
layer_name_html += layer_option_html;
97118
}
98119
layer_name_html += '</select>';
99120
$('#id_layerwms_set-0-wms_slug').replaceWith(layer_name_html);
@@ -141,15 +162,16 @@ const AdminLayerForm = (() => {
141162
$('#id_layerwms_set-0-wms_srs').val(srs_val);
142163
}
143164

144-
$('#id_layerwms_set-0-wms_srs').change(function () {
145-
if ($('#id_layerwms_set-0-wms_srs').val().toLowerCase() == 'epsg:3857') {
146-
$('#id_layerwms_set-0-wms_time_item').prop('disabled', true);
147-
$('#id_layerwms_set-0-wms_additional').prop('disabled', false);
148-
} else {
149-
$('#id_layerwms_set-0-wms_time_item').prop('disabled', false);
150-
$('#id_layerwms_set-0-wms_additional').prop('disabled', true);
151-
}
152-
});
165+
// 2025-04-17: What was the point of this? Give it a year and then remove it if you see this message.
166+
// $('#id_layerwms_set-0-wms_srs').change(function() {
167+
// if ($('#id_layerwms_set-0-wms_srs').val().toLowerCase() == 'epsg:3857') {
168+
// $('#id_layerwms_set-0-wms_time_item').prop('disabled', true);
169+
// $('#id_layerwms_set-0-wms_additional').prop('disabled', false);
170+
// } else {
171+
// $('#id_layerwms_set-0-wms_time_item').prop('disabled', false);
172+
// $('#id_layerwms_set-0-wms_additional').prop('disabled', true);
173+
// }
174+
// });
153175

154176
// Replace Styles
155177
var style_keys = [];
@@ -162,7 +184,7 @@ const AdminLayerForm = (() => {
162184
} else {
163185
$('#id_layerwms_set-0-wms_styles').prop('disabled', false);
164186
var style_val = $('#id_layerwms_set-0-wms_styles').val();
165-
var style_html = '<select id="id_layerwms_set-0-wms_styles" name="layerwms_set-0-wms_srs">';
187+
var style_html = '<select id="id_layerwms_set-0-wms_styles" name="layerwms_set-0-wms_styles">';
166188
style_html += '<option value="">Default</option>';
167189
for (var i = 0; i < style_keys.length; i++) {
168190
opt_val = style_keys[i];

layers/views.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,16 @@ def get_layer_details(request, layerID):
348348
specific_layer_model = layer_type_to_model.get(layer.layer_type)
349349
# Now, use the specific model class to get the specific layer instance
350350
if specific_layer_model and specific_layer_model != Layer:
351-
specific_layer = specific_layer_model.objects.get(layer=layer)
351+
# If admin doesn't touch specific layer form, no specific layer will have been created. This creates the default,
352+
# which has the same values that would be assumed if it were missing.
353+
(specific_layer, created) = specific_layer_model.objects.get_or_create(layer=layer)
352354
else:
355+
# TODO: why set this to layer? Why not just skil the next 'if' case if there is no specific layer?
356+
# specific_layer = False
353357
specific_layer = layer
354358
specific_layer_serializer_class = layer_type_to_serializer.get(layer.layer_type)
355359
# Instantiate the serializer with the specific layer instance
360+
# if specific_layer and specific_layer_serializer_class:
356361
if specific_layer_serializer_class:
357362
specific_layer_serializer = specific_layer_serializer_class(specific_layer)
358363
# Now you can use the serializer to get the serialized data
@@ -491,8 +496,16 @@ def wms_get_capabilities(url):
491496
'formats': available_formats
492497
}
493498

499+
try:
500+
layers_with_titles = []
501+
for key in wms.contents.keys():
502+
layers_with_titles.append({"key": key, "title": wms.contents[key].title})
503+
available_layers = layers_with_titles
504+
except Exception as e:
505+
available_layers = list(layers.keys())
506+
494507
result = {
495-
'layers': list(layers.keys()),
508+
'layers': available_layers,
496509
'formats': wms.getOperationByName('GetMap').formatOptions,
497510
'version': wms.version,
498511
'styles': styles,

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ django-colorfield
33
django-autocomplete-light
44
django-querysetsequence
55
django-import-export
6-
django-nested-admin
6+
django-nested-admin
7+
celery

0 commit comments

Comments
 (0)