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

[feature] add map to admin's change list (WIP - DO NOT MERGE) #124

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

olivierdalang
Copy link

Hi,

This PR allows to display a map at top of admin's change list of LeafletGeoAdmins.

It's a quick draft and I'm new to Django, so it's not ready for merge and needs review.

Please let me know what you think.

geoadmin

Features

  • single click : user can select entries both on the map and on the list (synced)
  • double click : opens the entry's change page.

How it works

It works by setting LeafletGeoAdmin's change_list_template to a custom template which features a map before the list.
The map knows which field to use to display the features thanks to a new list_geom_field parameter on LeafletGeoAdmin. By default, it's set to None, in which case no map is displayed.

How to use

class MyAdmin(LeafletGeoAdmin):
    ...
    list_geom_field = 'mygeomfieldname'
    ...

To do

  • Test without grappelli
  • Add a visible message when not all entities are show (pagination)
  • Allow click to work when show for a raw foreign key lookup
  • Cleanup the selection hack (so that it works with select all for instance)
  • Allow to completely replace the change list
  • Support of labels, popups, etc.
  • Customise click events
  • One day : display inlines as a map too
  • One day : allow to edit in place

@@ -55,3 +56,6 @@ class LeafletMap(self.widget):
map_height = self.map_height
display_raw = self.display_raw
return LeafletMap


change_list_template = 'leaflet/admin/change_list_geo.html'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is a rather radical change, I would do another admin class instead, at least the time to stabilize the whole thing

@@ -0,0 +1,99 @@
{% extends 'admin/change_list.html' %}
{% load leaflet_tags %}
{% load admin_list_leaflet %}
Copy link

Choose a reason for hiding this comment

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

Hi,
This file "admin_list_leaflet" haven’t in the commit and templatetags. Where does it come from? I am interested in this feature, it’s a good idea.
Thanks

Copy link
Author

Choose a reason for hiding this comment

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

Hi,
I'm not sure anymore (didn't look at it for some time), maybe it was a mistake ? did you try to remove that line ?

Copy link

Choose a reason for hiding this comment

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

I just doing the test,

  • I with an error : 'admin_list_leaflet' is not a valid tag library: Template library admin_list_leaflet not found, tried
  • Without no menus and no layer
    nolistmapadmin

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

Successfully merging this pull request may close these issues.

3 participants