umap-project 2.0.4__py3-none-any.whl → 2.1.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.
Files changed (106) hide show
  1. umap/__init__.py +1 -1
  2. umap/fields.py +3 -1
  3. umap/locale/br/LC_MESSAGES/django.po +76 -71
  4. umap/locale/en/LC_MESSAGES/django.po +41 -41
  5. umap/locale/hu/LC_MESSAGES/django.po +42 -42
  6. umap/locale/it/LC_MESSAGES/django.po +64 -58
  7. umap/locale/ms/LC_MESSAGES/django.po +62 -57
  8. umap/migrations/0018_datalayer_uuid.py +62 -0
  9. umap/migrations/0019_migrate_internal_remote_datalayers.py +52 -0
  10. umap/models.py +20 -3
  11. umap/settings/base.py +1 -0
  12. umap/settings/dev.py +1 -0
  13. umap/static/umap/js/modules/browser.js +2 -2
  14. umap/static/umap/js/modules/global.js +14 -4
  15. umap/static/umap/js/modules/i18n.js +35 -0
  16. umap/static/umap/js/modules/leaflet-configure.js +7 -0
  17. umap/static/umap/js/modules/schema.js +388 -0
  18. umap/static/umap/js/modules/urls.js +17 -2
  19. umap/static/umap/js/modules/utils.js +24 -0
  20. umap/static/umap/js/umap.controls.js +9 -10
  21. umap/static/umap/js/umap.core.js +5 -5
  22. umap/static/umap/js/umap.features.js +23 -9
  23. umap/static/umap/js/umap.forms.js +49 -299
  24. umap/static/umap/js/umap.icon.js +2 -2
  25. umap/static/umap/js/umap.js +26 -129
  26. umap/static/umap/js/umap.layer.js +9 -9
  27. umap/static/umap/js/umap.popup.js +3 -0
  28. umap/static/umap/js/umap.share.js +1 -1
  29. umap/static/umap/locale/am_ET.json +229 -225
  30. umap/static/umap/locale/ar.json +229 -225
  31. umap/static/umap/locale/ast.json +229 -225
  32. umap/static/umap/locale/bg.json +229 -225
  33. umap/static/umap/locale/br.json +237 -233
  34. umap/static/umap/locale/ca.json +229 -225
  35. umap/static/umap/locale/cs_CZ.json +229 -225
  36. umap/static/umap/locale/da.json +229 -225
  37. umap/static/umap/locale/de.json +229 -225
  38. umap/static/umap/locale/el.json +229 -225
  39. umap/static/umap/locale/en.json +230 -233
  40. umap/static/umap/locale/en_US.json +229 -225
  41. umap/static/umap/locale/es.json +229 -225
  42. umap/static/umap/locale/et.json +229 -225
  43. umap/static/umap/locale/eu.json +226 -198
  44. umap/static/umap/locale/fa_IR.json +229 -225
  45. umap/static/umap/locale/fi.json +229 -225
  46. umap/static/umap/locale/fr.json +229 -232
  47. umap/static/umap/locale/gl.json +229 -225
  48. umap/static/umap/locale/he.json +229 -225
  49. umap/static/umap/locale/hr.json +229 -225
  50. umap/static/umap/locale/hu.json +229 -232
  51. umap/static/umap/locale/id.json +229 -225
  52. umap/static/umap/locale/is.json +229 -225
  53. umap/static/umap/locale/it.json +229 -232
  54. umap/static/umap/locale/ja.json +229 -225
  55. umap/static/umap/locale/ko.json +229 -225
  56. umap/static/umap/locale/lt.json +229 -225
  57. umap/static/umap/locale/ms.json +229 -232
  58. umap/static/umap/locale/nl.json +232 -228
  59. umap/static/umap/locale/no.json +229 -225
  60. umap/static/umap/locale/pl.json +229 -225
  61. umap/static/umap/locale/pl_PL.json +229 -225
  62. umap/static/umap/locale/pt.json +229 -225
  63. umap/static/umap/locale/pt_BR.json +229 -225
  64. umap/static/umap/locale/pt_PT.json +229 -225
  65. umap/static/umap/locale/ro.json +229 -225
  66. umap/static/umap/locale/ru.json +229 -225
  67. umap/static/umap/locale/sk_SK.json +229 -225
  68. umap/static/umap/locale/sl.json +229 -225
  69. umap/static/umap/locale/sr.json +229 -225
  70. umap/static/umap/locale/sv.json +229 -225
  71. umap/static/umap/locale/th_TH.json +229 -225
  72. umap/static/umap/locale/tr.json +229 -225
  73. umap/static/umap/locale/uk_UA.json +229 -225
  74. umap/static/umap/locale/vi.json +229 -225
  75. umap/static/umap/locale/vi_VN.json +229 -225
  76. umap/static/umap/locale/zh.json +229 -225
  77. umap/static/umap/locale/zh_CN.json +229 -225
  78. umap/static/umap/locale/zh_TW.Big5.json +229 -225
  79. umap/static/umap/locale/zh_TW.json +229 -232
  80. umap/static/umap/test/index.html +0 -2
  81. umap/static/umap/{test → unittests}/URLs.js +5 -0
  82. umap/static/umap/vendors/leaflet/leaflet-src.esm.js +7064 -7064
  83. umap/static/umap/vendors/photon/leaflet.photon.js +3 -0
  84. umap/templates/umap/js.html +8 -6
  85. umap/templatetags/umap_tags.py +3 -2
  86. umap/tests/integration/test_browser.py +40 -0
  87. umap/tests/integration/test_collaborative_editing.py +72 -3
  88. umap/tests/integration/test_export_map.py +226 -9
  89. umap/tests/integration/test_features_id_generation.py +51 -0
  90. umap/tests/integration/test_owned_map.py +14 -1
  91. umap/tests/integration/test_statics.py +3 -3
  92. umap/tests/integration/test_tilelayer.py +3 -3
  93. umap/tests/settings.py +3 -3
  94. umap/tests/test_datalayer_views.py +77 -20
  95. umap/tests/test_map_views.py +20 -0
  96. umap/tests/test_merge_features.py +25 -5
  97. umap/urls.py +12 -12
  98. umap/utils.py +7 -0
  99. umap/views.py +58 -49
  100. umap/wsgi.py +1 -0
  101. {umap_project-2.0.4.dist-info → umap_project-2.1.1.dist-info}/METADATA +9 -9
  102. {umap_project-2.0.4.dist-info → umap_project-2.1.1.dist-info}/RECORD +105 -99
  103. umap/static/umap/test/Map.Export.js +0 -106
  104. {umap_project-2.0.4.dist-info → umap_project-2.1.1.dist-info}/WHEEL +0 -0
  105. {umap_project-2.0.4.dist-info → umap_project-2.1.1.dist-info}/entry_points.txt +0 -0
  106. {umap_project-2.0.4.dist-info → umap_project-2.1.1.dist-info}/licenses/LICENSE +0 -0
@@ -9,7 +9,7 @@ msgid ""
9
9
  msgstr ""
10
10
  "Project-Id-Version: uMap\n"
11
11
  "Report-Msgid-Bugs-To: \n"
12
- "POT-Creation-Date: 2024-02-15 13:53+0000\n"
12
+ "POT-Creation-Date: 2024-03-25 12:41+0000\n"
13
13
  "PO-Revision-Date: 2013-11-22 14:00+0000\n"
14
14
  "Last-Translator: Yaya - Nurul Azeera Hidayah @ Muhammad Nur Hidayat Yasuyoshi (MNH48) <admin@mnh48.moe>, 2021,2023-2024\n"
15
15
  "Language-Team: Malay (http://app.transifex.com/openstreetmap/umap/language/ms/)\n"
@@ -27,7 +27,7 @@ msgstr "Hanya boleh disunting dengan pautan rahsia"
27
27
  msgid "Everyone can edit"
28
28
  msgstr "Sesiapa pun boleh sunting"
29
29
 
30
- #: forms.py:69 models.py:371
30
+ #: forms.py:69 models.py:381
31
31
  msgid "Inherit"
32
32
  msgstr "Warisi"
33
33
 
@@ -35,107 +35,107 @@ msgstr "Warisi"
35
35
  msgid "Site is readonly for maintenance"
