Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move URL cleaning to the form
akjanik1ecbbe23ad42
diff --git a/saleor/dashboard/page/forms.py b/saleor/dashboard/page/forms.pyindex 88162fd3f1..35501421fd 100644--- a/saleor/dashboard/page/forms.py+++ b/saleor/dashboard/page/forms.py@@ -1,5 +1,4 @@from django import forms-from django.forms import inlineformset_factoryfrom ...page.models import Pagefrom ..product.forms import RichTextField@@ -12,3 +11,11 @@ class PageForm(forms.ModelForm):exclude = []content = RichTextField()++ def clean_url(self):+ """+ Make sure url is not being written to database with uppercase.+ """+ url = self.cleaned_data.get('url')+ url = url.lower()+ return urldiff --git a/saleor/page/models.py b/saleor/page/models.pyindex ce6e5f1540..aedd6417d6 100644--- a/saleor/page/models.py+++ b/saleor/page/models.py@@ -33,10 +33,3 @@ class Page(models.Model):def get_absolute_url(self):return reverse('page:details', kwargs={'url': self.url})-- def save(self, *args, **kwargs):- """- Make sure url is not being written to database with uppercase.- """- self.url = self.url.lower()- return super(Page, self).save(*args, **kwargs)diff --git a/templates/dashboard/page/form.html b/templates/dashboard/page/form.htmlindex 7cc59c5202..fe71bf2595 100644--- a/templates/dashboard/page/form.html+++ b/templates/dashboard/page/form.html@@ -3,7 +3,7 @@{% load materializecss %}{% load staticfiles %}-{% block page_title %}{% if page.pk %}{{ page }}{% else %}{% trans 'Add new page' %}{% endif %} - {% trans 'CMS' %} - {{ block.super }}{% endblock %}+{% block page_title %}{% if page.pk %}{{ page }}{% else %}{% trans 'Add new page' %}{% endif %}{{ block.super }}{% endblock %}{% block title %}{% if page.pk %}{{ page }}{% else %}{% trans 'Add new page' %}{% endif %} - {{ block.super }}{% endblock %}@@ -56,7 +56,7 @@<div class="col s12 l4">{{ form.url|materializecss }}{{ form.available_on|materializecss }}- {{ form.visible|materializecss }}+ {{ form.is_visible|materializecss }}</div></div><div class="row">diff --git a/templates/dashboard/page/list.html b/templates/dashboard/page/list.htmlindex 2f4a066701..4855d15bd7 100644--- a/templates/dashboard/page/list.html+++ b/templates/dashboard/page/list.html@@ -59,17 +59,7 @@</div>{% paginate pages %}{% else %}- {% if is_empty %}- {% include 'dashboard/page/zero_page.html' %}- {% else %}- <div class="col s12">- <div class="not-found">- <p class="grey-text">- {% trans "No pages found." context "Empty pages list message" %}- </p>- </div>- </div>- {% endif %}+ {% include 'dashboard/page/zero_page.html' %}{% endif %}</div></div>