umap-project 1.3.7__py3-none-any.whl → 1.4.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of umap-project might be problematic. Click here for more details.

Files changed (134) hide show
  1. umap/__init__.py +1 -1
  2. umap/locale/am_ET/LC_MESSAGES/django.mo +0 -0
  3. umap/locale/am_ET/LC_MESSAGES/django.po +79 -30
  4. umap/locale/ar/LC_MESSAGES/django.mo +0 -0
  5. umap/locale/ar/LC_MESSAGES/django.po +166 -96
  6. umap/locale/bg/LC_MESSAGES/django.mo +0 -0
  7. umap/locale/bg/LC_MESSAGES/django.po +79 -30
  8. umap/locale/br/LC_MESSAGES/django.mo +0 -0
  9. umap/locale/br/LC_MESSAGES/django.po +460 -0
  10. umap/locale/ca/LC_MESSAGES/django.mo +0 -0
  11. umap/locale/ca/LC_MESSAGES/django.po +95 -45
  12. umap/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
  13. umap/locale/cs_CZ/LC_MESSAGES/django.po +80 -31
  14. umap/locale/da/LC_MESSAGES/django.mo +0 -0
  15. umap/locale/da/LC_MESSAGES/django.po +80 -31
  16. umap/locale/de/LC_MESSAGES/django.mo +0 -0
  17. umap/locale/de/LC_MESSAGES/django.po +80 -31
  18. umap/locale/el/LC_MESSAGES/django.mo +0 -0
  19. umap/locale/el/LC_MESSAGES/django.po +87 -38
  20. umap/locale/en/LC_MESSAGES/django.po +75 -26
  21. umap/locale/es/LC_MESSAGES/django.mo +0 -0
  22. umap/locale/es/LC_MESSAGES/django.po +80 -31
  23. umap/locale/et/LC_MESSAGES/django.mo +0 -0
  24. umap/locale/et/LC_MESSAGES/django.po +80 -31
  25. umap/locale/eu/LC_MESSAGES/django.mo +0 -0
  26. umap/locale/eu/LC_MESSAGES/django.po +457 -0
  27. umap/locale/fa_IR/LC_MESSAGES/django.mo +0 -0
  28. umap/locale/fa_IR/LC_MESSAGES/django.po +80 -31
  29. umap/locale/fi/LC_MESSAGES/django.mo +0 -0
  30. umap/locale/fi/LC_MESSAGES/django.po +79 -30
  31. umap/locale/fr/LC_MESSAGES/django.mo +0 -0
  32. umap/locale/fr/LC_MESSAGES/django.po +82 -33
  33. umap/locale/gl/LC_MESSAGES/django.mo +0 -0
  34. umap/locale/gl/LC_MESSAGES/django.po +80 -31
  35. umap/locale/he/LC_MESSAGES/django.mo +0 -0
  36. umap/locale/he/LC_MESSAGES/django.po +80 -31
  37. umap/locale/hr/LC_MESSAGES/django.mo +0 -0
  38. umap/locale/hr/LC_MESSAGES/django.po +77 -28
  39. umap/locale/hu/LC_MESSAGES/django.mo +0 -0
  40. umap/locale/hu/LC_MESSAGES/django.po +80 -31
  41. umap/locale/is/LC_MESSAGES/django.mo +0 -0
  42. umap/locale/is/LC_MESSAGES/django.po +80 -31
  43. umap/locale/it/LC_MESSAGES/django.mo +0 -0
  44. umap/locale/it/LC_MESSAGES/django.po +80 -31
  45. umap/locale/ja/LC_MESSAGES/django.mo +0 -0
  46. umap/locale/ja/LC_MESSAGES/django.po +80 -31
  47. umap/locale/ko/LC_MESSAGES/django.mo +0 -0
  48. umap/locale/ko/LC_MESSAGES/django.po +80 -31
  49. umap/locale/lt/LC_MESSAGES/django.mo +0 -0
  50. umap/locale/lt/LC_MESSAGES/django.po +79 -30
  51. umap/locale/ms/LC_MESSAGES/django.mo +0 -0
  52. umap/locale/ms/LC_MESSAGES/django.po +85 -36
  53. umap/locale/nl/LC_MESSAGES/django.mo +0 -0
  54. umap/locale/nl/LC_MESSAGES/django.po +80 -31
  55. umap/locale/pl/LC_MESSAGES/django.mo +0 -0
  56. umap/locale/pl/LC_MESSAGES/django.po +80 -31
  57. umap/locale/pt/LC_MESSAGES/django.mo +0 -0
  58. umap/locale/pt/LC_MESSAGES/django.po +80 -31
  59. umap/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
  60. umap/locale/pt_BR/LC_MESSAGES/django.po +80 -31
  61. umap/locale/pt_PT/LC_MESSAGES/django.mo +0 -0
  62. umap/locale/pt_PT/LC_MESSAGES/django.po +80 -31
  63. umap/locale/ru/LC_MESSAGES/django.mo +0 -0
  64. umap/locale/ru/LC_MESSAGES/django.po +80 -31
  65. umap/locale/si/LC_MESSAGES/django.mo +0 -0
  66. umap/locale/si/LC_MESSAGES/django.po +456 -0
  67. umap/locale/sk_SK/LC_MESSAGES/django.mo +0 -0
  68. umap/locale/sk_SK/LC_MESSAGES/django.po +79 -30
  69. umap/locale/sl/LC_MESSAGES/django.mo +0 -0
  70. umap/locale/sl/LC_MESSAGES/django.po +79 -30
  71. umap/locale/sr/LC_MESSAGES/django.mo +0 -0
  72. umap/locale/sr/LC_MESSAGES/django.po +80 -31
  73. umap/locale/sv/LC_MESSAGES/django.mo +0 -0
  74. umap/locale/sv/LC_MESSAGES/django.po +80 -31
  75. umap/locale/th_TH/LC_MESSAGES/django.mo +0 -0
  76. umap/locale/th_TH/LC_MESSAGES/django.po +80 -31
  77. umap/locale/tr/LC_MESSAGES/django.mo +0 -0
  78. umap/locale/tr/LC_MESSAGES/django.po +80 -31
  79. umap/locale/uk_UA/LC_MESSAGES/django.mo +0 -0
  80. umap/locale/uk_UA/LC_MESSAGES/django.po +80 -31
  81. umap/locale/vi/LC_MESSAGES/django.mo +0 -0
  82. umap/locale/vi/LC_MESSAGES/django.po +79 -30
  83. umap/locale/zh/LC_MESSAGES/django.mo +0 -0
  84. umap/locale/zh/LC_MESSAGES/django.po +79 -30
  85. umap/locale/zh_TW/LC_MESSAGES/django.mo +0 -0
  86. umap/locale/zh_TW/LC_MESSAGES/django.po +94 -45
  87. umap/models.py +7 -7
  88. umap/settings/base.py +3 -1
  89. umap/static/umap/content.css +23 -0
  90. umap/static/umap/img/16-white.svg +6 -4
  91. umap/static/umap/img/16.svg +5 -3
  92. umap/static/umap/img/source/16-white.svg +7 -5
  93. umap/static/umap/img/source/16.svg +6 -4
  94. umap/static/umap/js/umap.controls.js +55 -52
  95. umap/static/umap/js/umap.features.js +14 -0
  96. umap/static/umap/js/umap.js +6 -7
  97. umap/static/umap/js/umap.layer.js +2 -2
  98. umap/static/umap/js/umap.permissions.js +3 -3
  99. umap/static/umap/js/umap.ui.js +1 -1
  100. umap/static/umap/locale/br.js +404 -0
  101. umap/static/umap/locale/br.json +402 -0
  102. umap/static/umap/locale/{si_LK.js → eu.js} +18 -18
  103. umap/static/umap/locale/{si_LK.json → eu.json} +16 -16
  104. umap/static/umap/locale/ms.js +5 -5
  105. umap/static/umap/locale/ms.json +5 -5
  106. umap/static/umap/locale/si.js +404 -0
  107. umap/static/umap/locale/si.json +402 -0
  108. umap/static/umap/locale/zh_TW.js +35 -35
  109. umap/static/umap/locale/zh_TW.json +35 -35
  110. umap/static/umap/map.css +6 -6
  111. umap/static/umap/vendors/formbuilder/Leaflet.FormBuilder.js +6 -5
  112. umap/static/umap/vendors/leaflet/leaflet-src.esm.js +1964 -1323
  113. umap/static/umap/vendors/leaflet/leaflet-src.esm.js.map +1 -1
  114. umap/static/umap/vendors/leaflet/leaflet-src.js +14478 -13836
  115. umap/static/umap/vendors/leaflet/leaflet-src.js.map +1 -1
  116. umap/static/umap/vendors/leaflet/leaflet.css +70 -44
  117. umap/static/umap/vendors/leaflet/leaflet.js +4 -3
  118. umap/static/umap/vendors/leaflet/leaflet.js.map +1 -1
  119. umap/templates/umap/login_popup_end.html +1 -1
  120. umap/templates/umap/map_table.html +41 -0
  121. umap/templates/umap/navigation.html +1 -1
  122. umap/templates/umap/search.html +1 -1
  123. umap/templates/umap/search_bar.html +5 -3
  124. umap/templates/umap/user_dashboard.html +23 -0
  125. umap/tests/test_views.py +21 -0
  126. umap/urls.py +5 -0
  127. umap/views.py +55 -42
  128. {umap_project-1.3.7.dist-info → umap_project-1.4.1.dist-info}/METADATA +1 -1
  129. {umap_project-1.3.7.dist-info → umap_project-1.4.1.dist-info}/RECORD +132 -122
  130. umap/locale/si_LK/LC_MESSAGES/django.mo +0 -0
  131. umap/locale/si_LK/LC_MESSAGES/django.po +0 -376
  132. {umap_project-1.3.7.dist-info → umap_project-1.4.1.dist-info}/WHEEL +0 -0
  133. {umap_project-1.3.7.dist-info → umap_project-1.4.1.dist-info}/entry_points.txt +0 -0
  134. {umap_project-1.3.7.dist-info → umap_project-1.4.1.dist-info}/licenses/LICENSE +0 -0
