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 edit_url and layers_url attribute into initial client API response (ref: group-project-map-config) #706

Merged
merged 7 commits into from
Jan 25, 2024

Conversation

Raruto
Copy link
Contributor

@Raruto Raruto commented Jan 9, 2024

Motivation

  1. See: Link to the edit project page g3w-client#391

  2. improve #503 without requiring client to perform a subsequent to another API endpoint to get the edit_url of current project (ie: throught about-project-by-group-api-list you can actually gets the edit_url of all projects within the same group, somewhat resource expensive.. ⌛)

Sample Response

// GET http:https://localhost:8000/api/config/2/qdjango/3?_t=1703148279.973667

{
  "id": 3,
  "name": "Public building management Demo",
  "layerstree": [ ... ],
  "thumbnail": null,
  "wms_use_layer_ids": true,
  "qgis_version": "3.28.4-Firenze",
  "toc_layers_init_status": "not_collapsed",
  "toc_themes_init_status": "collapsed",
  "wms_getmap_format": "image/png; mode=8bit",
  "initextent": [...],
  "extent": [...],
  "print": [...],
  "layers": [...],
  "search": [],
  "widget": [],
  "relations": [...],
  "initbaselayer": null,
  "metadata": {...},
  "context_base_legend": true,
  "feature_count": 5,
  "querymultilayers": [...],
  "autozoom_query": false,
  "toc_tab_default": "layers",
  "legend_position": "tab",
  "ows_method": "GET",
  "html_page_title": "g3w - client | Public building management Demo",
  "search_endpoint": "ows",
  "bookmarks": [...],
  "map_themes": [...],
  "messages": {...},
  "edit_url": "/en/admin/qdjango/3857/projects/update/public-building-management-demo/" // <-- ADDED
  "layers_url": "/en/admin/qdjango/3857/projects/public-building-management-demo/layers/" // <-- ADDED
}

Related to: g3w-suite/g3w-client#392

@Raruto Raruto added the feature New feature or request label Jan 9, 2024
@Raruto Raruto changed the title Add edit_url attribute into intial client API response (ref: group-project-map-config) Add edit_url attribute into initial client API response (ref: group-project-map-config) Jan 9, 2024
@Raruto Raruto changed the title Add edit_url attribute into initial client API response (ref: group-project-map-config) Add edit_url and layers_url attribute into initial client API response (ref: group-project-map-config) Jan 9, 2024
Comment on lines +602 to +615
# add edit url if user has grant
if self.request.user.has_perm('qdjango.change_project', instance):
ret['edit_url'] = reverse('qdjango-project-update', kwargs={
'group_slug': instance.group.slug,
'slug': instance.slug
})

# add layers url if user has grant
if self.request.user.has_perm('qdjango.change_project', instance):
ret['layers_url'] = reverse('qdjango-project-layers-list', kwargs={
'group_slug': instance.group.slug,
'project_slug': instance.slug
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wlorenzetti @volterra79 if you have better property names, just say...

@wlorenzetti wlorenzetti merged commit ed1a9d4 into dev Jan 25, 2024
4 checks passed
@wlorenzetti wlorenzetti deleted the project-edit-url branch January 25, 2024 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants