Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Remove css materialize files

IKarbowiak2094ec4854ee
diff --git a/saleor/core/templatetags/materializecss.py b/saleor/core/templatetags/materializecss.py
deleted file mode 100644
index ec1c754672..0000000000
--- a/saleor/core/templatetags/materializecss.py
+++ /dev/null
@@ -1,112 +0,0 @@
-from django import forms, template
-from django.template.loader import get_template
-from django_filters.widgets import RangeWidget
-
-from .widgets import CharsLeftWidget, DateRangeWidget, MoneyRangeWidget
-
-register = template.Library()
-
-
-def materializecss(element, label_cols=None):
- if not label_cols:
- label_cols = "s12"
-
- markup_classes = {"label": label_cols, "value": "", "single_value": ""}
- return render(element, markup_classes)
-
-
-def add_input_classes(field):
- if not any(
- [
- is_checkbox(field),
- is_checkbox_select_multiple(field),
- is_radio(field),
- is_file(field),
- ]
- ):
- field_classes = field.field.widget.attrs.get("class", "")
- if field.errors:
- field_classes = " ".join([field_classes, "invalid"])
- field.field.widget.attrs["class"] = field_classes
-
-
-def render(element, markup_classes):
- element_type = element.__class__.__name__.lower()
-
- if element_type == "boundfield":
- add_input_classes(element)
- template = get_template("materializecssform/field.html")
- context = {"field": element, "classes": markup_classes}
- else:
- has_management = getattr(element, "management_form", None)
- if has_management:
- for form in element.forms:
- for field in form.visible_fields():
- add_input_classes(field)
-
- template = get_template("materializecssform/formset.html")
- context = {"formset": element, "classes": markup_classes}
- else:
- for field in element.visible_fields():
- add_input_classes(field)
-
- template = get_template("materializecssform/form.html")
- context = {"form": element, "classes": markup_classes}
-
- return template.render(context)
-
-
-def is_checkbox(field):
- return isinstance(field.field.widget, forms.CheckboxInput)
-
-
-def is_textarea(field):
- return isinstance(field.field.widget, forms.Textarea)
-
-
-def is_radio(field):
- return isinstance(field.field.widget, forms.RadioSelect)
-
-
-def is_date_input(field):
- return isinstance(field.field.widget, (forms.DateInput, forms.DateTimeInput))
-
-
-def is_file(field):
- return isinstance(field.field.widget, forms.FileInput)
-
-
-def is_select(field):
- return isinstance(field.field.widget, forms.Select)
-
-
-def is_checkbox_select_multiple(field):
- return isinstance(field.field.widget, forms.CheckboxSelectMultiple)
-
-
-def is_range(field):
- return isinstance(field.field.widget, RangeWidget)
-
-
-def is_date_range(field):
- return isinstance(field.field.widget, DateRangeWidget)
-
-
-def is_price_range(field):
- return isinstance(field.field.widget, MoneyRangeWidget)
-
-
-def is_chars_left(field):
- return isinstance(field.field.widget, CharsLeftWidget)
diff --git a/templates/materializecssform/LICENSE b/templates/materializecssform/LICENSE
deleted file mode 100644
index 80ec237cd8..0000000000
--- a/templates/materializecssform/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-This software includes part of the materialize-css-form library: Copyright (c) 2015 Florent CLAPIÉ
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/templates/materializecssform/field.html b/templates/materializecssform/field.html
deleted file mode 100644
index 15a04993eb..0000000000
--- a/templates/materializecssform/field.html
+++ /dev/null
@@ -1,434 +0,0 @@
-{% load i18n %}
-{% load materializecss %}
-{% load utils %}
-
-{% if field|is_checkbox %}
- <div class="input input-field col {{ classes.label }}">
- <div class="{{ classes.single_value }}">
- <div>
- {% if field.auto_id %}
- <input id="{{ field.auto_id }}" name="{{ field.html_name }}" class="filled-in" type="checkbox"{% if field.value %} checked="checked" {% endif %} {% if field.field.disabled %} disabled {% endif %}>
- <label for="{{ field.auto_id }}">
- {{ field.label }}
- {% for error in field.errors %}
- <p class="help-block materialize-red-text">{{ error }}</p>
- {% endfor %}
- {% if field.help_text %}
- <p class="help-block">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- </label>
- {% endif %}
- </div>
- </div>
- </div>
-{% elif field|is_checkbox_select_multiple %}
- <div class="input input-field col {{ classes.label }}">
- {% if field.auto_id %}
- <label class="control-label {{ classes.label }}">
- {{ field.label }}
- {% if not field.field.required %}
- {% trans "(optional)" context "Dashboard form labels" %}
- {% endif %}
- </label>
- {% endif %}
- {% for choice in field %}
- <p>
- <input id="{{ choice.id_for_label }}" name="{{ choice.data.name }}" class="filled-in" type="checkbox" value="{{ choice.data.value }}" {% if choice.data.selected %} checked="checked" {% endif %}>
- <label for="{{ choice.id_for_label }}">
- {{ choice.choice_label }}
- </label>
- </p>
- {% endfor %}
- {% for error in field.errors %}
- <p class="help-block materialize-red-text">
- {{ error }}
- </p>
- {% endfor %}
- {% if field.help_text %}
- <p class="help-block">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- </div>
-{% elif field|is_radio %}
- <div class="input input-field col {{ classes.label }}">
- {% if field.auto_id %}
- <label class="control-label {{ classes.label }}">
- {{ field.label }}{% if not field.field.required %} {% trans "(optional)" context "Dashboard form labels" %}{% endif %}
- </label>
- {% endif %}
- {% for choice in field %}
- <p>
- {{ choice.tag }}
- <label for="{{ choice.id_for_label }}">
- {{ choice.choice_label }}
- </label>
- </p>
- {% endfor %}
- {% for error in field.errors %}
- <p class="help-block materialize-red-text">
- {{ error }}
- </p>
- {% endfor %}
- {% if field.help_text %}
- <p class="help-block">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- </div>
-{% elif field|is_date_input %}
- <div class="input input-field col {{ classes.label }}">
- <label class="active" for="{{ field.auto_id }}">
- {{ field.label }}
- {% if not field.field.required %}
- {% trans "(optional)" context "Dashboard form labels" %}
- {% endif %}
- </label>
- <input type="date" id="{{ field.auto_id }}" class="datepicker" name="{{ field.name }}"
- value="{% if field.value %}{{ field.value|date:"Y-m-d" }}{% endif %}" data-value="{% if field.value %}{{ field.value|date:"Y-m-d"|default:field.value }}{% endif %}">
- {% for error in field.errors %}
- <p class="help-block materialize-red-text">
- {{ error }}
- </p>
- {% endfor %}
- {% if field.help_text %}
- <p class="help-block">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- </div>
-{% elif field|is_select %}
- <div class="input input-field col {{ classes.label }}">
- {% if field|is_checkbox_select_multiple %}
- {% if field.auto_id %}
- <label class="control-label {{ classes.label }}">
- {{ field.label }}
- {% if not field.field.required %}
- {% trans "(optional)" context "Dashboard form labels" %}
- {% endif %}
- </label>
- {% endif %}
- <div class="{{ classes.value }}">
- {% for choice in field %}
- <p>
- {{ choice.tag }}
- <label for="{{ choice.id_for_label }}">
- {{ choice.choice_label }}
- </label>
- </p>
- {% endfor %}
- {% for error in field.errors %}
- <p class="help-block materialize-red-text">
- {{ error }}
- </p>
- {% endfor %}
- {% if field.help_text %}
- <p class="help-block">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- </div>
- {% else %}
- <label for="{{ field.id_for_label }}">
- {{ field.label }}{% if not field.field.required %} {% trans "(optional)" context "Dashboard form labels" %}{% endif %}
- </label>
- {{ field }}
- {% for error in field.errors %}
- <p class="help-block materialize-red-text">
- {{ error }}
- </p>
- {% endfor %}
- {% if field.help_text %}
- <p class="help-block">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- {% endif %}
- </div>
-{% elif field|is_textarea %}
- <div class="input input-field col {{ classes.label }}">
- <textarea id="{{ field.auto_id }}"
- class="materialize-textarea {{ field.field.widget.attrs.class }}"
- name="{{ field.name }}"
- {% if field.field.disabled %} disabled {% endif %}>{% if field.value %}{{ field.value }}{% endif %}</textarea>
- {% if field.auto_id %}
- <label class="{{ classes.label }}" for="{{ field.auto_id }}">
- {{ field.label }}
- {% if not field.field.required %}
- {% trans "(optional)" context "Dashboard form labels" %}
- {% endif %}
- </label>
- {% endif %}
- {% for error in field.errors %}
- <p class="help-block materialize-red-text">{{ error }}</p>
- {% endfor %}
- {% if field.help_text %}
- <p class="help-block">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- </div>
-{% elif field|is_file %}
- <div
- class="input col input-field {{ classes.label }}">
- {% if field.auto_id %}
- <p>
- <label
- class="{{ classes.label }}"
- for="{{ field.auto_id }}">
- {{ field.label }}
- {% if not field.field.required %}
- {% trans "(optional)" context "Dashboard form labels" %}
- {% endif %}
- </label>
- </p>
- {% endif %}
-
- {% with field.field.widget as widget %}
- {% if field.value %}
- <p>
- {{ widget.initial_text }}:
- <a
- href="{{ field.value.url }}">
- {{ field.value }}
- </a>
- {% if not widget.required %}
- <input
- type="checkbox"
- name="{{ field.name }}-clear"
- id="{{ field.name }}-clear_id">
- <label
- for="{{ field.name }}-clear_id">
- {{ widget.clear_checkbox_label }}
- </label>
- {% endif %}
- </p>
- {% endif %}
- {% endwith %}
-
- <div class="file-field">
- <p>
- <div class="btn">
- <span>
- {% trans "File" %}
- </span>
- <input class="file-chooser" id="{{ field.auto_id }}" name="{{ field.name }}" type="file">
- </div>
- <div class="file-path-wrapper">
- <input class="file-path" type="text">
- </div>
- </p>
- {% for error in field.errors %}
- <p class="help-block materialize-red-text">
- {{ error }}
- </p>
- {% endfor %}
- {% if field.help_text %}
- <p class="help-block">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- </div>
- </div>
-{% elif field|is_versatile_image_ppoi_click_widget %}
- <div class="input col file-field input-field {{ classes.label }}">
- {% if field.auto_id %}
- <label class="{{ classes.label }}" for="{{ field.auto_id }}">
- {{ field.label }}
- {% if not field.field.required %}
- {% trans "(optional)" context "Dashboard form labels" %}
- {% endif %}
- </label>
- {% endif %}
- <div class="btn">
- <span>
- {% trans "File" %}
- </span>
- <input class="file-chooser" id="{{ field.auto_id }}_0" name="{{ field.name }}_0" type="file">
- <input class="ppoi-input" id="{{ field.auto_id }}_1" name="{{ field.name }}_1" type="hidden">
- </div>
- <div class="file-path-wrapper">
- <input class="file-path" type="text">
- </div>
- {% for error in field.errors %}
- <p class="help-block materialize-red-text">
- {{ error }}
- </p>
- {% endfor %}
- {% if field.help_text %}
- <p class="help-block">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- </div>
-{% elif field|is_image_preview_widget %}
- <div class="col">
- {{ field }}
- </div>
- <div class="input col file-field input-field {{ classes.label }}">
- {% if field.auto_id %}
- <label class="{{ classes.label }}" for="{{ field.auto_id }}">
- {{ field.label }}
- {% if not field.field.required %}
- {% trans "(optional)" context "Dashboard form labels" %}
- {% endif %}
- </label>
- {% endif %}
- <div class="btn">
- <span>
- {% trans "File" %}
- </span>
- <input class="file-chooser" id="{{ field.auto_id }}_0" name="{{ field.name }}_0" type="file">
- </div>
- <div class="file-path-wrapper">
- <input class="file-path" type="text" value="{{ field.value.display_value }}">
- </div>
- {% for error in field.errors %}
- <p class="help-block materialize-red-text">
- {{ error }}
- </p>
- {% endfor %}
- {% if field.help_text %}
- <p class="help-block">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- </div>
-{% elif field|is_date_range %}
- <div class="input-field input-range col s12 {{ classes.label }}">
- <label class="active" for="{{ field.auto_id }}_0">
- {{ field.label }}
- {% if not field.field.required %}
- {% trans "(optional)" context "Dashboard form labels" %}
- {% endif %}
- </label>
- {% for value in field.value %}
- {% comment %} cycle after/before - this is assuming range will only iterate over 2 fields, required for django-filter instead of 0-1 indexes {% endcomment %}
- <input type="date" id="{{ field.auto_id }}" class="datepicker col s5" name="{{ field.name }}_{% cycle 'after' 'before' %}"
- value="{% if value %}{{ value }}{% endif %}" data-value="{% if value %}{{ value }}{% endif %}">
- {% for error in field.errors %}
- <p class="help-block materialize-red-text">
- {{ error }}
- </p>
- {% endfor %}
- {% if field.help_text %}
- <p class="help-block">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- {% if not forloop.last %}
- <div class="col s2 center-align separator">-</div>
- {% endif %}
- {% endfor %}
- </div>
-{% elif field|is_price_range %}
- <div class="input input-field input-range col s12 {{ classes.label }}">
- <label class="active" for="{{ field.auto_id }}_0">
- {{ field.label }}
- {% if not field.field.required %}
- {% trans "(optional)" context "Dashboard form labels" %}
- {% endif %}
- </label>
- <div>
- {% for value in field.value %}
- <div class="input-range--field">
- <div class="input-with-suffix">
- {% comment %} cycle min/max - this is assuming range will only iterate over 2 fields, required for django-filter instead of 0-1 indexes {% endcomment %}
- <input type="number" name="{{ field.name }}_{% cycle 'min' 'max' %}" value="{{ value }}"
- id="{{ field.auto_id }}_{{ forloop.counter0 }}">
- <div class="input-text-suffix">{{ field.field.widget.currency }}</div>
- </div>
- </div>
- {% for error in field.errors %}
- <p class="help-block materialize-red-text">
- {{ error }}
- </p>
- {% endfor %}
- {% if field.help_text %}
- <p class="help-block">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- {% if not forloop.last %}
- <div class="center-align separator">-</div>
- {% endif %}
- {% endfor %}
- </div>
- </div>
-{% elif field|is_range %}
- <div class="input input-field col s12 {{ classes.label }}">
- <label class="active" for="{{ field.auto_id }}_0">
- {{ field.label }}
- {% if not field.field.required %}
- {% trans "(optional)" context "Dashboard form labels" %}
- {% endif %}
- </label>
- {% for value in field.value %}
- {% for error in field.errors %}
- <p class="help-block materialize-red-text">
- {{ error }}
- </p>
- {% endfor %}
- {% if field.help_text %}
- <p class="help-block">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- {% comment %} cycle min/max - this is assuming range will only iterate over 2 fields, required for django-filter instead of 0-1 indexes {% endcomment %}
- <input type="number" class="col s5"
- name="{{ field.name }}_{% cycle 'min' 'max' %}" value="{{ value }}"
- id="{{ field.auto_id }}_{{ forloop.counter0 }}">
- {% if not forloop.last %}
- <div class="col s2 center-align separator">-</div>
- {% endif %}
- {% endfor %}
- </div>
-{% elif field|is_chars_left %}
- <div class="input input-field col {{ classes.label }}">
- <div class="chars-left">
- <label class="active chars-left__label" for="{{ field.auto_id }}">
- {{ field.label }}
- {% if not field.field.required %}
- {% trans "(optional)" context "Dashboard form labels" %}
- {% endif %}
- </label>
- <span class="chars-left__count">
- <span class="chars-left__count__current" data-bind="{{ field.auto_id }}">
- {% blocktrans with current_chars_count=field.value|length max_chars_count=field.field.max_length context "Message showing how many chars were used out of maximum field's length" %}
- {{ current_chars_count }}</span> of {{ max_chars_count }} characters used
- {% endblocktrans %}
- </span>
- </div>
- {{ field }}
- {% for error in field.errors %}
- <p class="help-block materialize-red-text">{{ error }}</p>
- {% endfor %}
- {% if field.help_text %}
- <p class="help-block">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- </div>
-{% else %}
- <div class="input input-field col {{ classes.label }}">
- {% if field.auto_id %}
- <label class="active" for="{{ field.auto_id }}">
- {{ field.label }}
- {% if not field.field.required %}
- {% trans "(optional)" context "Dashboard form labels" %}
- {% endif %}
- </label>
- {% endif %}
- {{ field }}
- {% for error in field.errors %}
- <p class="help-block materialize-red-text">{{ error }}</p>
- {% endfor %}
- {% if field.help_text %}
- <p class="help-block">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- </div>
-{% endif %}
diff --git a/templates/materializecssform/form.html b/templates/materializecssform/form.html
deleted file mode 100644
index 45908790f0..0000000000
--- a/templates/materializecssform/form.html
+++ /dev/null
@@ -1,15 +0,0 @@
-{% if form.non_field_errors %}
- <blockquote>
- {% for non_field_error in form.non_field_errors %}
- {{ non_field_error }}
- {% endfor %}
- </blockquote>
-{% endif %}
-
-{% for field in form.hidden_fields %}
- {{ field }}
-{% endfor %}
-
-{% for field in form.visible_fields %}
- {% include "materializecssform/field.html" %}
-{% endfor %}
diff --git a/templates/materializecssform/formset.html b/templates/materializecssform/formset.html
deleted file mode 100644
index a442d6f2bf..0000000000
--- a/templates/materializecssform/formset.html
+++ /dev/null
@@ -1,5 +0,0 @@
-{{ formset.management_form }}
-
-{% for form in formset %}
- {% include "materializecssform/form.html" with form=form %}
-{% endfor %}
diff --git a/templates/page/details.html b/templates/page/details.html
index 87072203d0..f878567c66 100644
--- a/templates/page/details.html
+++ b/templates/page/details.html
@@ -1,6 +1,5 @@
{% extends "base.html" %}
{% load i18n %}
-{% load materializecss %}
{% load build_absolute_uri from urls %}
{% load format_content from content_formatting %}