@@ -6,7 +6,7 @@
6
6
  window.opener.umap_proceed()
7
7
  } else {
8
8
  // Trade off as Twitter does not allow us to access window.opener
9
- window.location.href = '{{ request.user.get_url }}'
9
+ window.location.href = '{% url "user_dashboard" %}'
10
10
  }
11
11
  }
12
12
 
@@ -0,0 +1,41 @@
1
+ {% load umap_tags umap_tags i18n %}
2
+ <table class="maps">
3
+ {% if not is_ajax %}
4
+ <thead>
5
+ <tr>
6
+ <th>{% blocktrans %}Map{% endblocktrans %}</th>
7
+ <th>{% blocktrans %}Name{% endblocktrans %}</th>
8
+ <th>{% blocktrans %}Who can see / edit{% endblocktrans %}</th>
9
+ <th>{% blocktrans %}Last save{% endblocktrans %}</th>
10
+ <th>{% blocktrans %}Owner{% endblocktrans %}</th>
11
+ <th>{% blocktrans %}Actions{% endblocktrans %}</th>
12
+ </tr>
13
+ </thead>
14
+ {% endif %}
15
+ <tbody>
16
+ {% for map_inst in maps %}
17
+ <tr>
18
+ <td>{% map_fragment map_inst prefix=prefix page=request.GET.p %}</td>
19
+ <td>
20
+ <a href="{{ map_inst.get_absolute_url }}">{{ map_inst.name }}</a>
21
+ </td>
22
+ <td>{{ map_inst.get_share_status_display }} / {{ map_inst.get_edit_status_display }}</td>
23
+ <td>{{ map_inst.modified_at }}</td>
24
+ <td>
25
+ <a href="{{ map_inst.owner.get_url }}">{{ map_inst.owner }}</a>
26
+ </td>
27
+ <td>
28
+ <a href="{{ map_inst.get_absolute_url }}?share">{% translate "Share" %}</a>
29
+ <a href="{{ map_inst.get_absolute_url }}?edit">{% translate "Edit" %}</a>
30
+ <a href="{{ map_inst.get_absolute_url }}?download">{% translate "Download" %}</a>
31
+ </td>
32
+ </tr>
33
+ {% endfor %}
34
+ </tbody>
35
+ </table>
36
+ {% if maps.has_next %}
37
+ <div class="col wide">
38
+ <a href="?{% paginate_querystring maps.next_page_number %}"
39
+ class="button more_button neutral">{% trans "More" %}</a>
40
+ </div>
41
+ {% endif %}
@@ -9,7 +9,7 @@
9
9
  <ul>
