Skip to content

Commit

Permalink
Merge branch 'release-1.10.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
abidibo committed Sep 2, 2020
2 parents 41630d4 + ce6832e commit 3809160
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 14 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Add `baton` and `baton.autodiscover` to your `INSTALLED_APPS`:
# ...
'baton',
'django.contrib.admin',
# ...
# ... (place baton.autodiscover at the very end)
'baton.autodiscover',
)

Expand Down Expand Up @@ -416,6 +416,7 @@ You can specify the following positions:
|`bottom`| the template is placed inside the form row, at the bottom|
|`above`| the template is placed above the form row|
|`below`| the template is placed below the form row|
|`right`| the template is placed inline at the input field right side|

And, of course, you can access the `{{ original }}` object variable inside your template.

Expand Down
4 changes: 2 additions & 2 deletions baton/static/baton/app/dist/baton.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion baton/static/baton/app/dist/baton.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion baton/static/baton/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion baton/static/baton/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "baton",
"version": "1.10.9",
"version": "1.10.10",
"description": "Django Baton App",
"main": "index.js",
"scripts": {
Expand Down
9 changes: 7 additions & 2 deletions baton/static/baton/app/src/core/ChangeForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,18 @@ let ChangeForm = {
above: 'before',
below: 'after',
top: 'prepend',
bottom: 'append'
bottom: 'append',
right: 'after'
}
$('template').each(function (index, template) {
let field = $(template).attr('id').replace('template-', '')
let position = positionMap[$(template).attr('data-position')]
if (position !== undefined) {
$('.form-row.field-' + field)[position]($(template).html())
let el = $(template).attr('data-position') === 'right'
? $('.form-row.field-' + field + ' #id_' + field)
: $('.form-row.field-' + field)
console.log(el)
el[position]($(template).html())
} else {
console.error('Baton: wrong form include position detected')
}
Expand Down
5 changes: 5 additions & 0 deletions baton/static/baton/app/src/styles/_changeform.scss
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@
min-width: 100%;
}

.baton-form-include-right {
display: inline !important;
min-width: auto !important;
}

.change-form #content-main>form .form-row>div.baton-form-include {
display: block;
}
2 changes: 1 addition & 1 deletion baton/templates/admin/change_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{% for template, field, position in adminform.model_admin.baton_form_includes %}
<template id="template-{{ field }}" data-position="{{ position }}">
<div id='template-{{ field }}-container' class="baton-form-include">
<div id='template-{{ field }}-container' class="baton-form-include baton-form-include-{{ position }}">
{% include template %}
</div>
</template>
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
# built documents.
#
# The short X.Y version.
version = u'1.10.9'
version = u'1.10.10'
# The full version, including alpha/beta/rc tags.
release = u'1.10.9'
release = u'1.10.10'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 2 additions & 0 deletions docs/form_includes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ You can specify the following positions:
+----------------------------------------+--------------------------------------------------------------------+
| below | the template is placed below the form row |
+----------------------------------------+--------------------------------------------------------------------+
| right | the template is placed inline at the field right side |
+----------------------------------------+--------------------------------------------------------------------+

And, of course, you can access the `{{ original }}` object variable inside your template.

Expand Down
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Using pip
# ...
'baton',
'django.contrib.admin',
# ...
# ... (place baton.autodiscover at the very end)
'baton.autodiscover',
)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name='django-baton',
version='1.10.9',
version='1.10.10',
packages=['baton', 'baton.autodiscover', 'baton.templatetags'],
include_package_data=True,
license='MIT License',
Expand Down
Binary file modified testapp/app/db.sqlite3
Binary file not shown.
3 changes: 2 additions & 1 deletion testapp/app/news/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ class NewsAdmin(admin.ModelAdmin):

baton_form_includes = [
('news/admin_datetime_include.html', 'datetime', 'top', ),
('news/admin_content_include.html', 'content', 'above', )
('news/admin_content_include.html', 'content', 'above', ),
('news/admin_title_include.html', 'title', 'right', ),
]
1 change: 1 addition & 0 deletions testapp/app/news/templates/news/admin_title_include.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<a href="#" style="margin-left: 1rem; margin-top: 3px;" class="btn btn-primary btn-sm">Click here</a>

0 comments on commit 3809160

Please sign in to comment.