diff --git a/sigi/apps/utils/templatetags/file_image.py b/sigi/apps/utils/templatetags/file_image.py new file mode 100644 index 0000000..eb772ef --- /dev/null +++ b/sigi/apps/utils/templatetags/file_image.py @@ -0,0 +1,27 @@ +import pathlib +from django import template +from django.conf import settings +from django.db import models +from django.templatetags.static import static + +register = template.Library() + +ICONS_FOLDER = settings.STATIC_ROOT / "img/icons/" + + +@register.filter +def file_image(value): + if not isinstance(value, models.fields.files.FieldFile): + return value + if is_image(value): + return value.url or static("img/icons/unknown.jpg") + sufixo = pathlib.Path(value.name).suffix[1:] + if (ICONS_FOLDER / f"{sufixo}.jpg").exists(): + return static(f"img/icons/{sufixo}.jpg") + else: + return static("img/icons/unknown.jpg") + + +@register.filter +def is_image(value): + return isinstance(value, models.fields.files.ImageFieldFile) diff --git a/sigi/static/css/materialize-adjusts.css b/sigi/static/css/materialize-adjusts.css new file mode 100644 index 0000000..d18e83e --- /dev/null +++ b/sigi/static/css/materialize-adjusts.css @@ -0,0 +1,3 @@ +.file-field input[type="file"] { + left: 65px; +} \ No newline at end of file diff --git a/sigi/static/img/icons/csv.jpg b/sigi/static/img/icons/csv.jpg new file mode 100644 index 0000000..a66623b Binary files /dev/null and b/sigi/static/img/icons/csv.jpg differ diff --git a/sigi/static/img/icons/doc.jpg b/sigi/static/img/icons/doc.jpg new file mode 100644 index 0000000..4be8e50 Binary files /dev/null and b/sigi/static/img/icons/doc.jpg differ diff --git a/sigi/static/img/icons/docx.jpg b/sigi/static/img/icons/docx.jpg new file mode 100644 index 0000000..b29c561 Binary files /dev/null and b/sigi/static/img/icons/docx.jpg differ diff --git a/sigi/static/img/icons/json.jpg b/sigi/static/img/icons/json.jpg new file mode 100644 index 0000000..cf4f11b Binary files /dev/null and b/sigi/static/img/icons/json.jpg differ diff --git a/sigi/static/img/icons/odp.jpg b/sigi/static/img/icons/odp.jpg new file mode 100644 index 0000000..68ee5b5 Binary files /dev/null and b/sigi/static/img/icons/odp.jpg differ diff --git a/sigi/static/img/icons/ods.jpg b/sigi/static/img/icons/ods.jpg new file mode 100644 index 0000000..b6769fc Binary files /dev/null and b/sigi/static/img/icons/ods.jpg differ diff --git a/sigi/static/img/icons/odt.jpg b/sigi/static/img/icons/odt.jpg new file mode 100644 index 0000000..26688a9 Binary files /dev/null and b/sigi/static/img/icons/odt.jpg differ diff --git a/sigi/static/img/icons/pdf.jpg b/sigi/static/img/icons/pdf.jpg new file mode 100644 index 0000000..72fe251 Binary files /dev/null and b/sigi/static/img/icons/pdf.jpg differ diff --git a/sigi/static/img/icons/unknown.jpg b/sigi/static/img/icons/unknown.jpg new file mode 100644 index 0000000..f59d7ba Binary files /dev/null and b/sigi/static/img/icons/unknown.jpg differ diff --git a/sigi/static/img/icons/xls.jpg b/sigi/static/img/icons/xls.jpg new file mode 100644 index 0000000..27898c3 Binary files /dev/null and b/sigi/static/img/icons/xls.jpg differ diff --git a/sigi/static/img/icons/xlsx.jpg b/sigi/static/img/icons/xlsx.jpg new file mode 100644 index 0000000..cde316a Binary files /dev/null and b/sigi/static/img/icons/xlsx.jpg differ diff --git a/sigi/static/js/materialize-inits.js b/sigi/static/js/materialize-inits.js new file mode 100644 index 0000000..f3cde93 --- /dev/null +++ b/sigi/static/js/materialize-inits.js @@ -0,0 +1,3 @@ +$(document).ready(function () { + M.Materialbox.init($('.materialboxed')); +}) \ No newline at end of file diff --git a/sigi/templates/admin/base_site.html b/sigi/templates/admin/base_site.html index 23f1d92..93725cf 100644 --- a/sigi/templates/admin/base_site.html +++ b/sigi/templates/admin/base_site.html @@ -4,6 +4,7 @@ {% block theme %} + {% endblock %} {% block breadcrumbs %}{% endblock %} @@ -28,4 +29,9 @@ {% trans 'Log out' %} +{% endblock %} + +{% block footer %} + {{ block.super }} + {% endblock %} \ No newline at end of file diff --git a/sigi/templates/admin/widgets/clearable_file_input.html b/sigi/templates/admin/widgets/clearable_file_input.html index ae06c7b..167b9c9 100644 --- a/sigi/templates/admin/widgets/clearable_file_input.html +++ b/sigi/templates/admin/widgets/clearable_file_input.html @@ -1,19 +1 @@ - -{% if widget.is_initial %} -

- {{ widget.initial_text }}: - {{ widget.value }} - {% if not widget.required %} - - - - - {% endif %} -
- {{ widget.input_text }}: - {% endif %} - - {% if widget.is_initial %} -

-{% endif %} \ No newline at end of file +{% extends "django/forms/widgets/clearable_file_input.html" %} \ No newline at end of file diff --git a/sigi/templates/django/forms/material_form.html b/sigi/templates/django/forms/material_form.html index 0ef469a..8003d1d 100644 --- a/sigi/templates/django/forms/material_form.html +++ b/sigi/templates/django/forms/material_form.html @@ -3,12 +3,21 @@

{% for field in hidden_fields %}{{ field }}{% endfor %}

{% endif %} {% for field, errors in fields %} - + {{ errors }} - {% if field.label %}{{ field.label_tag }}{% endif %} - {{ field }} + {% if field.widget_type == 'checkbox' %} +

+ +

+ {% else %} + {% if field.label %}{{ field.label_tag }}{% endif %} + {{ field }} + {% endif %} {% if field.help_text %} {{ field.help_text|safe }} {% endif %} diff --git a/sigi/templates/django/forms/widgets/clearable_file_input.html b/sigi/templates/django/forms/widgets/clearable_file_input.html index 1edd8bc..353d684 100644 --- a/sigi/templates/django/forms/widgets/clearable_file_input.html +++ b/sigi/templates/django/forms/widgets/clearable_file_input.html @@ -1,9 +1,8 @@ -{% load i18n %} -
+{% load i18n file_image %} +
{% if widget.is_initial %} {% endif %} @@ -16,12 +15,13 @@
{% if widget.is_initial %} -{% if not widget.required %} + {% trans "Download" %}: {{ widget.value.url }}

+ {% if not widget.required %} + {% endif %}

-{% endif %} -{% endif %} +{% endif %} \ No newline at end of file