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

Add the exclusive keyword #45

Merged
merged 11 commits into from
Dec 9, 2024
Merged

Add the exclusive keyword #45

merged 11 commits into from
Dec 9, 2024

Conversation

mattiagiupponi
Copy link
Contributor

ref #44

@mattiagiupponi mattiagiupponi self-assigned this Nov 19, 2024
@mattiagiupponi mattiagiupponi linked an issue Nov 19, 2024 that may be closed by this pull request
@gannebamm
Copy link

Thanks for the fast work @mattiagiupponi !
We have deployed the changes and it is starting properly. @vineetasharma105 is currently reviewing its functionality.

@vineetasharma105
Copy link

The keyword - 'Subsite_exclusive' is working for documents, maps, datasets!!

@mattiagiupponi
Copy link
Contributor Author

The keyword - 'Subsite_exclusive' is working for documents, maps, datasets!!

great!

Thanks for the fast work @mattiagiupponi ! We have deployed the changes and it is starting properly. @vineetasharma105 is currently reviewing its functionality.

@gannebamm please let me know when your tests are done so I can merge the PR

@vineetasharma105
Copy link

Hi,
I am facing a question when dealing with subsite exclusive contents.
Question : Why the subsite exclusive contents , redirected via the linked resources click, still points towards and redirects to the homepage of geonode and the user is not anymore on the subsite page?
Enhancement/Requirement : as a user and as an admin also, the linked resources should not redirect to the homepage and rather stay on the subsite page, as the contents are 'subsite specific'.

As can be seen in the screen shot, the map (subsite_exclusive_test_map) and its related data set (subsite_exclusive_test_data)
image are part of Holisoils subsite and the keyword and the group is set up accordingly. Still , the linked resources links points to the homepage.
Map : https://geonode-demo.thuenen.de/holisoils/catalogue/uuid/20e4d7c5-09fd-46ab-843b-f1bbb4bfee8d
dataset : https://geonode-demo.thuenen.de/catalogue/uuid/ac3361f8-8299-43de-a4f7-20d51a6c7c01
Subsitelink: https://geonode-demo.thuenen.de/holisoils/#/

@mattiagiupponi
Copy link
Contributor Author

Hi @gannebamm @vineetasharma105
With the new push the resources in the linked resource are now pointing to the subsite instead of the main catalogue page.
NOTE: it might be redundant to say, but the resource in the map MUST be part of the subsite in order to be saw via the linked_resource link

@gannebamm
Copy link

I just deployed the changes and they do not work as intended, yet.

See: https://geonode-demo.thuenen.de/holisoils/catalogue/uuid/6e60d107-3643-4ce5-9482-e098ad4e9305

The map is subsite exlusive, belongs to the holisoils group and uses only subsite ressources. It seems all ressources which are subsite_exclusive currently fail with: [ "Subsite not found" ] for a request like https://geonode-demo.thuenen.de/de-de/api/v2/datasets/22?api_preset=viewer_common&api_preset=dataset_viewer

We used these subsite specific variables:

# SUBSITE SPECIFIC CONFIGURATION
ENABLE_SUBSITE_CUSTOM_THEMES = True
ENABLE_CATALOG_HOME_REDIRECTS_TO = False
SUBSITE_READ_ONLY = False # return download_resourcebase and view resourcebase as permissions
SUBSITE_HIDE_EXCLUSIVE_FROM_SPECIFIC_API = True # If TRUE will hide the `subsite_exclusive` resources also from the detailed endpoint `/documents`, `/maps`, `/datasets`, '/geoapps`

The code is using 270c349

Did we misconfigure something?

@mattiagiupponi
Copy link
Contributor Author

Can you try by set SUBSITE_HIDE_EXCLUSIVE_FROM_SPECIFIC_API = False ?

@gannebamm
Copy link

gannebamm commented Nov 25, 2024

redeployed.

Can you try by set SUBSITE_HIDE_EXCLUSIVE_FROM_SPECIFIC_API = False ?

This will fix the [ "Subsite not found" ] issue but the links still point to the main portal.