10
10
  {% if user.is_authenticated %}
11
11
  <li>
12
- <a href="{{ user.get_url }}">{% trans "My maps" %} ({{ user }})</a>
12
+ <a href="{% url 'user_dashboard' %}">{% trans "My maps" %} ({{ user }})</a>
13
13
  </li>
14
14
  <li>
15
15
  <a href="{{ user.get_stars_url }}">{% trans "Starred maps" %}</a>
@@ -4,7 +4,7 @@
4
4
  {% include "umap/search_bar.html" %}
5
5
  <div class="wrapper">
6
6
  <div class="map_list row">
7
- {% if q %}
7
+ {% if request.GET.q %}
8
8
  {% if maps %}
9
9
  <h2>
10
10
  {% blocktranslate trimmed count counter=count %}
@@ -1,12 +1,14 @@
1
1
  {% load i18n %}
2
+ {% url "search" as search_url %}
3
+ {% trans "Search maps" as default_placeholder %}
2
4
  <div class="wrapper search_wrapper">
3
5
  <div class="row">
4
- <form action="{% url "search" %}" method="get">
6
+ <form action="{% firstof action search_url %}" method="get">
5
7
  <div class="col two-third mwide">
6
8
  <input name="q"
7
9
  type="search"
8
- placeholder="{% trans "Search maps" %}"
9
- value="{{ q|default:"" }}" />
10
+ placeholder="{% firstof placeholder default_placeholder %}"
11
+ value="{{ request.GET.q|default:"" }}" />
10
12
  </div>
