cleanup: pep8

This commit is contained in:
2014-11-21 20:58:44 +01:00
parent 47a6eaa936
commit aac29c824d
12 changed files with 57 additions and 77 deletions

View File

@@ -27,15 +27,15 @@ def _list_items(view, context, model, name):
return Markup(
'<div class="select2-container-multi">'
'<ul class="select2-choices" style="border:0;cursor:default;background:none;">%s</ul></div>' % (
''.join( ['<li class="select2-search-choice" style="padding:3px 5px;">'
'<div>'+item.name+'</div></li>' for item in getattr(model,name)] )))
''.join(['<li class="select2-search-choice" style="padding:3px 5px;">'
'<div>' + item.name + '</div></li>' for item in getattr(model, name)] )))
def _list_thumbnail(view, context, model, name):
if not getattr(model,name): #model.name only does not work because name is a string
if not getattr(model,name): # model.name only does not work because name is a string
return ''
return ''
# return Markup('<img src="%s">' % url_for('static',
# return Markup('<img src="%s">' % url_for('static',
# filename=thumb.thumbnail(getattr(model,name), '50x50', crop='fit')))
# Create directory for file fields to use
@@ -81,19 +81,20 @@ class CKTextAreaField(fields.TextAreaField):
class CustomModelView(ModelView):
def is_accessible(self):
return True
#return login.current_user.has_role('admin')
# return login.current_user.has_role('admin')
class CustomBaseView(BaseView):
def is_accessible(self):
return True
#return login.current_user.has_role('admin')
# return login.current_user.has_role('admin')
# Create customized index view class that handles login & registration
class CustomAdminIndexView(admin.AdminIndexView):
def is_accessible(self):
return True
#return login.current_user.has_role('admin')
# return login.current_user.has_role('admin')
@expose('/')
def index(self):
@@ -107,9 +108,8 @@ class CustomAdminIndexView(admin.AdminIndexView):
# Create admin
backend = Admin(
app,
'BAM',
index_view=CustomAdminIndexView(),
base_template='admin/layout_admin.html'
)
app,
"BAM",
index_view=CustomAdminIndexView(),
base_template="admin/layout_admin.html"
)

View File

@@ -10,16 +10,16 @@ from application.modules.admin import _list_thumbnail
class ProjectView(CustomModelView):
column_searchable_list = ('name',)
column_list = ('name', 'picture', 'creation_date')
#column_formatters = { 'picture': _list_thumbnail }
#form_extra_fields = {'picture': image_upload_field('Header')}
# column_formatters = { 'picture': _list_thumbnail }
# form_extra_fields = {'picture': image_upload_field('Header')}
form_overrides = dict(
status=SelectField,
)
form_args = dict(
status=dict(
label='Status',
label='Status',
choices=[
('active', 'Active'),
('active', 'Active'),
('inactive', 'Inactive'),
('canceled', 'Canceled')
]),

View File

@@ -9,7 +9,7 @@ class Project(db.Model):
upload_path = db.Column(db.Text, nullable=False)
picture = db.Column(db.String(80))
creation_date = db.Column(db.DateTime(), default=datetime.datetime.now)
status = db.Column(db.String(80)) #active #inactive
status = db.Column(db.String(80)) # active #inactive
settings = db.relationship('ProjectSetting', backref='project')