36
36
  msgstr "Laman dalam mod baca sahaja untuk penyenggaraan"
37
37
 
38
- #: models.py:50
38
+ #: models.py:52
39
39
  msgid "name"
40
40
  msgstr "nama"
41
41
 
42
- #: models.py:81
42
+ #: models.py:83
43
43
  msgid "details"
44
44
  msgstr "perincian"
45
45
 
46
- #: models.py:82
46
+ #: models.py:84
47
47
  msgid "Link to a page where the licence is detailed."
48
48
  msgstr "Pautan ke halaman yang menyatakan lesennya."
49
49
 
50
- #: models.py:92
50
+ #: models.py:94
51
51
  msgid "URL template using OSM tile format"
52
52
  msgstr "Templat URL menggunakan format fail OSM"
53
53
 
54
- #: models.py:98
54
+ #: models.py:100
55
55
  msgid "Order of the tilelayers in the edit box"
56
56
  msgstr "Kedudukan lapisan jubin dalam kotak suntingan"
57
57
 
58
- #: models.py:144 models.py:372
58
+ #: models.py:146 models.py:382
59
59
  msgid "Everyone"
60
60
  msgstr "Semua orang"
61
61
 
62
- #: models.py:145 models.py:151 models.py:373
62
+ #: models.py:147 models.py:153 models.py:383
63
63
  msgid "Editors only"
64
64
  msgstr "Penyunting sahaja"
65
65
 
66
- #: models.py:146 models.py:374
66
+ #: models.py:148 models.py:384
67
67
  msgid "Owner only"
68
68
  msgstr "Pemilik sahaja"
69
69
 
70
- #: models.py:149
70
+ #: models.py:151
71
71
  msgid "Everyone (public)"
72
72
  msgstr "Semua orang (umum)"
73
73
 
74
- #: models.py:150
74
+ #: models.py:152
75
75
  msgid "Anyone with link"
76
76
  msgstr "Sesiapa yang ada pautan"
77
77
 
78
- #: models.py:152
78
+ #: models.py:154
79
79
  msgid "Blocked"
80
80
  msgstr "Disekat"
81
81
 
82
- #: models.py:155 models.py:378
82
+ #: models.py:157 models.py:391
83
83
  msgid "description"
84
84
  msgstr "keterangan"
85
85
 
86
- #: models.py:156
86
+ #: models.py:158
87
87
  msgid "center"
88
88
  msgstr "pertengahkan"
89
89
 
90
- #: models.py:157
90
+ #: models.py:159
91
91
  msgid "zoom"
92
92
  msgstr "zum"
93
93
 
94
- #: models.py:159
94
+ #: models.py:161
95
95
  msgid "locate"
96
96
  msgstr "mengesan"
97
97
 
98
- #: models.py:159
98
+ #: models.py:161
99
99
  msgid "Locate user on load?"
100
100
  msgstr "Kesan kedudukan pengguna semasa dimuatkan?"
101
101
 
102
- #: models.py:163
102
+ #: models.py:165
103
103
  msgid "Choose the map licence."
104
104
  msgstr "Pilih lesen peta."
105
105
 
106
- #: models.py:164
106
+ #: models.py:166
107
107
  msgid "licence"
108
108
  msgstr "lesen"
109
109
 
110
- #: models.py:175
110
+ #: models.py:177
111
111
  msgid "owner"
112
112
  msgstr "pemilik"
113
113
 
114
- #: models.py:179
114
+ #: models.py:181
115
115
  msgid "editors"
116
116
  msgstr "penyunting"
117
117
 
118
- #: models.py:184 models.py:392
118
+ #: models.py:186 models.py:405
119
119
  msgid "edit status"
120
120
  msgstr "status suntingan"
121
121
 
122
- #: models.py:189
122
+ #: models.py:191
123
123
  msgid "share status"