11
13
  <div class="col third mwide">
12
14
  <input type="submit" value="{% trans "Search" %}" class="neutral" />
@@ -0,0 +1,23 @@
1
+ {% extends "umap/content.html" %}
2
+ {% load i18n %}
3
+ {% block head_title %}
4
+ {{ SITE_NAME }} - {% trans "My dashboard" %}
5
+ {% endblock head_title %}
6
+ {% block maincontent %}
7
+ {% trans "Search my maps" as placeholder %}
8
+ <div class="col wide">
9
+ <h2 class="section">{% trans "My dashboard" %}</h2>
10
+ {% include "umap/search_bar.html" with action=request.get_full_path placeholder=placeholder %}
11
+ </div>
12
+ <div class="wrapper">
13
+ <div class="row">
14
+ {% if maps %}
15
+ {% include "umap/map_table.html" %}
16
+ {% else %}
17
+ <div>
18
+ {% blocktrans %}You have no map yet.{% endblocktrans %} <a href="{% url 'map_new' %}">{% translate "Create a map" %}</a>
19
+ </div>
20
+ {% endif %}
21
+ </div>
22
+ </div>
23
+ {% endblock maincontent %}
umap/tests/test_views.py CHANGED
@@ -240,3 +240,24 @@ def test_change_user_slug(client, user, settings):
240
240
  settings.USER_URL_FIELD = "pk"
241
241
  response = client.get(reverse("home"))
242
242
  assert f"/en/user/{user.pk}/" in response.content.decode()
243
+
244
+
245
+ @pytest.mark.django_db
246
+ def test_user_dashboard_is_restricted_to_logged_in(client):
247
+ response = client.get(reverse("user_dashboard"))
248
+ assert response.status_code == 302
249
+ assert response["Location"] == "/en/login/?next=/en/me"
250
+
251
+
252
+ @pytest.mark.django_db
253
+ def test_user_dashboard_display_user_maps(client, map):
254
+ client.login(username=map.owner.username, password="123123")
255
+ response = client.get(reverse("user_dashboard"))
256
+ assert response.status_code == 200
257
+ body = response.content.decode()
258
+ assert map.name in body
259
+ assert f"{map.get_absolute_url()}?edit" in body
260
+ assert f"{map.get_absolute_url()}?share" in body
261
+ assert f"{map.get_absolute_url()}?download" in body
262
+ assert "Everyone (public)" in body
263
+ assert "Owner only" in body
umap/urls.py CHANGED
@@ -98,6 +98,11 @@ i18n_urls += decorated_patterns(
98
98
  views.ToggleMapStarStatus.as_view(),
99
99
  name="map_star",
100
100
  ),
