Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
f4ae25c7
Commit
f4ae25c7
authored
Nov 22, 2012
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MongoEngine inline fields fixes
parent
f6d0a10b
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
5 deletions
+23
-5
simple.py
examples/mongoengine/simple.py
+1
-0
fields.py
flask_admin/contrib/mongoengine/fields.py
+5
-0
fields.py
flask_admin/model/fields.py
+1
-1
admin.css
flask_admin/static/css/admin.css
+4
-0
form.js
flask_admin/static/js/form.js
+11
-2
inline_form.html
flask_admin/templates/admin/model/inline_form.html
+1
-0
inline_list_base.html
flask_admin/templates/admin/model/inline_list_base.html
+0
-2
No files found.
examples/mongoengine/simple.py
View file @
f4ae25c7
...
...
@@ -55,6 +55,7 @@ class Post(db.Document):
name
=
db
.
StringField
(
max_length
=
20
)
value
=
db
.
StringField
(
max_length
=
20
)
inner
=
db
.
ListField
(
db
.
EmbeddedDocumentField
(
Comment
))
lols
=
db
.
ListField
(
db
.
StringField
(
max_length
=
20
))
# Customized admin views
...
...
flask_admin/contrib/mongoengine/fields.py
View file @
f4ae25c7
...
...
@@ -3,6 +3,11 @@ from wtforms.fields import FormField
class
ModelFormField
(
FormField
):
def
__init__
(
self
,
model
,
*
args
,
**
kwargs
):
# Small hack to get rid of separator if name is empty
name
=
kwargs
.
get
(
'name'
)
if
not
name
:
kwargs
[
'separator'
]
=
''
super
(
ModelFormField
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
model
=
model
...
...
flask_admin/model/fields.py
View file @
f4ae25c7
...
...
@@ -12,7 +12,7 @@ class InlineFieldList(FieldList):
super
(
InlineFieldList
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
# Create template
self
.
template
=
self
.
unbound_field
.
bind
(
form
=
None
,
name
=
''
,
prefix
=
''
,
separator
=
''
)
self
.
template
=
self
.
unbound_field
.
bind
(
form
=
None
,
name
=
''
)
self
.
template
.
process
(
None
)
def
__call__
(
self
,
**
kwargs
):
...
...
flask_admin/static/css/admin.css
View file @
f4ae25c7
...
...
@@ -62,6 +62,10 @@ form.search-form a.clear i {
}
/* Inline forms */
.fa-inline-field
{
padding-bottom
:
0.5em
;
}
.fa-inline-field-control
{
float
:
right
;
}
flask_admin/static/js/form.js
View file @
f4ae25c7
...
...
@@ -41,12 +41,21 @@
$
(
'[name]'
,
$template
).
each
(
function
(
e
)
{
var
me
=
$
(
this
);
me
.
attr
(
'id'
,
prefix
+
'-'
+
me
.
attr
(
'id'
));
me
.
attr
(
'name'
,
prefix
+
'-'
+
me
.
attr
(
'name'
));
var
id
=
me
.
attr
(
'id'
);
var
name
=
me
.
attr
(
'name'
);
id
=
prefix
+
(
id
!==
''
?
'-'
+
id
:
''
);
name
=
prefix
+
(
name
!==
''
?
'-'
+
name
:
''
);
me
.
attr
(
'id'
,
id
);
me
.
attr
(
'name'
,
name
);
});
$template
.
appendTo
(
$el
);
// Select first field
$
(
'input:first'
,
$template
).
focus
();
// Apply styles
this
.
applyGlobalStyles
(
$template
);
};
...
...
flask_admin/templates/admin/model/inline_form.html
View file @
f4ae25c7
{% import 'admin/lib.html' as lib with context %}
{{ lib.render_form_fields(field, True) }}
<hr/>
flask_admin/templates/admin/model/inline_list_base.html
View file @
f4ae25c7
...
...
@@ -4,7 +4,6 @@
<a
href=
"#"
class=
"fa-remove-field"
><i
class=
"icon-remove"
></i></a>
</div>
{{ render(template) }}
<hr/>
</div>
{%- endmacro %}
...
...
@@ -21,7 +20,6 @@
{%- endif -%}
{{ render(subfield) }}
<hr/>
</div>
{% endfor %}
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment