Skip to content

Commit

Permalink
Merge pull request #537 from Terralego/bump_black
Browse files Browse the repository at this point in the history
Bump black from 23.12.1 to 24.1.1
  • Loading branch information
submarcos authored Feb 1, 2024
2 parents 0b03fdf + ef9560b commit 4cbae9a
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 39 deletions.
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ babel==2.12.1
# via
# -r docs/requirements.txt
# sphinx
black==23.12.1
black==24.1.1
# via -r dev-requirements.in
build==0.10.0
# via pip-tools
Expand Down
16 changes: 10 additions & 6 deletions project/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ def custom_settings(request):
return {
"OIDC_ENABLED": settings.OIDC_ENABLE_LOGIN,
"INSTANCE_TITLE": config.INSTANCE_TITLE,
"INSTANCE_LOGO": config.INSTANCE_LOGO
if config.INSTANCE_LOGO.startswith("/")
else default_storage.url(config.INSTANCE_LOGO),
"INSTANCE_FAVICON": config.INSTANCE_FAVICON
if config.INSTANCE_FAVICON.startswith("/")
else default_storage.url(config.INSTANCE_FAVICON),
"INSTANCE_LOGO": (
config.INSTANCE_LOGO
if config.INSTANCE_LOGO.startswith("/")
else default_storage.url(config.INSTANCE_LOGO)
),
"INSTANCE_FAVICON": (
config.INSTANCE_FAVICON
if config.INSTANCE_FAVICON.startswith("/")
else default_storage.url(config.INSTANCE_FAVICON)
),
}
1 change: 1 addition & 0 deletions project/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""

import os
from datetime import timedelta
from pathlib import Path
Expand Down
6 changes: 3 additions & 3 deletions project/terra_layer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ def save(self, wizard_update=True, preserve_legend=False, **kwargs):
extra_style.style_config
)
if extra_style.style_config:
style_by_uid[
extra_style.style_config["uid"]
] = extra_style.style_config
style_by_uid[extra_style.style_config["uid"]] = (
extra_style.style_config
)
extra_style.save()

all_legends = list(self.legends)
Expand Down
6 changes: 3 additions & 3 deletions project/terra_layer/sources_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def to_representation(self, obj):
"id": obj.layer_identifier,
"source": DEFAULT_SOURCE_NAME,
"source-layer": self.source_object.slug,
"advanced_style": obj.advanced_style
if hasattr(obj, "advanced_style")
else {}, # custom style has no advanced styles
"advanced_style": (
obj.advanced_style if hasattr(obj, "advanced_style") else {}
), # custom style has no advanced styles
}

class Meta:
Expand Down
49 changes: 26 additions & 23 deletions project/terra_layer/style/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ def generate_style_from_wizard(geo_layer, config):
value = prop_config["value"]
no_value = prop_config.get("no_value")
data_field = prop_config.get("field")
map_style.setdefault(paint_or_layout, {})[
map_style_prop
] = get_style_no_value_condition(["get", data_field], value, no_value)
map_style.setdefault(paint_or_layout, {})[map_style_prop] = (
get_style_no_value_condition(["get", data_field], value, no_value)
)
elif style_type == "variable":
# Variable style
data_field = prop_config["field"]
Expand All @@ -101,10 +101,10 @@ def generate_style_from_wizard(geo_layer, config):

if variation_type == "color":
if analysis == "graduated":
map_style.setdefault(paint_or_layout, {})[
map_style_prop
] = gen_graduated_color_style(
geo_layer, data_field, map_field, prop_config
map_style.setdefault(paint_or_layout, {})[map_style_prop] = (
gen_graduated_color_style(
geo_layer, data_field, map_field, prop_config
)
)
if prop_config.get("generate_legend"):
legend = gen_graduated_color_legend(
Expand All @@ -118,10 +118,13 @@ def generate_style_from_wizard(geo_layer, config):
# TODO reuse previous computations
legends.append(legend)
elif analysis == "categorized":
map_style.setdefault(paint_or_layout, {})[
map_style_prop
] = gen_categorized_any_style(
geo_layer, data_field, prop_config, DEFAULT_NO_VALUE_FILL_COLOR
map_style.setdefault(paint_or_layout, {})[map_style_prop] = (
gen_categorized_any_style(
geo_layer,
data_field,
prop_config,
DEFAULT_NO_VALUE_FILL_COLOR,
)
)
if (
map_style.setdefault(paint_or_layout, {})[map_style_prop]
Expand Down Expand Up @@ -171,10 +174,10 @@ def generate_style_from_wizard(geo_layer, config):
legends.append(legend)

elif analysis == "proportionnal":
map_style.setdefault(paint_or_layout, {})[
map_style_prop
] = gen_proportionnal_radius_style(
geo_layer, data_field, map_field, prop_config
map_style.setdefault(paint_or_layout, {})[map_style_prop] = (
gen_proportionnal_radius_style(
geo_layer, data_field, map_field, prop_config
)
)
# Add sort key
# TODO find more smart way to do that
Expand Down Expand Up @@ -208,10 +211,10 @@ def generate_style_from_wizard(geo_layer, config):

if variation_type == "value":
if analysis == "graduated":
map_style.setdefault(paint_or_layout, {})[
map_style_prop
] = gen_graduated_size_style(
geo_layer, data_field, map_field, prop_config
map_style.setdefault(paint_or_layout, {})[map_style_prop] = (
gen_graduated_size_style(
geo_layer, data_field, map_field, prop_config
)
)
if prop_config.get("generate_legend"):
# TODO reuse previous computations
Expand Down Expand Up @@ -265,10 +268,10 @@ def generate_style_from_wizard(geo_layer, config):
"""map_style["layout"] = {
f"{map_style_type}-sort-key": ["-", ["get", data_field]]
}"""
map_style.setdefault(paint_or_layout, {})[
map_style_prop
] = gen_proportionnal_size_style(
geo_layer, data_field, map_field, prop_config
map_style.setdefault(paint_or_layout, {})[map_style_prop] = (
gen_proportionnal_size_style(
geo_layer, data_field, map_field, prop_config
)
)
if prop_config.get("generate_legend"):
# TODO reuse previous computations
Expand Down
8 changes: 5 additions & 3 deletions project/terra_layer/views/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,11 @@ def get_layer_structure(self):
{
"id": baselayer.id,
"label": baselayer.name,
"url": self.request.build_absolute_uri(baselayer.url)
if baselayer.base_layer_type != "mapbox"
else baselayer.url,
"url": (
self.request.build_absolute_uri(baselayer.url)
if baselayer.base_layer_type != "mapbox"
else baselayer.url
),
}
for baselayer in map_base_layers
]
Expand Down

0 comments on commit 4cbae9a

Please sign in to comment.