124
124
  msgstr "status perkongsian"
125
125
 
126
- #: models.py:192 models.py:387
126
+ #: models.py:194 models.py:400
127
127
  msgid "settings"
128
128
  msgstr "tetapan"
129
129
 
130
- #: models.py:320
130
+ #: models.py:322
131
131
  msgid "Clone of"
132
132
  msgstr "Klon bagi"
133
133
 
134
- #: models.py:382
134
+ #: models.py:395
135
135
  msgid "display on load"
136
136
  msgstr "paparkan semasa dimuatkan"
137
137
 
138
- #: models.py:383
138
+ #: models.py:396
139
139
  msgid "Display this layer on load."
140
140
  msgstr "Paparkan lapisan ini ketika dimuatkan."
141
141
 
@@ -291,7 +291,7 @@ msgstr "Dapatkan inspirasi, layari peta-peta"
291
291
  msgid "You are logged in. Continuing..."
292
292
  msgstr "Anda telah log masuk. Menyambung..."
293
293
 
294
- #: templates/umap/map_list.html:9 views.py:341
294
+ #: templates/umap/map_list.html:9 views.py:349
295
295
  msgid "by"
296
296
  msgstr "oleh"
297
297
 
@@ -327,57 +327,57 @@ msgstr "Pemilik"
327
327
  msgid "Actions"
328
328
  msgstr "Tindakan"
329
329
 
330
- #: templates/umap/map_table.html:25 templates/umap/map_table.html:27
330
+ #: templates/umap/map_table.html:26 templates/umap/map_table.html:28
331
331
  msgid "Open preview"
332
332
  msgstr "Buka pralihat"
333
333
 
334
- #: templates/umap/map_table.html:46 templates/umap/map_table.html:48
334
+ #: templates/umap/map_table.html:48 templates/umap/map_table.html:50
335
335
  msgid "Share"
336
336
  msgstr "Kongsi"
337
337
 
338
- #: templates/umap/map_table.html:51 templates/umap/map_table.html:53
338
+ #: templates/umap/map_table.html:54 templates/umap/map_table.html:56
339
339
  msgid "Edit"
340
340
  msgstr "Sunting"
341
341
 
342
- #: templates/umap/map_table.html:56 templates/umap/map_table.html:58
342
+ #: templates/umap/map_table.html:60 templates/umap/map_table.html:62
343
343
  msgid "Download"
344
344
  msgstr "Muat turun"
345
345
 
346
- #: templates/umap/map_table.html:63 templates/umap/map_table.html:65
346
+ #: templates/umap/map_table.html:66 templates/umap/map_table.html:68
347
347
  msgid "Clone"
348
348
  msgstr "Klon"
349
349
 
350
- #: templates/umap/map_table.html:73 templates/umap/map_table.html:75
350
+ #: templates/umap/map_table.html:76 templates/umap/map_table.html:78
351
351
  msgid "Delete"
352
352
  msgstr "Padam"
353
353
 
354
- #: templates/umap/map_table.html:88
354
+ #: templates/umap/map_table.html:91
355
355
  msgid "first"
356
356
  msgstr "pertama"
357
357
 
358
- #: templates/umap/map_table.html:89
358
+ #: templates/umap/map_table.html:92
359
359
  msgid "previous"
360
360
  msgstr "sebelumnya"
361
361
 
362
- #: templates/umap/map_table.html:98
362
+ #: templates/umap/map_table.html:100
363
363
  #, python-format
364
364
  msgid "Page %(maps_number)s of %(num_pages)s"
365
365
  msgstr "Halaman %(maps_number)s daripada %(num_pages)s"
366
366
 
367
- #: templates/umap/map_table.html:104
367
+ #: templates/umap/map_table.html:105
368
368
  msgid "next"
369
369
  msgstr "seterusnya"
370
370
 
371
- #: templates/umap/map_table.html:105
371
+ #: templates/umap/map_table.html:106
372
372
  msgid "last"
373
373
  msgstr "terakhir"
374
374
 
375
- #: templates/umap/map_table.html:113
375
+ #: templates/umap/map_table.html:114
376
376
  #, python-format
