Home Information - Your home, your data, organized.
Python
Improved styling and fixed bugs for file upload attribute.
Anthony Cassandraa50794ed1052
diff --git a/src/hi/apps/attribute/models.py b/src/hi/apps/attribute/models.pyindex 5d045ce1..307adee8 100644--- a/src/hi/apps/attribute/models.py+++ b/src/hi/apps/attribute/models.py@@ -136,9 +136,14 @@ class AttributeModel(models.Model):return dict()def save(self, *args, **kwargs):+if self.file_value and self.file_value.name:self.file_value.field.upload_to = self.get_upload_to()- self.file_value.name = generate_unique_filename( self.file_value.name )+ if not self.value:+ self.value = self.file_value.name+ if not self.pk or not self.__class__.objects.filter( pk = self.pk ).exists():+ self.file_value.name = generate_unique_filename( self.file_value.name )+super().save(*args, **kwargs)returndiff --git a/src/hi/apps/attribute/templates/attribute/panes/attribute_form_file.html b/src/hi/apps/attribute/templates/attribute/panes/attribute_form_file.htmlindex 92e208d8..486c58bd 100644--- a/src/hi/apps/attribute/templates/attribute/panes/attribute_form_file.html+++ b/src/hi/apps/attribute/templates/attribute/panes/attribute_form_file.html@@ -1,19 +1,20 @@<input type="hidden" id="{{ attribute_form.name.id_for_label }}"name="{{ attribute_form.name.html_name }}"value="{{ attribute_form.instance.name }}" />-<div class="input-group" >- <div>- File: <a href="{{ attribute_form.instance.file_value.url }}"- {% if attribute_form.instance.file_mime_type %}type="{{ attribute_form.instance.file_mime_type }}"{% endif %}- target="_blank">- {{ attribute_form.instance.name }}++<div class="input-group">+ <div class="input-group-prepend">+ <a href="{{ attribute_form.instance.file_value.url }}"+ class="btn btn-sm btn-primary"+ {% if attribute_form.instance.file_mime_type %}type="{{ attribute_form.instance.file_mime_type }}"{% endif %}+ target="_blank">+ VIEW</a></div>{% include "attribute/panes/attribute_form_field_value.html" %}-{% if attribute_form.show_as_editable and attribute_form.instance.is_editable and attribute_form.instance.attribute_type.can_delete %}- <div class="">- {{ attribute_form.DELETE }} Delete+ <div class="input-group-append">+ <span class="pl-3" >{{ attribute_form.DELETE }} Delete</span></div>{% endif %}</div>diff --git a/src/hi/apps/entity/templates/entity/modals/entity_edit.html b/src/hi/apps/entity/templates/entity/modals/entity_edit.htmlindex 2b5c5417..6a95825a 100644--- a/src/hi/apps/entity/templates/entity/modals/entity_edit.html+++ b/src/hi/apps/entity/templates/entity/modals/entity_edit.html@@ -1,4 +1,5 @@{% extends "modals/base.html" %}+{% block modal_dialog_class %}hi-modal-dialog-600{% endblock %}{% block title_text %}{{ entity.name }}: Editdiff --git a/src/hi/static/css/main.css b/src/hi/static/css/main.cssindex 01091bc2..e617b513 100644--- a/src/hi/static/css/main.css+++ b/src/hi/static/css/main.css@@ -252,6 +252,10 @@ a.underline:visited {border-left: 1px solid var(--line-color);}+.hi-modal-dialog-600 {+ max-width: 600px;+}+.btn-control {width: 100%;white-space: nowrap;@@ -259,6 +263,9 @@ a.underline:visited {font-weight: bold;}+input[type="number"] {+ max-width: 8rem;+}.hi-location-view {justify-content: center;align-items: center;diff --git a/src/hi/templates/modals/base.html b/src/hi/templates/modals/base.htmlindex af79067a..c0864988 100644--- a/src/hi/templates/modals/base.html+++ b/src/hi/templates/modals/base.html@@ -1,5 +1,5 @@{% load static %}-<div class="modal-dialog hi-modal">+<div class="modal-dialog hi-modal {% block modal_dialog_class %}{% endblock %}"><div class="modal-content"><div class="modal-title"><div class="row {% block header_class %}bg-secondary{% endblock %} m-0 py-2">