Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop > Master / 2.13.2 #2730

Merged
merged 44 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b87523b
fix occtax mobile absolute apk_url ref #2708
joelclems Sep 18, 2023
fe11097
Changelog - Fix typos
camillemonchicourt Sep 18, 2023
6b54448
fix(permissions) fix asked permission
Pierre-Narcisi Sep 18, 2023
5defaff
bump UsersHub-auth
TheoLechemia Sep 19, 2023
cf4bd0f
prepa release
TheoLechemia Sep 19, 2023
abf568c
fix(permission) add the json params to the checked params
Pierre-Narcisi Sep 19, 2023
ce047ed
Changelog 2.13.2
camillemonchicourt Sep 20, 2023
e16f0be
Merge pull request #2709 from PnX-SI/fix/occtax_mobile_absolute_apk_url
camillemonchicourt Sep 20, 2023
2eb5cb4
Doc install - Typo
camillemonchicourt Sep 20, 2023
465ee3f
Doc admin - Review permissions
camillemonchicourt Sep 20, 2023
06215f0
Merge pull request #2715 from PnX-SI/doc-admin-review-permissions
camillemonchicourt Sep 20, 2023
d6aeb7f
move DispatcherMiddleware after custom /static
bouttier Sep 25, 2023
15892a9
remove hard-coded /static url path
bouttier Sep 25, 2023
3dfb7fe
db.session.remove() in celery post run hook
bouttier Dec 23, 2022
9dbf224
celery: enable_utc=False
bouttier Sep 27, 2023
99f31c6
bump UsersHub-auth
TheoLechemia Sep 19, 2023
067fc07
prepa release
TheoLechemia Sep 19, 2023
e42bad2
add bootstrap style on datalist
TheoLechemia Sep 27, 2023
2a1e957
docker: use python3.11 in backend image
bouttier Sep 27, 2023
4350d0f
Merge pull request #2711 from PnX-SI/prepa2.13.2
camillemonchicourt Sep 27, 2023
b862a4c
Merge pull request #2710 from PnX-SI/fix/use-validation-c
camillemonchicourt Sep 27, 2023
d533d82
Merge pull request #2720 from PnX-SI/fix/custo-app-root
camillemonchicourt Sep 27, 2023
299853b
Merge pull request #2725 from PnX-SI/feat/celery-utc-no
camillemonchicourt Sep 27, 2023
22981ae
Merge pull request #2728 from PnX-SI/feat/docker-python3.11
camillemonchicourt Sep 27, 2023
4f125e8
Merge pull request #2727 from PnX-SI/datalist-bootstrap
camillemonchicourt Sep 27, 2023
ec6ab11
dataset card buttons bloc: add hasAnyButtons
bouttier Sep 27, 2023
8a047d1
dataset input url: ask mod for right object code
bouttier Sep 27, 2023
3357a05
remove 03b_populate_db_for_test.sh
bouttier Sep 27, 2023
8cec8a9
Merge pull request #2726 from PnX-SI/refact/remove-populate-db-test
camillemonchicourt Sep 28, 2023
4342b29
Merge pull request #2724 from PnX-SI/fix/worker-session-leak
camillemonchicourt Sep 28, 2023
a89417c
Merge pull request #2729 from PnX-SI/fix/ds-input
camillemonchicourt Sep 28, 2023
b2af29d
Changelog 2.13.2
camillemonchicourt Sep 28, 2023
2d41a87
feat: add filter on module source for synthese
andriacap Sep 6, 2023
e0c3bfe
fix: fix different id_source in list
andriacap Sep 7, 2023
c99e2ba
feat: merge filters and add multiselect
andriacap Sep 13, 2023
57caf62
test(back): add fixtures and test
andriacap Sep 14, 2023
c7cd170
fix: name of aggreg variable
andriacap Sep 14, 2023
cfe627b
feat:change the way to filt synthese by module
andriacap Sep 25, 2023
34815ef
feat: use designStyle param
andriacap Sep 28, 2023
eb25cff
fix(permissions) fix for import case
Pierre-Narcisi Sep 27, 2023
175dcec
Merge pull request #2712 from PnX-SI/fix/datasets-route
camillemonchicourt Sep 28, 2023
2c0886c
Changelog 2.13.2
camillemonchicourt Sep 28, 2023
87032d5
GN 2.13.2 in install_all.ini
camillemonchicourt Sep 28, 2023
86ba9f5
Changelog 2.13.2
camillemonchicourt Sep 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ jobs:
working-directory: ./backend
- name: Install database
run: |
install/03b_populate_db_for_test.sh
install/03b_populate_db.sh
env:
GEONATURE_CONFIG_FILE: config/test_config.toml
srid_local: 2154
install_bdc_statuts: true
add_sample_data: true
install_sig_layers: true
install_grid_layer_5: true
install_ref_sensitivity: true
# FRONTEND
- name: Cache node modules
uses: actions/cache@v3
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ jobs:
GEONATURE_CONFIG_FILE: config/test_config.toml
- name: Install database
run: |
install/03b_populate_db_for_test.sh
install/03b_populate_db.sh
env:
GEONATURE_CONFIG_FILE: config/test_config.toml
srid_local: 2154
install_bdc_statuts: true
add_sample_data: true
install_sig_layers: true
install_grid_layer_5: true
install_ref_sensitivity: true
- name: Show database status
run: |
geonature db status
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.13.1
2.13.2
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1.2

