diff --git a/src/personalisation/forms.py b/src/personalisation/forms.py index ad7ac5f..63deaa5 100644 --- a/src/personalisation/forms.py +++ b/src/personalisation/forms.py @@ -5,17 +5,42 @@ from django.conf import settings from django.utils.translation import ugettext as _ from wagtail.wagtailcore.models import Page -from personalisation.models import Segment +from wagtail.wagtailadmin.forms import WagtailAdminModelForm + +from personalisation.models import (ReferralRule, Segment, TimeRule, + VisitCountRule) class SegmentForm(forms.ModelForm): - """ - Custom Segment form for the create view - """ + """Custom Segment form for the create view.""" class Meta: + """Why does this need a docstring? I do not know.""" model = Segment fields = ( 'name', 'status', ) +class TimeRuleForm(WagtailAdminModelForm): + """Create a form for the time rule model.""" + title = "Time" + description = "Choose a time segment in which the user visits the site." + class Meta: + model = TimeRule + fields = ['start_time', 'end_time'] + +class ReferralRuleForm(WagtailAdminModelForm): + """Create a form for the referral rule model.""" + title = "Referrer" + description = "Define a referring page, domain or query the user has to come from." + class Meta: + model = ReferralRule + fields = ['regex_string'] + +class VisitCountRuleForm(WagtailAdminModelForm): + """Create a form for the visit count rule model.""" + title = "Visit count" + description = "Choose the number of visits the user has to have made." + class Meta: + model = VisitCountRule + fields = ['operator', 'count'] diff --git a/src/personalisation/templates/modeladmin/personalisation/segment/create.html b/src/personalisation/templates/modeladmin/personalisation/segment/create.html index 1e5ed8f..e5f7a17 100644 --- a/src/personalisation/templates/modeladmin/personalisation/segment/create.html +++ b/src/personalisation/templates/modeladmin/personalisation/segment/create.html @@ -7,18 +7,26 @@ {% include "wagtailadmin/shared/header.html" with title=view.get_page_title subtitle=view.get_page_subtitle icon=view.header_icon tabbed=1 merged=1 %} {% endblock %} - - {{ modal_content }} -
{% csrf_token %} {% block form %} {{ edit_handler.render_form_content }} - {% endblock %} - + {% endblock %} {% block footer %}