From 620b465cc2ba104bcc5c72e63e8b6c53d3e38c9d Mon Sep 17 00:00:00 2001 From: Tom Dyson Date: Thu, 19 Nov 2020 15:35:47 +0000 Subject: [PATCH 1/8] Remove Deployment model, manage builds through UI --- wagtailnetlify/__init__.py | 2 +- wagtailnetlify/admin_urls.py | 7 +++ wagtailnetlify/management/commands/netlify.py | 37 +++++------ wagtailnetlify/models.py | 21 +++---- .../wagtailnetlify/deploy_listing.html | 63 +++++++++++++++++++ wagtailnetlify/urls.py | 7 +-- wagtailnetlify/utils.py | 32 ++++++++++ wagtailnetlify/views.py | 35 +++++------ wagtailnetlify/wagtail_hooks.py | 41 +++++------- 9 files changed, 163 insertions(+), 82 deletions(-) create mode 100644 wagtailnetlify/admin_urls.py create mode 100644 wagtailnetlify/templates/wagtailnetlify/deploy_listing.html create mode 100644 wagtailnetlify/utils.py diff --git a/wagtailnetlify/__init__.py b/wagtailnetlify/__init__.py index 1ea903c..26421e1 100644 --- a/wagtailnetlify/__init__.py +++ b/wagtailnetlify/__init__.py @@ -1 +1 @@ -__version__ = "0.7" +__version__ = "0.8" diff --git a/wagtailnetlify/admin_urls.py b/wagtailnetlify/admin_urls.py new file mode 100644 index 0000000..61c6e59 --- /dev/null +++ b/wagtailnetlify/admin_urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import url +from wagtailnetlify.views import list_deploys, do_deploy + +urlpatterns = [ + url(r"^deployments$", list_deploys, name="list_deploys"), + url(r"^deployments/create$", do_deploy, name="do_deploy"), +] diff --git a/wagtailnetlify/management/commands/netlify.py b/wagtailnetlify/management/commands/netlify.py index 17344c1..6088151 100644 --- a/wagtailnetlify/management/commands/netlify.py +++ b/wagtailnetlify/management/commands/netlify.py @@ -3,7 +3,6 @@ import requests from django.core.management.base import BaseCommand, CommandError from django.conf import settings -from wagtailnetlify.models import Deployment try: from wagtail.contrib.redirects.models import Redirect @@ -25,19 +24,18 @@ def build_redirects(): class Command(BaseCommand): - help = "Deploys your baked Wagtail site to Netlify" + help = "Deploys your site to Netlify, or triggers a build" def write_redirects(self): - """ Redirects are configured in a file called '_redirects' - at the root of the build directory + """Redirects are configured in a file called '_redirects' + at the root of the build directory """ if not hasattr(settings, "BUILD_DIR"): raise CommandError("BUILD_DIR is not defined in settings") redirect_file = os.path.join(settings.BUILD_DIR, "_redirects") redirects_str, count = build_redirects() - fo = open(redirect_file, "w") - fo.write(redirects_str) - fo.close() + with open(redirect_file, "w") as fo: + fo.write(redirects_str) self.stdout.write("Written %s redirect(s)" % (count)) def trigger_build(self): @@ -61,13 +59,13 @@ def deploy(self): if not netlify_cli: raise CommandError("NETLIFY_PATH is not defined in settings") - deployment = Deployment() - deployment.save() - - command = [netlify_cli, "deploy"] - command.append("--dir={}".format(settings.BUILD_DIR)) - command.append("--prod") - command.append('--message="Wagtail Deployment #{}"'.format(deployment.pk)) + command = [ + netlify_cli, + "deploy", + "--dir={}".format(settings.BUILD_DIR), + "--prod", + '--message="Wagtail Deployment #{}"'.format(deployment.pk), + ] site_id = getattr(settings, "NETLIFY_SITE_ID", None) if site_id: @@ -81,22 +79,21 @@ def deploy(self): def add_arguments(self, parser): parser.add_argument( - "-n", "--no-deploy", - action="store_true", - help="Do not deploy" + "-n", "--no-deploy", action="store_true", help="Do not deploy" ) parser.add_argument( - "-t", "--trigger-build", + "-t", + "--trigger-build", action="store_true", - help="Trigger build on Netlify" + help="Trigger build on Netlify", ) def handle(self, *args, **kwargs): - no_deploy = kwargs["no_deploy"] trigger = kwargs["trigger_build"] if trigger: self.trigger_build() else: self.write_redirects() + no_deploy = kwargs["no_deploy"] if not no_deploy: self.deploy() diff --git a/wagtailnetlify/models.py b/wagtailnetlify/models.py index d3f09c4..caa9fad 100644 --- a/wagtailnetlify/models.py +++ b/wagtailnetlify/models.py @@ -1,5 +1,4 @@ from threading import Thread -from django.db import models from django.core.management import call_command from django.db import connection from django.conf import settings @@ -11,16 +10,6 @@ from wagtail.core.signals import page_published -class Deployment(models.Model): - netlify_id = models.CharField(max_length=30, null=True) - url = models.URLField(null=True) - deployment_url = models.URLField(null=True) - datetime_started = models.DateTimeField( - auto_now_add=True, help_text="deployment started" - ) - datetime_finished = models.DateTimeField("deployment completed", null=True) - - def postpone(function): """ Cheap aysnc, see https://stackoverflow.com/a/28913218 @@ -34,8 +23,7 @@ def decorator(*args, **kwargs): return decorator -@postpone -def deploy(sender, **kwargs): +def deploy(): """ Trigger a build on Netlify, if NETLIFY_BUILD_HOOK is supplied, or build static pages, then upload incremental changes to Netlify. @@ -46,12 +34,17 @@ def deploy(sender, **kwargs): else: call_command("build") call_command("netlify") + + +@postpone +def async_deploy(sender, **kwargs): + deploy() connection.close() if getattr(settings, "NETLIFY_AUTO_DEPLOY", False) == True: function_path = getattr( - settings, "NETLIFY_DEPLOY_FUNCTION", "wagtailnetlify.models.deploy" + settings, "NETLIFY_DEPLOY_FUNCTION", "wagtailnetlify.models.async_deploy" ) function = import_string(function_path) page_published.connect(function) diff --git a/wagtailnetlify/templates/wagtailnetlify/deploy_listing.html b/wagtailnetlify/templates/wagtailnetlify/deploy_listing.html new file mode 100644 index 0000000..7bfe759 --- /dev/null +++ b/wagtailnetlify/templates/wagtailnetlify/deploy_listing.html @@ -0,0 +1,63 @@ +{% extends "wagtailadmin/base.html" %} + +{% block titletag %}Netlify deployments{% endblock %} + +{% block content %} +{% block header %} +
+
+
+
+

