From 232948e5b5f5c44d6f9dd6a754d705983006fe25 Mon Sep 17 00:00:00 2001 From: Nicolas Kempf Le Stanc Date: Thu, 12 Dec 2024 14:43:11 +0100 Subject: [PATCH 1/6] feat: beta admin as default --- udata_front/theme/gouvfr/templates/header.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/udata_front/theme/gouvfr/templates/header.html b/udata_front/theme/gouvfr/templates/header.html index 40cf26968..fe5d2f815 100644 --- a/udata_front/theme/gouvfr/templates/header.html +++ b/udata_front/theme/gouvfr/templates/header.html @@ -90,7 +90,7 @@
  • From ade639a7715a3a95cff35d8190f302e499b8c2dc Mon Sep 17 00:00:00 2001 From: Nicolas Kempf Le Stanc Date: Thu, 12 Dec 2024 14:44:26 +0100 Subject: [PATCH 2/6] docs: changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed4947f4c..7fc25f991 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Current (in progress) -- Nothing yet +- Use beta admin as default [#621](https://github.com/datagouv/udata-front/pull/621) ## 6.0.6 (2024-12-09) From 6f8d27c3f7f668b6ee09233cf8047c3f817cbdcc Mon Sep 17 00:00:00 2001 From: maudetes Date: Wed, 15 Jan 2025 20:33:23 +0100 Subject: [PATCH 3/6] Add a new helper to route to the new admin if available --- udata_front/frontend/helpers.py | 14 ++++++++++++++ .../theme/gouvfr/templates/dataset/display.html | 8 ++++---- udata_front/theme/gouvfr/templates/header.html | 4 ++-- .../gouvfr/templates/organization/display.html | 2 +- udata_front/theme/gouvfr/templates/user/base.html | 2 +- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/udata_front/frontend/helpers.py b/udata_front/frontend/helpers.py index 6528d1fcd..539e6078d 100644 --- a/udata_front/frontend/helpers.py +++ b/udata_front/frontend/helpers.py @@ -109,6 +109,20 @@ def in_url(*args, **kwargs): ) +@front.app_template_global() +def beta_admin_url_for(path, fallback_path, **kwargs): + ''' + A helper to route to the new admin if available. + If NEW_ADMIN_URL is defined, we build the target url pointing to it using `path`. + Else we route to the old admin using `fallback_path`. + Kwargs are forwarded as as params in the first case and as arguments of url_for in the seconde case. + ''' + if current_app.config['NEW_ADMIN_URL']: + scheme, netloc, path, query, fragments = urlsplit(current_app.config['NEW_ADMIN_URL'] + path) + return urlunsplit((scheme, netloc, path, url_encode(kwargs), fragments)) + return url_for('admin.index', path=fallback_path, **kwargs) + + @front.app_template_filter() @pass_context def placeholder(ctx, url, name='default', external=False): diff --git a/udata_front/theme/gouvfr/templates/dataset/display.html b/udata_front/theme/gouvfr/templates/dataset/display.html index 3485ce1fb..c96f6682b 100644 --- a/udata_front/theme/gouvfr/templates/dataset/display.html +++ b/udata_front/theme/gouvfr/templates/dataset/display.html @@ -56,7 +56,7 @@
    {{ _('Edit') }} @@ -359,7 +359,7 @@

    {{ _('Add a file') }} @@ -399,7 +399,7 @@

    {{ ngettext('%(num)d Reuse', '%( {% if not read_only_mode %} @@ -422,7 +422,7 @@

    {{ ngettext('%(num)d Reuse', '%(

    {{ _('Publish a reuse') }} diff --git a/udata_front/theme/gouvfr/templates/header.html b/udata_front/theme/gouvfr/templates/header.html index fe5d2f815..306b7fd7e 100644 --- a/udata_front/theme/gouvfr/templates/header.html +++ b/udata_front/theme/gouvfr/templates/header.html @@ -7,9 +7,9 @@ {'icon': 'fr-icon-database-line', 'label': _('A dataset'), 'url': url_for('beta.datasets-new')}, {'icon': 'fr-icon-code-s-slash-line', 'label': _('An API'), 'url': url_for('beta.dataservices-new')}, {'icon': 'fr-icon-line-chart-line', 'label': _('A reuse'), 'url': url_for('beta.reuses-new')}, - {'icon': 'fr-icon-server-line', 'label': _('A harvester'), 'url': url_for('admin.index', path='harvester/new/')}, + {'icon': 'fr-icon-server-line', 'label': _('A harvester'), 'url': beta_admin_url_for(path='harvesters/new', fallback_path='harvester/new/')}, {'icon': 'fr-icon-government-line', 'label': _('An organization'), 'url': url_for('beta.organizations-new')}, -] + ([{'icon': 'fr-icon-article-line', 'label': _('A post'), 'url': url_for('admin.index', path='post/new/')}] if current_user.sysadmin else []) +] + ([{'icon': 'fr-icon-article-line', 'label': _('A post'), 'url': beta_admin_url_for(path='posts/new/', fallback_path='post/new/')}] if current_user.sysadmin else []) %}