101
+ re_path(
102
+ r"^me$",
103
+ views.user_dashboard,
104
+ name="user_dashboard",
105
+ ),
101
106
  )
102
107
  map_urls = [
103
108
  re_path(
umap/views.py CHANGED
@@ -77,7 +77,7 @@ PRIVATE_IP = re.compile(
77
77
  ANONYMOUS_COOKIE_MAX_AGE = 60 * 60 * 24 * 30 # One month
78
78
 
79
79
 
80
- class PaginatorMixin(object):
80
+ class PaginatorMixin:
81
81
  per_page = 5
82
82
 
83
83
  def paginate(self, qs, per_page=None):
@@ -94,9 +94,20 @@ class PaginatorMixin(object):
94
94
  qs = paginator.page(paginator.num_pages)
95
95
  return qs
96
96
 
97
+ def get_context_data(self, **kwargs):
98
+ kwargs.update({"is_ajax": is_ajax(self.request)})
99
+ return super().get_context_data(**kwargs)
100
+
101
+ def get_template_names(self):
102
+ """
103
+ Dispatch template according to the kind of request: ajax or normal.
104
+ """
105
+ if is_ajax(self.request):
106
+ return [self.list_template_name]
107
+ return super().get_template_names()
97
108
 
98
- class PublicMapsMixin(object):
99
109
 
110
+ class PublicMapsMixin(object):
100
111
  def get_public_maps(self):
101
112
  qs = Map.public
102
113
  if (
@@ -109,7 +120,7 @@ class PublicMapsMixin(object):
109
120
  return maps
110
121
 
111
122
 
112
- class Home(TemplateView, PublicMapsMixin, PaginatorMixin):
123
+ class Home(PaginatorMixin, TemplateView, PublicMapsMixin):
113
124
  template_name = "umap/home.html"
114
125
  list_template_name = "umap/map_list.html"
115
126
 
@@ -142,15 +153,6 @@ class Home(TemplateView, PublicMapsMixin, PaginatorMixin):
142
153
  "showcase_map": showcase_map,
143
154
  }
144
155
 
145
- def get_template_names(self):
146
- """
147
- Dispatch template according to the kind of request: ajax or normal.
148
- """
149
- if is_ajax(self.request):
150
- return [self.list_template_name]
151
- else:
152
- return [self.template_name]
153
-
154
156
 
155
157
  home = Home.as_view()
156
158
 
@@ -162,7 +164,7 @@ class About(Home):
162
164
  about = About.as_view()
163
165
 
164
166
 
165
- class UserMaps(DetailView, PaginatorMixin):
167
+ class UserMaps(PaginatorMixin, DetailView):
166
168
  model = User
167
169
  slug_url_kwarg = "identifier"
168
170
  slug_field = settings.USER_URL_FIELD
@@ -190,15 +192,6 @@ class UserMaps(DetailView, PaginatorMixin):
190
192
  kwargs.update({"maps": self.paginate(self.get_maps(), self.per_page)})
191
193
  return super().get_context_data(**kwargs)
192
194
 
193
- def get_template_names(self):
194
- """
195
- Dispatch template according to the kind of request: ajax or normal.
196
- """
197
- if is_ajax(self.request):
198
- return [self.list_template_name]
199
- else:
200
- return super(UserMaps, self).get_template_names()
201
-
202
195
 
203
196
  user_maps = UserMaps.as_view()
204
197
 
@@ -216,37 +209,34 @@ class UserStars(UserMaps):
216
209
  user_stars = UserStars.as_view()
217
210
 
218
211
 
219
- class Search(TemplateView, PublicMapsMixin, PaginatorMixin):
220
- template_name = "umap/search.html"
221
- list_template_name = "umap/map_list.html"
222
-
223
- def get_context_data(self, **kwargs):
212
+ class SearchMixin:
213
+ def get_search_queryset(self, **kwargs):
224
214
  q = self.request.GET.get("q")
225
- qs_count = 0
226
- results = []
227
215
  if q:
228
216
  vector = SearchVector("name", config=settings.UMAP_SEARCH_CONFIGURATION)
229
217
  query = SearchQuery(
230
218
  q, config=settings.UMAP_SEARCH_CONFIGURATION, search_type="websearch"
231
219
  )
232
- qs = Map.objects.annotate(search=vector).filter(search=query)
220
+ return Map.objects.annotate(search=vector).filter(search=query)
221
+
222
+
223
+ class Search(PaginatorMixin, TemplateView, PublicMapsMixin, SearchMixin):
224
+ template_name = "umap/search.html"
225
+ list_template_name = "umap/map_list.html"
226
+
227
+ def get_context_data(self, **kwargs):
228
+ qs = self.get_search_queryset()
229
+ qs_count = 0
230
+ results = []
231
+ if qs is not None:
233
232
  qs = qs.filter(share_status=Map.PUBLIC).order_by("-modified_at")
234
233
  qs_count = qs.count()
235
234
  results = self.paginate(qs)
236
235
  else:
237
- results = self.get_public_maps()[:settings.UMAP_MAPS_PER_SEARCH]
238
- kwargs.update({"maps": results, "count": qs_count, "q": q})
236
+ results = self.get_public_maps()[: settings.UMAP_MAPS_PER_SEARCH]
237
+ kwargs.update({"maps": results, "count": qs_count})
239
238
  return kwargs
240
239
 
241
- def get_template_names(self):
242
- """
243
- Dispatch template according to the kind of request: ajax or normal.
244
- """
245
- if is_ajax(self.request):
246
- return [self.list_template_name]
247
- else:
248
- return super(Search, self).get_template_names()
249
-
250
240
  @property
251
241
  def per_page(self):
252
242
  return settings.UMAP_MAPS_PER_SEARCH
@@ -255,6 +245,29 @@ class Search(TemplateView, PublicMapsMixin, PaginatorMixin):
255
245
  search = Search.as_view()
256
246
 
257
247
 
248
+ class UserDashboard(PaginatorMixin, DetailView, SearchMixin):
249
+ model = User
250
+ template_name = "umap/user_dashboard.html"
251
+ list_template_name = "umap/map_table.html"
252
+
253
+ def get_object(self):
254
+ return self.get_queryset().get(pk=self.request.user.pk)
255
+
256
+ def get_maps(self):
257
+ qs = self.get_search_queryset() or Map.objects.all()
258
+ qs = qs.filter(Q(owner=self.object) | Q(editors=self.object))
259
+ return qs.order_by("-modified_at")
260
+
261
+ def get_context_data(self, **kwargs):
262
+ kwargs.update(
263
+ {"maps": self.paginate(self.get_maps(), settings.UMAP_MAPS_PER_PAGE_OWNER)}
264
+ )
265
+ return super().get_context_data(**kwargs)
266
+
267
+
268
+ user_dashboard = UserDashboard.as_view()
269
+
270
+
258
271
  class MapsShowCase(View):
259
272
  def get(self, *args, **kwargs):
260
273
  maps = Map.public.filter(center__distance_gt=(DEFAULT_CENTER, D(km=1)))
@@ -436,7 +449,7 @@ class MapDetailMixin:
436
449
  properties["user"] = {
437
450
  "id": user.pk,
438
451
  "name": str(user),
439
- "url": user.get_url(),
452
+ "url": reverse("user_dashboard"),
440
453
  }
441
454
  map_settings = self.get_geojson()
442
455
  if "properties" not in map_settings:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: umap-project
3
- Version: 1.3.7
3
+ Version: 1.4.1
4
4
  Summary: Create maps with OpenStreetMap layers in a minute and embed them in your site.
5
5
  Author-email: Yohan Boniface <yb@enix.org>
6
6
  Maintainer-email: David Larlet <david@larlet.fr>