Server settings for svn commits

This commit is contained in:
2014-11-07 12:08:00 +01:00
committed by Campbell Barton
parent 5601ad297f
commit d2611cd979
6 changed files with 87 additions and 7 deletions

View File

@@ -49,7 +49,7 @@ db = SQLAlchemy(app)
from application.modules.admin import backend
from application.modules.admin import settings
from application.modules.projects import admin
from application.modules.projects.model import Project
from application.modules.projects.model import Project, ProjectSetting
@auth.get_password
@@ -221,6 +221,15 @@ class FileAPI(Resource):
arguments = json.loads(request.args['arguments'])
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'))
# If the setting does not exist, stop here and prevent any other operation
if not svn_password:
return make_response(jsonify(
{'message': 'SVN missing password settings'}), 500)
if file and self.allowed_file(file.filename):
os.makedirs(project.upload_path, exist_ok=True)
@@ -276,9 +285,13 @@ class FileAPI(Resource):
result = local_client.run_command('add',
[file_path,])
# Commit command
result = local_client.run_command('commit',
[local_client.info()['entry_path'], '--message', arguments['message']],
[local_client.info()['entry_path'],
'--message', arguments['message'],
'--username', svn_default_user,
'--password', svn_password],
combine=True)

View File

@@ -1,11 +1,12 @@
from application import db
class Setting(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(256), unique=True, nullable=False)
description = db.Column(db.Text)
value = db.Column(db.String(100), nullable=False)
data_type = db.Column(db.String(128), nullable=False)
def __unicode__(self):
return self.name

View File

@@ -1,7 +1,7 @@
from application import app
from application import db
from application.modules.projects.model import Project
from application.modules.projects.model import Project, ProjectSetting
from application.modules.admin import *
from application.modules.admin import _list_thumbnail
@@ -12,6 +12,21 @@ class ProjectView(CustomModelView):
column_list = ('name', 'picture', 'creation_date')
#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',
choices=[
('active', 'Active'),
('inactive', 'Inactive'),
('canceled', 'Canceled')
]),
)
inline_models = (
ProjectSetting,
)
# Add views
backend.add_view(ProjectView(Project, db.session, name='Projects', url='projects'))

View File

@@ -1,6 +1,7 @@
import datetime
from application import db
class Project(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255), nullable=False)
@@ -8,7 +9,21 @@ 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)) #pending #active #inactive
status = db.Column(db.String(80)) #active #inactive
settings = db.relationship('ProjectSetting', backref='project')
def __str__(self):
return str(self.name)
class ProjectSetting(db.Model):
id = db.Column(db.Integer, primary_key=True)
project_id = db.Column(db.Integer(), db.ForeignKey('project.id'), nullable=False)
name = db.Column(db.String(256), unique=True, nullable=False)
description = db.Column(db.Text)
value = db.Column(db.String(100), nullable=False)
data_type = db.Column(db.String(128), nullable=False)
def __unicode__(self):
return self.name