diff --git a/src/adminactions/bulk_update.py b/src/adminactions/bulk_update.py index 3a1402e..f73e7a5 100644 --- a/src/adminactions/bulk_update.py +++ b/src/adminactions/bulk_update.py @@ -39,12 +39,17 @@ class BulkUpdateForm(forms.Form): action = forms.CharField( label="", required=True, initial="", widget=forms.HiddenInput() ) - - _async = forms.BooleanField( - label="Async", - required=False, - help_text=_("use Celery to run update in background"), + _file = forms.FileField( + label="CSV File", + required=True, + help_text=_("CSV file"), + validators=[FileExtensionValidator(allowed_extensions=["csv", "txt"])], ) + # _async = forms.BooleanField( + # label="Async", + # required=False, + # help_text=_("use Celery to run update in background"), + # ) _clean = forms.BooleanField( label="Clean()", required=False, help_text=_("if checked calls obj.clean()") ) @@ -55,20 +60,18 @@ class BulkUpdateForm(forms.Form): help_text=_("if checked use obj.save() instead of manager.bulk_update()"), ) - _date_format = forms.CharField( - label="Date format", required=True, help_text=_("Date format") - ) - _file = forms.FileField( - label="CSV File", - required=True, - help_text=_("CSV file"), - validators=[FileExtensionValidator(allowed_extensions=["csv", "txt"])], - ) + # _date_format = forms.CharField( + # label="Date format", required=True, help_text=_("Date format") + # ) + @property def media(self): """Return all media required to render the widgets on this form.""" - media = Media(js=["adminactions/js/bulkupdate.js"]) + media = Media(js=["adminactions/js/bulkupdate.js"], + css={"all": + ["adminactions/css/bulkupdate.css"] + }) for field in self.fields.values(): media = media + field.widget.media return media @@ -218,10 +221,10 @@ def bulk_update(modeladmin, request, queryset): # noqa "map_form": map_form, "action_short_description": bulk_update.short_description, "title": "%s (%s)" - % ( - bulk_update.short_description.capitalize(), - smart_str(modeladmin.opts.verbose_name_plural), - ), + % ( + bulk_update.short_description.capitalize(), + smart_str(modeladmin.opts.verbose_name_plural), + ), "change": True, "is_popup": False, "save_as": False, diff --git a/src/adminactions/static/adminactions/css/bulkupdate.scss b/src/adminactions/static/adminactions/css/bulkupdate.scss new file mode 100644 index 0000000..8e89d51 --- /dev/null +++ b/src/adminactions/static/adminactions/css/bulkupdate.scss @@ -0,0 +1,37 @@ + +table.bulk-update { + border: 1px solid #c9c9c9; + + td { + border-left: 1px solid #c9c9c9; + } + + select.func_select { + min-width: 100px; + } +} +table{ + th.title{ + background-color: var(--header-bg); + } +} +#col1 { + float: left; + //padding-right: 10px; + width: 70%; + table{ + width: 90%; + } +} + +#col2 { + float: right; + width: 30%; + table{ + width: 90%; + } +} + +#col2 select { + width: 100%; +} diff --git a/src/adminactions/templates/adminactions/bulk_update.html b/src/adminactions/templates/adminactions/bulk_update.html index d9f7124..deb9a89 100644 --- a/src/adminactions/templates/adminactions/bulk_update.html +++ b/src/adminactions/templates/adminactions/bulk_update.html @@ -22,18 +22,19 @@ {% endif %} {{ form.non_field_errors }} -
-
+
Settings: + +
+ +
{% csrf_token %} -
Configuration: - -
+ {% for field in adminform.form %} {% if field.field.widget.input_type == "hidden" %} {{ field }} @@ -48,22 +49,11 @@ {% endif %} {% endfor %} - - - {% for field in csv_form %} - - - - - {% endfor %} - - + + + + @@ -77,7 +67,8 @@ - {% endif %} @@ -87,6 +78,22 @@ {{ hidden }} {% endfor %} - - + +
+
Configuration

CSV Options

{{ field.label_tag }} - {{ field.errors }} - {{ field }} {{ field.help_text }} -

Columns Mapping

-
{{ map_form.index_field.errors }}
-
Columns Mapping
{{ map_form.index_field.errors }}
field name Use for index {{ field.errors }}{{ field }}  + + {{ field.errors }}{{ field }} 
+ + + + {% for field in csv_form %} + + + + + {% endfor %} +

CSV Options

{{ field.label_tag }} + {{ field.errors }} + {{ field }} {{ field.help_text }} +
+
+ {% endblock %}