FROM python:3.9-bullseye AS build
FROM python:3.11-bookworm AS build

ENV PIP_ROOT_USER_ACTION=ignore
RUN --mount=type=cache,target=/root/.cache \
Expand Down
13 changes: 6 additions & 7 deletions backend/geonature/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,18 @@ def create_app(with_external_mods=True):
app.wsgi_app = SchemeFix(app.wsgi_app, scheme=config.get("PREFERRED_URL_SCHEME"))
app.wsgi_app = ProxyFix(app.wsgi_app, x_host=1)
app.wsgi_app = RequestID(app.wsgi_app)
if app.config["APPLICATION_ROOT"] != "/":
app.wsgi_app = DispatcherMiddleware(
Response("Not Found", status=404),
{app.config["APPLICATION_ROOT"].rstrip("/"): app.wsgi_app},
)

if config.get("CUSTOM_STATIC_FOLDER"):
app.wsgi_app = SharedDataMiddleware(
app.wsgi_app,
{
"/static": config["CUSTOM_STATIC_FOLDER"],
app.static_url_path: config["CUSTOM_STATIC_FOLDER"],
},
)
if app.config["APPLICATION_ROOT"] != "/":
app.wsgi_app = DispatcherMiddleware(
Response("Not Found", status=404),
{app.config["APPLICATION_ROOT"].rstrip("/"): app.wsgi_app},
)

app.json = MyJSONProvider(app)

Expand Down
1 change: 1 addition & 0 deletions backend/geonature/celery_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

app.Task = ContextTask

app.conf.imports += ("geonature.tasks",)

Check warning on line 17 in backend/geonature/celery_app.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/celery_app.py#L17

Added line #L17 was not covered by tests
app.conf.imports += tuple(
[ep.module for dist in iter_modules_dist() for ep in dist.entry_points.select(name="tasks")]
)
14 changes: 7 additions & 7 deletions backend/geonature/core/gn_commons/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@
if app.relative_path_apk:
relative_apk_path = Path("mobile", app.relative_path_apk)
app_dict["url_apk"] = url_for("media", filename=str(relative_apk_path), _external=True)
relative_settings_path = relative_apk_path.parent / "settings.json"
app_dict["url_settings"] = url_for(
"media", filename=relative_settings_path, _external=True
)
settings_file = Path(current_app.config["MEDIA_FOLDER"]) / relative_settings_path
with settings_file.open() as f:
app_dict["settings"] = json.load(f)
relative_settings_path = Path(f"mobile/{app.app_code.lower()}/settings.json")
app_dict["url_settings"] = url_for(

Check warning on line 213 in backend/geonature/core/gn_commons/routes.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/core/gn_commons/routes.py#L212-L213

Added lines #L212 - L213 were not covered by tests
"media", filename=relative_settings_path, _external=True
)
settings_file = Path(current_app.config["MEDIA_FOLDER"]) / relative_settings_path
with settings_file.open() as f:
app_dict["settings"] = json.load(f)

Check warning on line 218 in backend/geonature/core/gn_commons/routes.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/core/gn_commons/routes.py#L216-L218

Added lines #L216 - L218 were not covered by tests
mobile_apps.append(app_dict)
if len(mobile_apps) == 1:
return mobile_apps[0]
Expand Down
10 changes: 6 additions & 4 deletions backend/geonature/core/gn_meta/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,12 @@ def _get_read_scope(self, user=None):
cruved = get_scopes_by_action(id_role=user.id_role, module_code="METADATA")
return cruved["R"]

def _get_create_scope(self, module_code, user=None):
def _get_create_scope(self, module_code, user=None, object_code=None):
if user is None:
user = g.current_user
cruved = get_scopes_by_action(id_role=user.id_role, module_code=module_code)
cruved = get_scopes_by_action(
id_role=user.id_role, module_code=module_code, object_code=object_code
)
return cruved["C"]