https://geonode-demo.thuenen.de/holisoils/catalogue/#/maps?d=57%3Bmap

@mattiagiupponi
Copy link
Contributor Author

uhm is working fine on my test environment with or without that variable, i'll give another check soon

@gannebamm
Copy link

Just as additional info:
We use this deployment https://github.com/Thuenen-GeoNode-Development/thuenen_atlas/tree/subsite_exclusive_test
Which is based on the docker blueprint plus some of our contrib apps. It will use the subsite dev branch as listed here: Thuenen-GeoNode-Development/thuenen_atlas@4183280

@mattiagiupponi
Copy link
Contributor Author

mattiagiupponi commented Nov 27, 2024

Hi @gannebamm
I made some local test using the project you linked and as you mentioned, the linked resources still point the main catalogue:
image

But the API v2 is returning the linked resources as expected by adding the subsite:

image

While on my local instance using geonode-master and mapstore-client-master is working as expected:

image

I notice that the mapstore-client used by the project, is a fork of the 52north mapstore client fork which is about 20 commits behind the production one for GeoNode 4.3.x which also includes improvement for the linked resources (GeoNode/geonode-mapstore-client@c7f6d10)

Can you please evaluate to upgrade the mapstore client and align it to the GeoNode one? So we can have the same environment.

@mattiagiupponi
Copy link
Contributor Author

As counterproof, i run a geonode 433 on my local instance and the subsite is correctly used for the linked resources:
image

@gannebamm
Copy link

@mattiagiupponi Thank you very much for the in-depth look! Yes, we will upgrade soon. See: Thuenen-GeoNode-Development/thuenen_atlas#58 (comment)

@gannebamm
Copy link

gannebamm commented Nov 28, 2024

We have deployed a new version and most parts of the feature do work well but ressources with subsite_exclusive keyword will fail with the known [ "Subsite not found" ] error. See:

https://geonode-demo.thuenen.de/holisoils/catalogue/#/?d=36%3Bdataset%3Bvector

If SUBSITE_HIDE_EXCLUSIVE_FROM_SPECIFIC_API = False they will render. Can you please take a look again @mattiagiupponi

