Commit a915a5b3 authored by Serge S. Koval's avatar Serge S. Koval

Minor CSS changes, fixed mongoengine field ordering

parent cbd5846a
from operator import attrgetter
from mongoengine import ReferenceField from mongoengine import ReferenceField
from mongoengine.base import BaseDocument, DocumentMetaclass from mongoengine.base import BaseDocument, DocumentMetaclass
...@@ -167,7 +169,8 @@ def get_form(model, converter, ...@@ -167,7 +169,8 @@ def get_form(model, converter,
field_args = field_args or {} field_args = field_args or {}
# Find properties # Find properties
properties = ((k, v) for k, v in iteritems(model._fields)) properties = sorted(((k, v) for k, v in iteritems(model._fields)),
key=lambda v: v[1].creation_counter)
if only: if only:
props = dict(properties) props = dict(properties)
......
def make_gridfs_args(value):
args = {
'id': value.grid_id,
'coll': value.collection_name
}
if value.db_alias != 'default':
args['db'] = value.db_alias
return args
def make_thumb_args(value):
if value.thumbnail:
args = {
'id': value.thumbnail._id,
'coll': value.collection_name
}
if value.db_alias != 'default':
args['db'] = value.db_alias
return args
else:
return make_gridfs_args(value)
...@@ -18,7 +18,7 @@ def grid_formatter(view, value): ...@@ -18,7 +18,7 @@ def grid_formatter(view, value):
'</a> %(size)dk (%(content_type)s)') % '</a> %(size)dk (%(content_type)s)') %
{ {
'url': url_for('.api_file_view', **args), 'url': url_for('.api_file_view', **args),
'name': escape(value.filename), 'name': escape(value.name),
'size': value.length // 1024, 'size': value.length // 1024,
'content_type': escape(value.content_type) 'content_type': escape(value.content_type)
}) })
......
...@@ -17,10 +17,10 @@ class MongoFileInput(object): ...@@ -17,10 +17,10 @@ class MongoFileInput(object):
placeholder = '' placeholder = ''
if field.data: if field.data:
data = field.data.fs data = field.data
placeholder = self.template % { placeholder = self.template % {
'name': escape(data.filename), 'name': escape(data.name),
'content_type': escape(data.content_type), 'content_type': escape(data.content_type),
'size': data.length // 1024 'size': data.length // 1024
} }
......
...@@ -83,6 +83,24 @@ table.filters { ...@@ -83,6 +83,24 @@ table.filters {
max-height: 100px; max-height: 100px;
} }
/* Forms */
.form-horizontal .control-label {
width: 100px;
text-align: left;
margin-left: 4px;
}
.form-horizontal .controls {
margin-left: 110px;
}
/* Inline forms */
.inline-field .inline-form {
border-left: 1px solid #eeeeee;
padding-left: 8px;
margin-bottom: 4px;
}
/* Patch Select2 */ /* Patch Select2 */
.select2-results li { .select2-results li {
min-height: 24px !important; min-height: 24px !important;
......
{% import 'admin/lib.html' as lib with context %} {% import 'admin/lib.html' as lib with context %}
{{ lib.render_form_fields(field, False) }} <div class="inline-form">
<hr/> {{ lib.render_form_fields(field, False) }}
</div>
{% macro render_inline_fields(field, template, render, check=None) %} {% macro render_inline_fields(field, template, render, check=None) %}
<div class="well"> <div class="inline-field">
<div id="{{ field.id }}-fields"> <div id="{{ field.id }}-fields">
{% for subfield in field %} {% for subfield in field %}
<div id="{{ subfield.id }}" class="fa-inline-field"> <div id="{{ subfield.id }}" class="fa-inline-field">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment