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

Filter[Question]: Filter temporal data by user #4268

Closed
1 task done
BaBoWaGa opened this issue Mar 5, 2024 · 6 comments
Closed
1 task done

Filter[Question]: Filter temporal data by user #4268

BaBoWaGa opened this issue Mar 5, 2024 · 6 comments
Labels

Comments

@BaBoWaGa
Copy link

BaBoWaGa commented Mar 5, 2024

What is the question? (in English)

Hi, I have a time manager on a postGIS layer with daily start and end date. Is there a way to limit data display based on logged in user?
Example:
alpha user can see data from 1 to 5 March 2024
beta user can see data from February 1 to March 5, 2024
gamma user can see the entirety of the data

Lizmap 7.5 QGIS 3.28.15

Versions, safeguards, check summary etc

Lizmap 7.5 QGIS 3.28.15

Check Lizmap plugin

  • I have done the step just before in the Lizmap QGIS desktop plugin before opening this ticket. Otherwise, my ticket is not considered valid and might get closed.

Operating system

Windows 11

Browsers

Chrome

Browsers version

122.0.6261.95

Relevant log output

No response

@katagen
Copy link

katagen commented Mar 6, 2024

Did you check the documentation here ?

https://docs.lizmap.com/3.7/en/publish/lizmap_plugin/filtered_layers_login.html

@BaBoWaGa
Copy link
Author

BaBoWaGa commented Mar 7, 2024

Yes, thanks, I managed to do something by following those instructions, the only thing I didn't understand is how and if I can hide the display of some fields depending on the logged in user.

@Gustry
Copy link
Member

Gustry commented Mar 7, 2024

if I can hide the display of some fields depending on the logged in user.

It's not possible with Lizmap.
Maybe with some Javascript, but I doubt and it wouldn't be secure/safety because all the data will still be in the webbrowser.

@Gustry Gustry closed this as not planned Won't fix, can't repro, duplicate, stale Mar 7, 2024
@BaBoWaGa
Copy link
Author

BaBoWaGa commented Mar 7, 2024

Maybe with a script like this

layer = QgsProject.instance().mapLayersByName('Your_layer_name')[0]  # Make sure to replace 'Your_layer_name' with the actual name of your layer

# Check if the web user is in the lizmap_user and/or lizmap_user_groups list
web_user = 'web_username'  # Replace with the actual web user's name
user_group = 'user_group'  # Replace with the actual user's group name

# Check if the web user is in the lizmap_user list
if web_user in layer.customProperty("lizmap_user"):
    # If the web user is present, select the fields to display
    fields_to_display = ['field1', 'field2', 'field3']
else:
    # If the web user is not present, select a different set of fields to display
    fields_to_display = ['alternative_field1', 'alternative_field2']

# Update the display of fields in the layer
layer.setSubsetString('"field_name" IN {}'.format(tuple(fields_to_display)))

@Gustry
Copy link
Member

Gustry commented Mar 7, 2024

This is Python, so it can only run as a Python plugin for QGIS server.

@BaBoWaGa
Copy link
Author

Ok thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants