From c61fcd482e7059b91c1acc0effe6e0bf95402d2e Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Tue, 15 Dec 2020 18:52:06 +0000 Subject: [PATCH] Add buttons into each variant at final step --- .../static_src/style/progress.scss | 4 ++++ .../templates/wagtail_ab_testing/results.html | 14 +++++++++++ wagtail_ab_testing/views.py | 24 ++++--------------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/wagtail_ab_testing/static_src/style/progress.scss b/wagtail_ab_testing/static_src/style/progress.scss index 93a83d0..341bbdb 100644 --- a/wagtail_ab_testing/static_src/style/progress.scss +++ b/wagtail_ab_testing/static_src/style/progress.scss @@ -128,6 +128,10 @@ $charcoal-grey: #333; font-weight: bold; font-size: 20px; } + + .button span { + font-weight: bold; + } } &__variant-stats { diff --git a/wagtail_ab_testing/templates/wagtail_ab_testing/results.html b/wagtail_ab_testing/templates/wagtail_ab_testing/results.html index 902f991..871c012 100644 --- a/wagtail_ab_testing/templates/wagtail_ab_testing/results.html +++ b/wagtail_ab_testing/templates/wagtail_ab_testing/results.html @@ -69,6 +69,13 @@

{% trans "Control" %} {% icon n + + {% if ab_test.status == 'finished' %} +
+ {% csrf_token %} + +
+ {% endif %}
diff --git a/wagtail_ab_testing/views.py b/wagtail_ab_testing/views.py index 7ba13ff..ba5f9df 100644 --- a/wagtail_ab_testing/views.py +++ b/wagtail_ab_testing/views.py @@ -171,7 +171,7 @@ def is_shown(self, request, context): if not context['user_page_permissions'].for_page(context['ab_test'].page).can_publish(): return False - return context['ab_test'].status in [AbTest.Status.DRAFT, AbTest.Status.RUNNING, AbTest.Status.PAUSED, AbTest.Status.FINISHED] + return context['ab_test'].status in [AbTest.Status.DRAFT, AbTest.Status.RUNNING, AbTest.Status.PAUSED] class PauseAbTestMenuItem(ActionMenuItem): @@ -185,22 +185,6 @@ def is_shown(self, request, context): return context['ab_test'].status == AbTest.Status.RUNNING -class SelectControlMenuItem(ActionMenuItem): - name = 'action-select-control' - label = _("Revert to control") - - def is_shown(self, request, context): - return context['ab_test'].status == AbTest.Status.FINISHED - - -class SelectTreatmentMenuItem(ActionMenuItem): - name = 'action-select-treatment' - label = _("Publish treatment") - - def is_shown(self, request, context): - return context['ab_test'].status == AbTest.Status.FINISHED - - class AbTestActionMenu: template = 'wagtailadmin/pages/action_menu/menu.html' @@ -214,8 +198,6 @@ def __init__(self, request, **kwargs): RestartAbTestMenuItem(order=1), EndAbTestMenuItem(order=2), PauseAbTestMenuItem(order=3), - SelectControlMenuItem(order=4), - SelectTreatmentMenuItem(order=5), ] self.menu_items = [ @@ -368,6 +350,8 @@ def progress(request, page, ab_test): if ab_test.status == AbTest.Status.FINISHED: ab_test.complete(AbTest.CompletionAction.REVERT, user=request.user) + messages.success(request, _("The page has been reverted back to the control version.")) + else: messages.error(request, _("The A/B test cannot be paused because it is not running.")) @@ -376,6 +360,8 @@ def progress(request, page, ab_test): # TODO Permission check? ab_test.complete(AbTest.CompletionAction.PUBLISH, user=request.user) + messages.success(request, _("The treatment version has been published.")) + else: messages.error(request, _("The A/B test cannot be paused because it is not running."))