377
377
  msgid "Lines per page: %(per_page)s"
378
378
  msgstr "Baris per halaman: %(per_page)s"
379
379
 
380
- #: templates/umap/map_table.html:118
380
+ #: templates/umap/map_table.html:119
381
381
  #, python-format
382
382
  msgid "%(count)s maps"
383
383
  msgstr "%(count)s peta"
@@ -470,20 +470,20 @@ msgstr "Cari peta"
470
470
  msgid "Search"
471
471
  msgstr "Cari"
472
472
 
473
- #: templates/umap/user_dashboard.html:7 templates/umap/user_dashboard.html:26
473
+ #: templates/umap/user_dashboard.html:7 templates/umap/user_dashboard.html:27
474
474
  msgid "Search my maps"
475
475
  msgstr "Gelintar peta saya"
476
476
 
477
- #: templates/umap/user_dashboard.html:11
477
+ #: templates/umap/user_dashboard.html:10
478
478
  #, python-format
479
479
  msgid "My Maps (%(count)s)"
480
480
  msgstr "Peta Saya (%(count)s)"
481
481
 
482
- #: templates/umap/user_dashboard.html:13
482
+ #: templates/umap/user_dashboard.html:12
483
483
  msgid "My profile"
484
484
  msgstr "Profil saya"
485
485
 
486
- #: templates/umap/user_dashboard.html:21 templates/umap/user_dashboard.html:23
486
+ #: templates/umap/user_dashboard.html:20 templates/umap/user_dashboard.html:24
487
487
  msgid "Map’s title"
488
488
  msgstr "Tajuk peta"
489
489
 
@@ -496,52 +496,57 @@ msgstr "Muat turun %(count)s peta"
496
496
  msgid "You have no map yet."
497
497
  msgstr "Anda belum ada peta."
498
498
 
499
- #: views.py:346
499
+ #: views.py:354
500
500
  msgid "View the map"
501
501
  msgstr "Lihat peta"
502
502
 
503
- #: views.py:704
503
+ #: views.py:716
504
504
  msgid "See full screen"
505
505
  msgstr "Lihat skrin penuh"
506
506
 
507
- #: views.py:803
507
+ #: views.py:817
508
508
  msgid "Map editors updated with success!"
509
509
  msgstr "Penyunting peta telah dikemas kini dengan jayanya!"
510
510
 
511
- #: views.py:841
511
+ #: views.py:854
512
512
  #, python-format
513
513
  msgid "The uMap edit link for your map: %(map_name)s"
514
514
  msgstr "Pautan suntingan uMap untuk peta anda: %(map_name)s"
515
515
 
516
- #: views.py:844
516
+ #: views.py:857
517
517
  #, python-format
518
518
  msgid "Here is your secret edit link: %(link)s"
519
519
  msgstr "Ini pautan suntingan rahsia anda: %(link)s"
520
520
 
521
- #: views.py:850
521
+ #: views.py:864
522
+ #, python-format
523
+ msgid "Can't send email to %(email)s"
524
+ msgstr "Tidak dapat menghantar e-mel kepada %(email)s"
525
+
526
+ #: views.py:867
522
527
  #, python-format
523
528
  msgid "Email sent to %(email)s"
524
529
  msgstr "E-mel telah dihantar ke %(email)s"
525
530
 
526
- #: views.py:861
531
+ #: views.py:878
527
532
  msgid "Only its owner can delete the map."
528
533
  msgstr "Hanya pemiliknya sahaja mampu memadamkan peta."
529
534
 
530
- #: views.py:889
535
+ #: views.py:906
531
536
  #, python-format
532
537
  msgid ""
533
538
  "Your map has been cloned! If you want to edit this map from another "
534
539
  "computer, please use this link: %(anonymous_url)s"
535
540
  msgstr "Peta anda telah diklon! Jika anda ingin menyunting peta ini dari komputer lain, sila gunakan pautan ini: %(anonymous_url)s"
536
541
 
537
- #: views.py:894
542
+ #: views.py:911
538
543
  msgid "Congratulations, your map has been cloned!"
