Misc fixes

- on vire un commentaire obsolète, et on en remet un à jour
- un peu de doc sur les converters
This commit is contained in:
Ludovic Stephan 2019-05-21 15:30:51 +02:00
parent 03c74a7940
commit 198658f5f9
3 changed files with 16 additions and 1 deletions

View file

@ -37,6 +37,15 @@ def export(qs, fields=None):
def admin_list_export( def admin_list_export(
request, model_name, app_label, queryset=None, fields=None, list_display=True request, model_name, app_label, queryset=None, fields=None, list_display=True
): ):
"""
Put the following line in your urls.py BEFORE your admin include:
path(
"admin/<slug:app_label>/<slug:model_name>/csv/",
csv_views.admin_list_export,
{"fields": ["username"]},
),
"""
if not request.user.is_staff: if not request.user.is_staff:
return HttpResponseForbidden() return HttpResponseForbidden()
if not queryset: if not queryset:

View file

@ -15,7 +15,6 @@ export_patterns = [
name="cof.mega_export_participants", name="cof.mega_export_participants",
), ),
path("mega/orgas", views.export_mega_orgas, name="cof.mega_export_orgas"), path("mega/orgas", views.export_mega_orgas, name="cof.mega_export_orgas"),
# path(r'^mega/(?P<type>.+)$', views.export_mega_bytype),
path("mega", views.export_mega, name="cof.mega_export"), path("mega", views.export_mega, name="cof.mega_export"),
] ]

View file

@ -1,3 +1,10 @@
"""
Les converters sont la méthode "clean" de faire les regex custom dans des URLs django.
Plus d'info dans la doc :
https://docs.djangoproject.com/en/2.2/topics/http/urls/#registering-custom-path-converters
"""
class TrigrammeConverter: class TrigrammeConverter:
regex = ".{3}" regex = ".{3}"