additional info: We have updated to 4.4.x and use this (https://github.com/Thuenen-GeoNode-Development/thuenen_atlas) branch for deployment

@ridoo
Copy link
Contributor

ridoo commented Nov 28, 2024

@mattiagiupponi A quick test turns out that there are different URLs in the Add Resource drop down depending on either opening subsite root http://172.18.0.1:8001/holisoils/ or the catalogue http://172.18.0.1:8001/holisoils/catalogue/. The subsite root point to http://172.18.0.1:8001/holisoils/catalogue/#/map/new and the subsite's catalogue points to http://172.18.0.1:8001/catalogue/#/map/new instead.

Also, what I can see from the Django Logs (not sure if this is related):

WARNING Forbidden: /api/v2/executionrequest
WARNING Forbidden: /api/v2/executionrequest
WARNING "GET /api/v2/executionrequest?filter%7Baction%7D=import&filter%7Bsource%7D=upload&page=1&page_size=99999 HTTP/1.1" 403 103
WARNING "GET /api/v2/executionrequest?filter%7Baction%7D=import&filter%7Bsource%7D=upload&page=1&page_size=99999 HTTP/1.1" 403 103

However, creating a map starting from subsite's catalogue will create a map but redirect (http://172.18.0.1:8001/holisoils/api/v2/maps/9/?api_preset=viewer_common&api_preset=map_viewer) fails with 404. Maps are available from the main portal.

@gannebamm I did not spot errors like [ "Subsite not found" ]. Which component is logging such errors?

These were my testing config:

ENABLE_SUBSITE_CUSTOM_THEMES = True
ENABLE_CATALOG_HOME_REDIRECTS_TO = False
SUBSITE_READ_ONLY = False
SUBSITE_HIDE_EXCLUSIVE_FROM_SPECIFIC_API = False  # tried also True with no different in the described behaviour

@gannebamm
Copy link

gannebamm commented Nov 29, 2024

@ridoo We are currently working on the subsite_exclusive feature. This has currently no effect on creating new ressources on the subsite. In our workflow ressources are added by main portals staff via the main portal (atlas in our case). They will be tagged with the keyword subsite_exclusive to only show on the subsite, if they are project specific and not data created by ourselves. For that we need them to not show up in the main catalogue (works) but show up in the subsite catalogue (works) and showing correct links on the subsite for linked ressources (also works). But they still show up on the main portals API if SUBSITE_HIDE_EXCLUSIVE_FROM_SPECIFIC_API = False. If we change this to SUBSITE_HIDE_EXCLUSIVE_FROM_SPECIFIC_API = True they will not show up in the main portals API, but the rendering of ressource panels is broken.

I did not spot errors like [ "Subsite not found" ]. Which component is logging such errors?

It is a mapstore call to fetch info for the ressource info panel. See this:

If you do the same request for a dataset on the subsite which is not tagged as subsite_exclusive it will render properly. See:

{
    "dataset": {
        "uuid": "0ea54778-63a2-4bf9-b684-51d41e29f1a9",
        "default_style": {
            "pk": 14,
            "name": "ph_30_100",
            "workspace": "geonode",
            "sld_title": "ph_30_100",
            "sld_url": "https://geonode-demo.thuenen.de/geoserver/rest/workspaces/geonode/styles/ph_30_100.sld"
        }
        // [... whole API v2 response ...]
    }
}

the main portals API will properly hide subsite exclusive datasets:
https://geonode-demo.thuenen.de/api/v2/datasets/

while the subsite will show those:
https://geonode-demo.thuenen.de/holisoils/api/v2/datasets/

@mattiagiupponi
Copy link
Contributor Author

Hi @gannebamm @ridoo
Sorry but i was submerged with other tasks, today I'll take a look on your questions.

If SUBSITE_HIDE_EXCLUSIVE_FROM_SPECIFIC_API = False they will render. Can you please take a look again @mattiagiupponi

I'm going to take a look now.

@mattiagiupponi
Copy link
Contributor Author

mattiagiupponi commented Nov 29, 2024

Hi @gannebamm
The last push should fix the issue related to the visualization of the resources inside a subsite. Even with SUBSITE_HIDE_EXCLUSIVE_FROM_SPECIFIC_API = True it should be rendered correctly now
Can you please verify?

soon i'll check the add resource issue pointed out by @ridoo

@gannebamm
Copy link

The last push should fix the issue related to the visualization of the resources inside a subsite. Even with SUBSITE_HIDE_EXCLUSIVE_FROM_SPECIFIC_API = True it should be rendered correctly now
Can you please verify?

We are currently starting the review. First look is promising and the issue with subsite exclusive ressources like

seems to be solved

@gannebamm
Copy link

@mattiagiupponi can you please double check if this is related: Thuenen-GeoNode-Development/thuenen_atlas#58 (comment)

@mattiagiupponi
Copy link
Contributor Author

@mattiagiupponi can you please double check if this is related: Thuenen-GeoNode-Development/thuenen_atlas#58 (comment)

i'll check and i'll let you know soon

@mattiagiupponi
Copy link
Contributor Author

@mattiagiupponi can you please double check if this is related: Thuenen-GeoNode-Development/thuenen_atlas#58 (comment)

there was a missing slash in the beginning of the URL, so for the remote service was appending the embed url to the main one instead of recreating one. now should be fixed. please try again

@mattiagiupponi
Copy link
Contributor Author

@mattiagiupponi A quick test turns out that there are different URLs in the Add Resource drop down depending on either opening subsite root http://172.18.0.1:8001/holisoils/ or the catalogue http://172.18.0.1:8001/holisoils/catalogue/. The subsite root point to http://172.18.0.1:8001/holisoils/catalogue/#/map/new and the subsite's catalogue points to http://172.18.0.1:8001/catalogue/#/map/new instead.

I'm trying to replicate this, but it looks like is working as expected, only the remote-services are pointing to the main site root. as an instance:
issue_subsite

Could be this issue related to my previous comment? #45 (comment) Can you please try with an updated version of GeoNode?
Anyway i'm going to check and fix the remote service that points to the main site.

Im also going to verify this:

Also, what I can see from the Django Logs (not sure if this is related):

The upload from the subsite works fine to me, no 403 are returned. It could always be related to the GeoNode version (i guess)
image

Can you confirm @ridoo ?

@ridoo
Copy link
Contributor

ridoo commented Dec 3, 2024

Hey @mattiagiupponi

Could be this issue related to my previous comment? #45 (comment) Can you please try with an updated version of GeoNode?

The version we use should be up to date (more or less) with v4.4.x. Of course, we made customizations.

I tested again and seems that your local overrides did not have any effect. We also provide an overrideLocalConfig in a _geonode_config.html and we should make sure to not only let the last one take precedence. It would be good to provide a recursive handling of all overrideLocalConfigs. I made it work via this configuration:

{% extends 'geonode-mapstore-client/_geonode_config.html' %}
{% block override_local_config %}

{% comment %} Keep the overrides from other apps {% endcomment %}
{{ block.super }}

<script>
const { overrideLocalConfig } = window.__GEONODE_CONFIG__;
window.__GEONODE_CONFIG__.overrideLocalConfig = function(localConfig, _) {

    if (overrideLocalConfig) {
        overrideLocalConfig(localConfig, _)
    }


    // do actual override

    return localConfig;

}

</script>
{% endblock %}

If you think, this make sense, I can create a pull request for geonode-mapstore-client.

@mattiagiupponi
Copy link
Contributor Author

Hi @ridoo sorry but today i was busy since yesterday i was OOO.
I'll tag @allyoucanmap and @dsuren1 just to make them provide their opinion on this.

@ridoo
Copy link
Contributor

ridoo commented Dec 5, 2024

@mattiagiupponi no problem, I hope you enjoyed your free time :)