539
544
  msgstr "Tahniah, peta anda telah berjaya diklon!"
540
545
 
541
- #: views.py:1130
546
+ #: views.py:1145
542
547
  msgid "Layer successfully deleted."
543
548
  msgstr "Lapisan telah berjaya dipadamkan."
544
549
 
545
- #: views.py:1152
550
+ #: views.py:1167
546
551
  msgid "Permissions updated with success!"
547
552
  msgstr "Kebenaran telah dikemas kini dengan jayanya!"
@@ -0,0 +1,62 @@
1
+ # Generated by Django 4.2.8 on 2024-02-19 17:40
2
+
3
+ import uuid
4
+
5
+ from django.db import migrations, models
6
+
7
+ drop_index = """DO $$
8
+ BEGIN
9
+ EXECUTE 'ALTER TABLE umap_datalayer DROP CONSTRAINT ' || (
10
+ SELECT indexname
11
+ FROM pg_indexes
12
+ WHERE tablename = 'umap_datalayer' AND indexname LIKE '%pk%'
13
+ );
14
+ END $$;
15
+ """
16
+
17
+
18
+ class Migration(migrations.Migration):
19
+ dependencies = [
20
+ ("umap", "0017_migrate_to_openstreetmap_oauth2"),
21
+ ]
22
+
23
+ operations = [
24
+ # Add the new uuid field
25
+ migrations.AddField(
26
+ model_name="datalayer",
27
+ name="uuid",
28
+ field=models.UUIDField(
29
+ default=uuid.uuid4, editable=False, null=True, serialize=False
30
+ ),
31
+ ),
32
+ # Generate UUIDs for existing records
33
+ migrations.RunSQL(
34
+ "UPDATE umap_datalayer SET uuid = gen_random_uuid()",
35
+ reverse_sql=migrations.RunSQL.noop,
36
+ ),
37
+ # Remove the primary key constraint
38
+ migrations.RunSQL(drop_index, reverse_sql=migrations.RunSQL.noop),
39
+ # Drop the "id" primary key…
40
+ migrations.AlterField(
41
+ "datalayer", name="id", field=models.IntegerField(null=True, blank=True)
42
+ ),
43
+ # Rename "id" to "old id"
44
+ migrations.RenameField(
45
+ model_name="datalayer", old_name="id", new_name="old_id"
46
+ ),
47
+ # … to put it back on the "uuid"
48
+ migrations.AlterField(
49
+ model_name="datalayer",
50
+ name="uuid",
51
+ field=models.UUIDField(
52
+ default=uuid.uuid4,
53
+ editable=False,
54
+ unique=True,
55
+ primary_key=True,
56
+ serialize=False,
57
+ ),
58
+ ),
59
+ # When applying the migration backwards, we need to drop the pk index
60
+ # Before addding a new one.
61
+ migrations.RunSQL(migrations.RunSQL.noop, reverse_sql=drop_index),
62
+ ]
@@ -0,0 +1,52 @@
1
+ # Generated by Django 4.2 on 2024-02-26 14:09
2
+
3
+ import re
4
+
5
+ from django.conf import settings
6
+ from django.db import migrations
7
+ from django.urls import NoReverseMatch, reverse
8
+
9
+ # Some users hacked uMap to use another map datalayer as a remote data source.
10
+ # This script gently handles the migration for them.
11
+
12
+
13
+ def migrate_datalayers(apps, schema_editor):
14
+ DataLayer = apps.get_model("umap", "DataLayer")
15
+
16
+ datalayers = DataLayer.objects.filter(
17
+ settings__remoteData__url__icontains="datalayer"
18
+ )
19
+
20
+ for item in datalayers:
21
+ old_url = item.settings["remoteData"]["url"]
22
+ match = re.search(
23
+ rf"{settings.SITE_URL}/datalayer/(?P<map_id>\d+)/(?P<datalayer_id>\d+)",
24
+ old_url,
25
+ )
26
+ if match:
27
+ remote_id = match.group("datalayer_id")
28
+ map_id = match.group("map_id")
29
+ try:
30
+ remote_uuid = DataLayer.objects.get(old_id=remote_id).uuid
31
+ except DataLayer.DoesNotExist:
32
+ pass
33
+ else:
34
+ try:
35
+ new_url = settings.SITE_URL + reverse(
36
+ "datalayer_view", args=[map_id, remote_uuid]
37
+ )
38
+ except NoReverseMatch:
39
+ pass
40
+ else:
41
+ item.settings["remoteData"]["url"] = new_url
42
+ item.save()
43
+
44
+
45
+ class Migration(migrations.Migration):
46
+ dependencies = [
47
+ ("umap", "0018_datalayer_uuid"),
48
+ ]
49
+
50
+ operations = [
51
+ migrations.RunPython(migrate_datalayers, reverse_code=migrations.RunPython.noop)
52
+ ]
umap/models.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import json
2
2
  import os
