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

@@ -117,7 +117,6 @@ class DirectoryAPI(Resource):
path_root_abs = os.path.join(path_root_abs, path)
parent_path = os.pardir
if not os.path.isdir(path_root_abs):
return jsonify(message="Path is not a directory %r" % path_root_abs)
@@ -138,7 +137,7 @@ class DirectoryAPI(Resource):
}
return jsonify(project_files)
#return {'message': 'Display files list'}
# return {'message': 'Display files list'}
class FileAPI(Resource):
@@ -218,7 +217,6 @@ class FileAPI(Resource):
yield report("%s: %r\n" % (colorize("failed to extract", color='red'), filepath))
return
with open(filepath_zip, 'rb') as f:
f.seek(0, os.SEEK_END)
f_size = f.tell()
@@ -246,8 +244,12 @@ class FileAPI(Resource):
file = request.files['file']
# Get the value of the first (and only) result for the specified project setting
svn_password = next((setting.value for setting in project.settings if setting.name == 'svn_password'))
svn_default_user = next((setting.value for setting in project.settings if setting.name == 'svn_default_user'))
svn_password = next((setting.value
for setting in project.settings
if setting.name == 'svn_password'))
svn_default_user = next((setting.value
for setting in project.settings
if setting.name == 'svn_default_user'))
# We get the actual username from the http headers
svn_user = auth.username()
@@ -310,7 +312,7 @@ class FileAPI(Resource):
# We add each unversioned file to SVN
if item_status == 'unversioned':
result = local_client.run_command('add',
[file_path,])
[file_path, ])
with open(os.path.join(extract_tmp_dir, '.bam_paths_ops.json'), 'r') as path_ops:
path_ops = json.load(path_ops)
@@ -322,18 +324,16 @@ class FileAPI(Resource):
file_path_abs = os.path.join(project.repository_path, file_path)
assert(os.path.exists(file_path_abs))
result = local_client.run_command('rm',
[file_path_abs,])
[file_path_abs, ])
# Commit command
result = local_client.run_command('commit',
[local_client.info()['entry_path'],
[local_client.info()['entry_path'],
'--message', arguments['message'],
'--username', svn_user,
'--password', svn_password],
combine=True)
return jsonify(message=result)
else:
return jsonify(message='File not allowed')
@@ -405,8 +405,6 @@ class FileAPI(Resource):
del write_dict_as_json
# done writing json!
@staticmethod
def allowed_file(filename):
return '.' in filename and \
@@ -415,4 +413,3 @@ class FileAPI(Resource):
api.add_resource(DirectoryAPI, '/<project_name>/file_list', endpoint='file_list')
api.add_resource(FileAPI, '/<project_name>/file', endpoint='file')

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')

View File

@@ -70,4 +70,3 @@ if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()