Skip to content

Commit

Permalink
Don't allow creating A/B tests if there are no differences
Browse files Browse the repository at this point in the history
  • Loading branch information
kaedroho committed Dec 15, 2020
1 parent 28307f1 commit d548de9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions wagtail_ab_testing/templates/wagtail_ab_testing/add_compare.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@
<div class="nice-padding" style="padding-top: 20px;">
<p>{% trans "This will create an A/B test comparing the published version of this page and the draft with the following differences:" %}</p>

{% include "./includes/comparison.html" %}
{% if differences %}
{% include "./includes/comparison.html" %}

<a class="button button-primary" href="{% url 'wagtail_ab_testing:add_ab_test_form' page.id %}">{% trans "Create this test" %}</a>
<a class="button button-primary" href="{% url 'wagtail_ab_testing:add_ab_test_form' page.id %}">{% trans "Create this test" %}</a>
{% else %}
<div class="help-block help-warning">
<p>{% trans "There are no differences, please go back and make some changes to set up a new test" %}
</div>
{% endif %}
</div>
{% endblock %}

Expand Down
1 change: 1 addition & 0 deletions wagtail_ab_testing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def add_compare(request, page_id):
'page': page,
'latest_revision_as_page': latest_revision_as_page,
'comparison': comparison,
'differences': any(comp.has_changed() for comp in comparison),
})


Expand Down

0 comments on commit d548de9

Please sign in to comment.