+ + Netlify Deployments

+
+
+ {% block header_extra %} + + {% endblock %} +
+
+{% endblock %} + +
+
+
+ + + + + + + + + + + {% for deploy in deploys %} + + + + + + + {% endfor %} + +
DeploymentStatusTime takenStarted at
{{ deploy.title }} + (logs){{ deploy.state|title }} + {% if deploy.deploy_time %} + {{ deploy.deploy_time }} seconds + {% else %} + - + {% endif %} + {{ deploy.created_at_parsed }}
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/wagtailnetlify/urls.py b/wagtailnetlify/urls.py index e9e3363..ff3c04b 100644 --- a/wagtailnetlify/urls.py +++ b/wagtailnetlify/urls.py @@ -1,7 +1,4 @@ from django.conf.urls import url -from wagtailnetlify.views import success_hook, redirects +from wagtailnetlify.views import redirects -urlpatterns = [ - url(r"^success$", success_hook, name="success_hook"), - url(r"^redirects$", redirects, name="redirect_builder"), -] +urlpatterns = [url(r"^redirects$", redirects, name="redirect_builder")] diff --git a/wagtailnetlify/utils.py b/wagtailnetlify/utils.py new file mode 100644 index 0000000..61fe824 --- /dev/null +++ b/wagtailnetlify/utils.py @@ -0,0 +1,32 @@ +from dateutil.parser import parse +import requests +from django.conf import settings + + +API_ROOT = "https://api.netlify.com/api/v1/" +HEADERS = { + "Authorization": str("Bearer " + settings.NETLIFY_API_TOKEN), + "Content-type": "application/json", +} + + +def get_site_name(): + site_details_url = API_ROOT + "sites/" + settings.NETLIFY_SITE_ID + resp = requests.get(site_details_url, headers=HEADERS) + return resp.json()["name"] + + +def netlify_deploys(): + site_name = get_site_name() + deploys_listing_url = ( + API_ROOT + "sites/" + settings.NETLIFY_SITE_ID + "/deploys?per_page=5" + ) + deploys = requests.get(deploys_listing_url, headers=HEADERS).json() + + for deploy in deploys: + deploy["admin_url"] = ( + "https://app.netlify.com/sites/" + site_name + "/deploys/" + deploy["id"] + ) + deploy["created_at_parsed"] = parse(deploy["created_at"]) + + return deploys diff --git a/wagtailnetlify/views.py b/wagtailnetlify/views.py index 17a388f..ecc4464 100644 --- a/wagtailnetlify/views.py +++ b/wagtailnetlify/views.py @@ -1,28 +1,27 @@ import json from django.http import HttpResponse from django.views.decorators.csrf import csrf_exempt +from django.shortcuts import render, redirect from django.utils import timezone -from wagtailnetlify.models import Deployment from wagtailnetlify.management.commands.netlify import build_redirects - - -@csrf_exempt -def success_hook(request): - """ Handle incoming webhook from Netlify, to record deployment completion """ - body_unicode = request.body.decode("utf-8") - payload = json.loads(body_unicode) - # get the first deployment without a Netlify ID - deployment = ( - Deployment.objects.filter(netlify_id__isnull=True).order_by("id").first() - ) - deployment.netlify_id = payload["id"] - deployment.url = payload["url"] - deployment.deployment_url = payload["deploy_ssl_url"] - deployment.datetime_finished = timezone.now() - deployment.save() - return HttpResponse("Thanks\n") +from .utils import netlify_deploys +from .models import deploy def redirects(request): redirects_str, count = build_redirects() return HttpResponse(redirects_str) + + +def list_deploys(request): + deploys = netlify_deploys() + return render( + request, + "wagtailnetlify/deploy_listing.html", + {"deploys": deploys}, + ) + + +def do_deploy(request): + deploy() # non-async deploy + return redirect(list_deploys) \ No newline at end of file diff --git a/wagtailnetlify/wagtail_hooks.py b/wagtailnetlify/wagtail_hooks.py index bc1ab34..09b69fc 100644 --- a/wagtailnetlify/wagtail_hooks.py +++ b/wagtailnetlify/wagtail_hooks.py @@ -1,29 +1,22 @@ -from django.conf import settings -from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register -from wagtail.contrib.modeladmin.helpers import PermissionHelper -from wagtailnetlify.models import Deployment +from wagtail.core import hooks +from wagtail.admin.menu import AdminOnlyMenuItem +from django.urls import include, reverse, path +from . import admin_urls -class DeploymentPermissionHelper(PermissionHelper): - # remove the add Deployment button - def user_can_create(self, user): - return False - def user_can_edit_obj(self, user, obj): - return False +@hooks.register("register_admin_urls") +def register_admin_urls(): + return [ + path(r"netlify/", include(admin_urls)), + ] -class DeploymentAdmin(ModelAdmin): - model = Deployment - menu_icon = 'success' - menu_order = 0 - add_to_settings_menu = True - exclude_from_explorer = False - list_display = ('datetime_started', 'datetime_finished', 'deployment_url', 'url') - list_filter = ('datetime_started',) - inspect_view_enabled=True - permission_helper_class = DeploymentPermissionHelper - - -if 'wagtail.contrib.modeladmin' in settings.INSTALLED_APPS: - modeladmin_register(DeploymentAdmin) +@hooks.register("register_admin_menu_item") +def register_netlify_menu_item(): + return AdminOnlyMenuItem( + "Netlify", + reverse("list_deploys"), + classnames="icon icon-collapse-down", + order=1000, + ) \ No newline at end of file From cdcc328023b3da2710debc846dd705d4d7db059b Mon Sep 17 00:00:00 2001 From: Tom Dyson Date: Thu, 19 Nov 2020 15:45:40 +0000 Subject: [PATCH 2/8] Update changelog --- CHANGELOG.md | 12 ++++++++++++ wagtailnetlify/utils.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3df415c..2ed4ac0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. ... +## v0.8 + +Significant update, with backwards-incompatible changes. +The `Deployment` model has been removed, in favour of direct +integration with the Netlify API. A new view for Wagtail +administrators lists the last ten builds, with the option of +triggering new builds. + +### Added + +- Admin UI integration with the Netlify build API + ## v0.7 ### Added diff --git a/wagtailnetlify/utils.py b/wagtailnetlify/utils.py index 61fe824..e6162a9 100644 --- a/wagtailnetlify/utils.py +++ b/wagtailnetlify/utils.py @@ -19,7 +19,7 @@ def get_site_name(): def netlify_deploys(): site_name = get_site_name() deploys_listing_url = ( - API_ROOT + "sites/" + settings.NETLIFY_SITE_ID + "/deploys?per_page=5" + API_ROOT + "sites/" + settings.NETLIFY_SITE_ID + "/deploys?per_page=10" ) deploys = requests.get(deploys_listing_url, headers=HEADERS).json() From af4819efa2b17b79fca2fa0e03680d38515e7a49 Mon Sep 17 00:00:00 2001 From: Tom Dyson Date: Thu, 19 Nov 2020 15:55:02 +0000 Subject: [PATCH 3/8] Remove support for Wagtail <2 --- CHANGELOG.md | 4 ++++ wagtailnetlify/management/commands/netlify.py | 8 ++------ wagtailnetlify/models.py | 6 +----- wagtailnetlify/views.py | 3 --- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ed4ac0..e26d3c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ triggering new builds. - Admin UI integration with the Netlify build API +### Removed + +- Support for Wagtail < 2 + ## v0.7 ### Added diff --git a/wagtailnetlify/management/commands/netlify.py b/wagtailnetlify/management/commands/netlify.py index 6088151..b72ff78 100644 --- a/wagtailnetlify/management/commands/netlify.py +++ b/wagtailnetlify/management/commands/netlify.py @@ -3,11 +3,7 @@ import requests from django.core.management.base import BaseCommand, CommandError from django.conf import settings - -try: - from wagtail.contrib.redirects.models import Redirect -except ImportError: # Wagtail < 2.0 - from wagtail.wagtailredirects.models import Redirect +from wagtail.contrib.redirects.models import Redirect def build_redirects(): @@ -64,7 +60,7 @@ def deploy(self): "deploy", "--dir={}".format(settings.BUILD_DIR), "--prod", - '--message="Wagtail Deployment #{}"'.format(deployment.pk), + '--message="Wagtail Deployment"', ] site_id = getattr(settings, "NETLIFY_SITE_ID", None) diff --git a/wagtailnetlify/models.py b/wagtailnetlify/models.py index caa9fad..8a9dd56 100644 --- a/wagtailnetlify/models.py +++ b/wagtailnetlify/models.py @@ -3,11 +3,7 @@ from django.db import connection from django.conf import settings from django.utils.module_loading import import_string - -try: - from wagtail.wagtailcore.signals import page_published -except ImportError: # Wagtail < 2.0 - from wagtail.core.signals import page_published +from wagtail.core.signals import page_published def postpone(function): diff --git a/wagtailnetlify/views.py b/wagtailnetlify/views.py index ecc4464..caca6b2 100644 --- a/wagtailnetlify/views.py +++ b/wagtailnetlify/views.py @@ -1,8 +1,5 @@ -import json from django.http import HttpResponse -from django.views.decorators.csrf import csrf_exempt from django.shortcuts import render, redirect -from django.utils import timezone from wagtailnetlify.management.commands.netlify import build_redirects from .utils import netlify_deploys from .models import deploy From f1644539d6bd0b653655febc0cce37239a52d58c Mon Sep 17 00:00:00 2001 From: Tom Dyson Date: Thu, 19 Nov 2020 15:56:53 +0000 Subject: [PATCH 4/8] Require Wagtail 2+ at installation --- setup.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/setup.py b/setup.py index f41f382..3abf49a 100644 --- a/setup.py +++ b/setup.py @@ -1,24 +1,23 @@ from setuptools import setup, find_packages from wagtailnetlify import __version__ -with open('README.md', 'r') as fh: +with open("README.md", "r") as fh: long_description = fh.read() setup( - name='wagtailnetlify', + name="wagtailnetlify", version=__version__, - description='Deploy Wagtail sites to Netlify', + description="Deploy Wagtail sites to Netlify", long_description=long_description, long_description_content_type="text/markdown", - url='https://github.com/tomdyson/wagtail-netlify', - author='Tom Dyson', - author_email='tom+wagtailnetlify@torchbox.com', - license='MIT', + url="https://github.com/tomdyson/wagtail-netlify", + author="Tom Dyson", + author_email="tom+wagtailnetlify@torchbox.com", + license="MIT", classifiers=[ "Environment :: Web Environment", "Framework :: Django", "Framework :: Wagtail", - "Framework :: Wagtail :: 1", "Framework :: Wagtail :: 2", "Intended Audience :: Developers", "Operating System :: OS Independent", @@ -26,12 +25,9 @@ "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", ], - keywords='development', + keywords="development", packages=find_packages(), include_package_data=True, zip_safe=False, - install_requires=[ - "wagtail>=1.6", - "wagtail-bakery>=0.3.0" - ], + install_requires=["wagtail>=2.0", "wagtail-bakery>=0.3.0"], ) From 515dc334429aae2ee8ef1bd4daaa53b1b22fd2f7 Mon Sep 17 00:00:00 2001 From: Tom Dyson Date: Fri, 27 Nov 2020 17:58:40 +0000 Subject: [PATCH 5/8] Update documentation --- README.md | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 380cf19..eb4b956 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ Deploy your Wagtail site on Netlify. Features include: - - automatic deployment when pages are published + - the ability to build locally and push them to Netlify, or trigger builds on Netlify's servers + - (optional) automatic deployment when pages are published + - an admin UI for viewing and creating Netlify builds - a new `netlify` management command - conversion of Wagtail redirects to Netlify's format @@ -48,13 +50,13 @@ The path to the Netlify CLI. *Hint: type `which netlify` to check the location.* If set, deploy to that specific Netlify site. -If not set, the Netlify CLI might prompt you to select one. +If not set, the Netlify CLI might prompt you to select one. This setting is required for the admin view. ### `NETLIFY_API_TOKEN` **Default: `None`** -If set, the Netlify CLI will not prompt you to click the authentication link in the console. It can be useful when deployed to a remote server where you don't see the console output. +If set, the Netlify CLI will not prompt you to click the authentication link in the console. It can be useful when deployed to a remote server where you don't see the console output. This setting is required for the admin view. Connect to your Netlify account to [generate a token](https://app.netlify.com/account/applications) and then set the settings. *Warning: You should never check credentials in your version control system. Use [environment variables](https://django-environ.readthedocs.io/en/latest/) or [local settings file](http://techstream.org/Bits/Local-Settings-in-django) instead.* @@ -80,12 +82,17 @@ The URL of a Netlify build hook. If provided, `./manage.py netlify --trigger-bui on Netlify's servers. This may be useful if you have a headless front-end on Netlify which handles its own static site generation, e.g. Nuxt, Next or Gatsby. See https://docs.netlify.com/configure-builds/build-hooks/ for more details. -### Optional admin view and endpoints +### Admin view -Netlify can send a webhook after a successful deployment. This app provides an endpoint for that webhook and an admin view of completed deployments. To enable this view: +This view allows Wagtail administrators to see a list of recent Netlify builds, and trigger a new one. Both `NETLIFY_API_TOKEN` and `NETLIFY_SITE_ID` should be available in settings. If `NETLIFY_BUILD_HOOK` has been set, new builds will be created by triggering a build on Netlify's servers; if not, wagtail-netlify will attempt to build the site locally and push it to Netlify. -1. Add `wagtail.contrib.modeladmin` to your `INSTALLED_APPS` -1. Update your project's `urls.py`: +The view will be available to Wagtail administrators as a new `Netlify` menu item. + +### Redirects + +Including the `wagtailnetlify` URLs will enable a view at /netlify/redirects, which outputs any Wagtail redirects in [Netlify's plain text format](https://docs.netlify.com/routing/redirects/#syntax-for-the-redirects-file). This may be useful if you are using Netlify to host a headless front-end for your Wagtail site. + +To enable this view, update your project's `urls.py`: ```python # in your imports @@ -95,11 +102,11 @@ from wagtailnetlify import urls as netlify_urls url(r"^netlify/", include(netlify_urls)), ``` -3. In Netlify's admin interface for your app, add http://yourdomain/netlify/success as a URL to notify for the outgoing webhook on *Deploy succeeded* events (in Settings / Build & deploy / Deploy notifications). +To include the generated redirects in your Netlify-hosted front-end, you should fetch them from the back-end server as part of your front-end build. For example, for a Nuxt site, the build command could be: -The view will be available under `Settings / Deployments` in your site's admin. - -Including the `wagtailnetlify` URLs will also enable a view at /netlify/redirects, which outputs any Wagtail redirects in [Netlify's plain text format](https://docs.netlify.com/routing/redirects/#syntax-for-the-redirects-file). This may be useful if you are using Netlify to host a headless front-end for your Wagtail site. +```bash +yarn build && yarn export && wget -O dist/_redirects https://your-wagtail-backend/netlify/redirects +``` ## Development From 252c6276db6864cd4b8683bf85b9e908b013dda6 Mon Sep 17 00:00:00 2001 From: Tom Dyson Date: Fri, 27 Nov 2020 18:30:46 +0000 Subject: [PATCH 6/8] Redirect to view by name, not instance --- wagtailnetlify/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wagtailnetlify/views.py b/wagtailnetlify/views.py index caca6b2..4238a4f 100644 --- a/wagtailnetlify/views.py +++ b/wagtailnetlify/views.py @@ -21,4 +21,4 @@ def list_deploys(request): def do_deploy(request): deploy() # non-async deploy - return redirect(list_deploys) \ No newline at end of file + return redirect("list_deploys") From e0c1557fa05a6a3b93b1b0084b5fb484a298521e Mon Sep 17 00:00:00 2001 From: Tom Dyson Date: Fri, 27 Nov 2020 18:41:37 +0000 Subject: [PATCH 7/8] Ignore IDE settings --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 7bbc71c..71fce44 100644 --- a/.gitignore +++ b/.gitignore @@ -99,3 +99,5 @@ ENV/ # mypy .mypy_cache/ + +.vscode/ \ No newline at end of file From 2c62bad7ee4b38c1c0254961eb153a9dc96afcc8 Mon Sep 17 00:00:00 2001 From: Tom Dyson Date: Wed, 4 May 2022 14:36:04 +0100 Subject: [PATCH 8/8] Update for Django 4 compatibility --- wagtailnetlify/admin_urls.py | 6 +++--- wagtailnetlify/urls.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wagtailnetlify/admin_urls.py b/wagtailnetlify/admin_urls.py index 61c6e59..7979556 100644 --- a/wagtailnetlify/admin_urls.py +++ b/wagtailnetlify/admin_urls.py @@ -1,7 +1,7 @@ -from django.conf.urls import url +from django.urls import re_path from wagtailnetlify.views import list_deploys, do_deploy urlpatterns = [ - url(r"^deployments$", list_deploys, name="list_deploys"), - url(r"^deployments/create$", do_deploy, name="do_deploy"), + re_path(r"^deployments$", list_deploys, name="list_deploys"), + re_path(r"^deployments/create$", do_deploy, name="do_deploy"), ] diff --git a/wagtailnetlify/urls.py b/wagtailnetlify/urls.py index ff3c04b..72ef45f 100644 --- a/wagtailnetlify/urls.py +++ b/wagtailnetlify/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import url +from django.urls import re_path from wagtailnetlify.views import redirects -urlpatterns = [url(r"^redirects$", redirects, name="redirect_builder")] +urlpatterns = [re_path(r"^redirects$", redirects, name="redirect_builder")]