def filter_by_scope(self, scope, user=None):
Expand Down Expand Up @@ -366,14 +368,14 @@ def filter_by_readable(self, user=None):
"""
return self.filter_by_scope(self._get_read_scope(user))

def filter_by_creatable(self, module_code, user=None):
def filter_by_creatable(self, module_code, user=None, object_code=None):
"""
Return all dataset where user have read rights minus those who user to not have
create rigth
"""
query = self.filter(TDatasets.modules.any(module_code=module_code))
scope = self._get_read_scope(user)
create_scope = self._get_create_scope(module_code, user=user)
create_scope = self._get_create_scope(module_code, user=user, object_code=object_code)
if create_scope < scope:
scope = create_scope
return query.filter_by_scope(scope)
Expand Down
13 changes: 12 additions & 1 deletion backend/geonature/core/gn_meta/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
from werkzeug.datastructures import Headers
from geonature.core.gn_permissions import decorators as permissions
from geonature.core.gn_permissions.tools import get_scopes_by_action
from geonature.core.gn_permissions.models import TObjects
from geonature.core.gn_meta.mtd import mtd_utils
import geonature.utils.filemanager as fm
import geonature.utils.utilsmails as mail
Expand Down Expand Up @@ -99,15 +100,25 @@ def get_datasets():
.. :quickref: Metadata;

:query boolean active: filter on active fiel
:query string create: filter on C permission for the module_code specified
(we can specify the object_code by adding a . between both)
:query int id_acquisition_framework: get only dataset of given AF
:returns: `list<TDatasets>`
"""
params = MultiDict(request.args)
if request.is_json:
params.update(request.json)
fields = params.get("fields", type=str, default=[])
if fields:
fields = fields.split(",")
if "create" in params:
query = TDatasets.query.filter_by_creatable(params.pop("create"))
create = params.pop("create").split(".")
if len(create) > 1:
query = TDatasets.query.filter_by_creatable(
module_code=create[0], object_code=create[1]
)
else:
query = TDatasets.query.filter_by_creatable(module_code=create[0])
else:
query = TDatasets.query.filter_by_readable()

Expand Down
20 changes: 12 additions & 8 deletions backend/geonature/core/gn_meta/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,22 @@
def module_input(self, item, original, many, **kwargs):
if "modules" in item:
for i, module in enumerate(original.modules):
if not hasattr(module, "generate_input_url_for_dataset"):
continue
object_code = getattr(module.generate_input_url_for_dataset, "object_code", "ALL")

Check warning on line 73 in backend/geonature/core/gn_meta/schemas.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/core/gn_meta/schemas.py#L73

Added line #L73 was not covered by tests
create_scope = get_scopes_by_action(
id_role=g.current_user.id_role, module_code=module.module_code
id_role=g.current_user.id_role,
module_code=module.module_code,
object_code=object_code,
)["C"]
if not original.has_instance_permission(create_scope):
continue
if hasattr(module, "generate_input_url_for_dataset"):
item["modules"][i].update(
{
"input_url": module.generate_input_url_for_dataset(original),
"input_label": module.generate_input_url_for_dataset.label,
}
)
item["modules"][i].update(

Check warning on line 81 in backend/geonature/core/gn_meta/schemas.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/core/gn_meta/schemas.py#L81

Added line #L81 was not covered by tests
{
"input_url": module.generate_input_url_for_dataset(original),
"input_label": module.generate_input_url_for_dataset.label,
}
)
return item

# retro-compatibility with mobile app
Expand Down
1 change: 1 addition & 0 deletions backend/geonature/core/gn_synthese/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ class VSyntheseForWebApp(DB.Model):
unique_id_sinp = DB.Column(UUID(as_uuid=True))
unique_id_sinp_grp = DB.Column(UUID(as_uuid=True))
id_source = DB.Column(DB.Integer, nullable=False)
id_module = DB.Column(DB.Integer)
entity_source_pk_value = DB.Column(DB.Integer)
id_dataset = DB.Column(DB.Integer)
dataset_name = DB.Column(DB.Integer)
Expand Down
1 change: 1 addition & 0 deletions backend/geonature/core/gn_synthese/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@ def create_report(permissions):

synthese = Synthese.query.options(
Load(Synthese).raiseload("*"),
joinedload("nomenclature_sensitivity"),
joinedload("cor_observers"),
joinedload("digitiser"),
joinedload("dataset"),
Expand Down
9 changes: 5 additions & 4 deletions backend/geonature/core/gn_synthese/utils/query_select_sqla.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from geoalchemy2.shape import from_shape

from geonature.utils.env import DB

from geonature.core.gn_commons.models import TModules
from geonature.core.gn_synthese.models import (
CorObserverSynthese,
CorAreaSynthese,
Expand Down Expand Up @@ -372,17 +374,16 @@ def filter_other_filters(self, user):
self.query = self.query.where(self.model.id_dataset.in_(formated_datasets))
if "date_min" in self.filters:
self.query = self.query.where(self.model.date_min >= self.filters.pop("date_min"))

if "date_max" in self.filters:
# set the date_max at 23h59 because a hour can be set in timestamp
date_max = datetime.datetime.strptime(self.filters.pop("date_max"), "%Y-%m-%d")
date_max = date_max.replace(hour=23, minute=59, second=59)
self.query = self.query.where(self.model.date_max <= date_max)

if "id_source" in self.filters:
self.add_join(TSources, self.model.id_source, TSources.id_source)
self.query = self.query.where(self.model.id_source == self.filters.pop("id_source"))

self.query = self.query.where(self.model.id_source.in_(self.filters.pop("id_source")))
if "id_module" in self.filters:
self.query = self.query.where(self.model.id_module.in_(self.filters.pop("id_module")))
if "id_acquisition_framework" in self.filters:
if hasattr(self.model, "id_acquisition_framework"):
self.query = self.query.where(
Expand Down
Loading
Loading