3
3
  import time
4
+ import uuid
4
5
 
5
6
  from django.conf import settings
6
7
  from django.contrib.auth.models import User
@@ -9,6 +10,7 @@ from django.core.files.base import File
9
10
  from django.core.signing import Signer
10
11
  from django.template.defaultfilters import slugify
11
12
  from django.urls import reverse
13
+ from django.utils.functional import classproperty
12
14
  from django.utils.translation import gettext_lazy as _
13
15
 
14
16
  from .managers import PublicManager
@@ -217,7 +219,7 @@ class Map(NamedModel):
217
219
  "umap_id": self.pk,
218
220
  "onLoadPanel": "none",
219
221
  "captionBar": False,
220
- "default_iconUrl": "%sumap/img/marker.svg" % settings.STATIC_URL,
222
+ "schema": self.extra_schema,
221
223
  "slideshow": {},
222
224
  }
223
225
  )
@@ -328,6 +330,14 @@ class Map(NamedModel):
328
330
  datalayer.clone(map_inst=new)
329
331
  return new
330
332
 
333
+ @classproperty
334
+ def extra_schema(self):
335
+ return {
336
+ "iconUrl": {
337
+ "default": "%sumap/img/marker.svg" % settings.STATIC_URL,
338
+ }
339
+ }
340
+
331
341
 
332
342
  class Pictogram(NamedModel):
333
343
  """
@@ -373,7 +383,10 @@ class DataLayer(NamedModel):
373
383
  (EDITORS, _("Editors only")),
374
384
  (OWNER, _("Owner only")),
375
385
  )
376
-
386
+ uuid = models.UUIDField(
387
+ unique=True, primary_key=True, default=uuid.uuid4, editable=False
388
+ )
389
+ old_id = models.IntegerField(null=True, blank=True)
377
390
  map = models.ForeignKey(Map, on_delete=models.CASCADE)
378
391
  description = models.TextField(blank=True, null=True, verbose_name=_("description"))
379
392
  geojson = models.FileField(upload_to=upload_to, blank=True, null=True)
@@ -436,6 +449,7 @@ class DataLayer(NamedModel):
436
449
 
437
450
  def clone(self, map_inst=None):
438
451
  new = self.__class__.objects.get(pk=self.pk)
452
+ new._state.adding = True
439
453
  new.pk = None
440
454
  if map_inst:
441
455
  new.map = map_inst
@@ -444,7 +458,10 @@ class DataLayer(NamedModel):
444
458
  return new
445
459
 
446
460
  def is_valid_version(self, name):
447
- return name.startswith("%s_" % self.pk) and name.endswith(".geojson")
461
+ valid_prefixes = [name.startswith("%s_" % self.pk)]
462
+ if self.old_id:
463
+ valid_prefixes.append(name.startswith("%s_" % self.old_id))
464
+ return any(valid_prefixes) and name.endswith(".geojson")
448
465
 
449
466
  def version_metadata(self, name):
450
467
  els = name.split(".")[0].split("_")
umap/settings/base.py CHANGED
@@ -1,4 +1,5 @@
1
1
  """Base settings shared by all environments"""
2
+
2
3
  # Import global settings to make it easier to extend settings.
3
4
  from email.utils import parseaddr
4
5
 
umap/settings/dev.py CHANGED
@@ -1,4 +1,5 @@
1
1
  """Settings for Development Server"""
2
+
2
3
  from umap.settings.base import * # pylint: disable=W0614,W0401
3
4
 
4
5
  DEBUG = True
@@ -30,7 +30,7 @@ export default class Browser {
30
30
  title.textContent = feature.getDisplayName() || '—'
31
31
  const bgcolor = feature.getDynamicOption('color')
32
32
  colorBox.style.backgroundColor = bgcolor
33
- if (symbol && symbol !== this.map.options.default_iconUrl) {
33
+ if (symbol && symbol !== U.SCHEMA.iconUrl.default) {
34
34
  const icon = U.Icon.makeIconElement(symbol, colorBox)
35
35
  U.Icon.setIconContrast(icon, colorBox, symbol, bgcolor)
36
36
  }
@@ -131,7 +131,7 @@ export default class Browser {
131
131
  'h3',
132
132
  'umap-browse-title',
133
133
  container,
134
- this.map.options.name
134
+ this.map.getOption('name')
135
135
  )
136
136
 
137
137
  const formContainer = DomUtil.create('div', '', container)
@@ -1,10 +1,20 @@
1
- import * as L from '../../vendors/leaflet/leaflet-src.esm.js'
2
1
  import URLs from './urls.js'
3
2
  import Browser from './browser.js'
3
+ import * as Utils from './utils.js'
4
+ import {SCHEMA} from './schema.js'
4
5
  import { Request, ServerRequest, RequestError, HTTPError, NOKError } from './request.js'
6
+
5
7
  // Import modules and export them to the global scope.
6
8
  // For the not yet module-compatible JS out there.
7
9
 
8
- // Copy the leaflet module, it's expected by leaflet plugins to be writeable.
9
- window.L = { ...L }
10
- window.U = { URLs, Request, ServerRequest, RequestError, HTTPError, NOKError, Browser }
10
+ window.U = {
11
+ URLs,
12
+ Request,
13
+ ServerRequest,
14
+ RequestError,
15
+ HTTPError,
16
+ NOKError,
17
+ Browser,
18
+ Utils,
19
+ SCHEMA,
20
+ }
@@ -0,0 +1,35 @@
1
+ // Comes from https://github.com/Leaflet/Leaflet/pull/9281
2
+ import { Util } from '../../vendors/leaflet/leaflet-src.esm.js'
3
+
4
+ export const locales = {}
5
+
6
+ // @property locale: String
7
+ // The current locale code, that will be used when translating strings.
8
+ export let locale = null
9
+
10
+ // @function registerLocale(code: String, locale?: Object): String
11
+ // Define localized strings for a given locale, defined by `code`.
12
+ export function registerLocale(code, locale) {
13
+ locales[code] = Util.extend({}, locales[code], locale)
14
+ }
15
+ // @function setLocale(code: String): undefined
16
+ // Define or change the locale code to be used when translating strings.
17
+ export function setLocale(code) {
18
+ locale = code
19
+ }
20
+ // @function translate(string: String, data?: Object): String
21
+ // Actually try to translate the `string`, with optionnal variable passed in `data`.
22
+ export function translate(string, data = {}) {
23
+ if (locale && locales[locale] && locales[locale][string] !== undefined) {
24
+ string = locales[locale][string]
25
+ }
26
+ try {
27
+ // Do not fail if some data is missing
28
+ // a bad translation should not break the app
29
+ string = Util.template(string, data)
30
+ } catch (err) {
31
+ console.error(err)
32
+ }
33
+
34
+ return string
35
+ }
@@ -0,0 +1,7 @@
1
+ import * as L from '../../vendors/leaflet/leaflet-src.esm.js'
2
+ // Comes from https://github.com/Leaflet/Leaflet/pull/9281
3
+ // TODELETE once it's merged!
4
+ import * as i18n from './i18n.js'
5
+
6
+ window.L = { ...L, ...i18n }
7
+ window.L._ = i18n.translate