I referenced my suggestion in another issue. So if @gannebamm tested successfully this one could be merged IMO (did not find any issues, though, I tested this one not thoroughly).

@mattiagiupponi
Copy link
Contributor Author

@mattiagiupponi no problem, I hope you enjoyed your free time :)

I referenced my suggestion in another issue. So if @gannebamm tested successfully this one could be merged IMO (did not find any issues, though, I tested this one not thoroughly).

I agree, is better to keep this kind of improvment for later, when it can be well tested in case.
If for @gannebamm everything looks fine, we can merge this PR

@gannebamm
Copy link

@vineetasharma105 Did you encounter any issues with our latest build? For me it is working well and I would give it a go for merging.

@gannebamm
Copy link

Hi @mattiagiupponi,
we can assure that the feature is working fine for master. I just tested it locally. For 4.4.x everything works except uploading a dataset from the subsite. You demo in comment #45 (comment) is using the master branch (you can spot it on the uploaded page with the new css applied). For 4.4.x the route https://geonode-demo.thuenen.de/holisoils/api/v2/uploads is not working.

For our use case it is not important, since we will upload ressources from the maint page and not via the subsite. In terms of code quality it maybe should get fixed. On the other hand, it is working fine on master 🤷

@mattiagiupponi
Copy link
Contributor Author

Hi @mattiagiupponi, we can assure that the feature is working fine for master. I just tested it locally. For 4.4.x everything works except uploading a dataset from the subsite. You demo in comment #45 (comment) is using the master branch (you can spot it on the uploaded page with the new css applied). For 4.4.x the route https://geonode-demo.thuenen.de/holisoils/api/v2/uploads is not working.

For our use case it is not important, since we will upload ressources from the maint page and not via the subsite. In terms of code quality it maybe should get fixed. On the other hand, it is working fine on master 🤷

Thanks for spotting it.
With the last commit e2abe20 now the "Add resource" in the subsite works as expected in 44x.
If there are no more bugs and if you give the green line i'll merge the PR :) (feel free to approve it too!)

@mattiagiupponi mattiagiupponi merged commit f1fcd4f into main Dec 9, 2024
@gannebamm
Copy link

Just for the record: We successfully tested the PR 👍

@mattiagiupponi mattiagiupponi deleted the subsite_exclusive branch December 9, 2024 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exclusive keyword
4 participants