Server settings for svn commits
This commit is contained in:
@@ -49,7 +49,7 @@ db = SQLAlchemy(app)
|
|||||||
from application.modules.admin import backend
|
from application.modules.admin import backend
|
||||||
from application.modules.admin import settings
|
from application.modules.admin import settings
|
||||||
from application.modules.projects import admin
|
from application.modules.projects import admin
|
||||||
from application.modules.projects.model import Project
|
from application.modules.projects.model import Project, ProjectSetting
|
||||||
|
|
||||||
|
|
||||||
@auth.get_password
|
@auth.get_password
|
||||||
@@ -221,6 +221,15 @@ class FileAPI(Resource):
|
|||||||
arguments = json.loads(request.args['arguments'])
|
arguments = json.loads(request.args['arguments'])
|
||||||
file = request.files['file']
|
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):
|
if file and self.allowed_file(file.filename):
|
||||||
os.makedirs(project.upload_path, exist_ok=True)
|
os.makedirs(project.upload_path, exist_ok=True)
|
||||||
|
|
||||||
@@ -276,9 +285,13 @@ class FileAPI(Resource):
|
|||||||
result = local_client.run_command('add',
|
result = local_client.run_command('add',
|
||||||
[file_path,])
|
[file_path,])
|
||||||
|
|
||||||
|
|
||||||
# Commit command
|
# Commit command
|
||||||
result = local_client.run_command('commit',
|
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)
|
combine=True)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
from application import db
|
from application import db
|
||||||
|
|
||||||
|
|
||||||
class Setting(db.Model):
|
class Setting(db.Model):
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
name = db.Column(db.String(256), unique=True, nullable=False)
|
name = db.Column(db.String(256), unique=True, nullable=False)
|
||||||
description = db.Column(db.Text)
|
description = db.Column(db.Text)
|
||||||
value = db.Column(db.String(100), nullable=False)
|
value = db.Column(db.String(100), nullable=False)
|
||||||
data_type = db.Column(db.String(128), nullable=False)
|
data_type = db.Column(db.String(128), nullable=False)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
from application import app
|
from application import app
|
||||||
from application import db
|
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 *
|
||||||
from application.modules.admin import _list_thumbnail
|
from application.modules.admin import _list_thumbnail
|
||||||
@@ -12,6 +12,21 @@ class ProjectView(CustomModelView):
|
|||||||
column_list = ('name', 'picture', 'creation_date')
|
column_list = ('name', 'picture', 'creation_date')
|
||||||
#column_formatters = { 'picture': _list_thumbnail }
|
#column_formatters = { 'picture': _list_thumbnail }
|
||||||
#form_extra_fields = {'picture': image_upload_field('Header')}
|
#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
|
# Add views
|
||||||
backend.add_view(ProjectView(Project, db.session, name='Projects', url='projects'))
|
backend.add_view(ProjectView(Project, db.session, name='Projects', url='projects'))
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from application import db
|
from application import db
|
||||||
|
|
||||||
|
|
||||||
class Project(db.Model):
|
class Project(db.Model):
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
name = db.Column(db.String(255), nullable=False)
|
name = db.Column(db.String(255), nullable=False)
|
||||||
@@ -8,7 +9,21 @@ class Project(db.Model):
|
|||||||
upload_path = db.Column(db.Text, nullable=False)
|
upload_path = db.Column(db.Text, nullable=False)
|
||||||
picture = db.Column(db.String(80))
|
picture = db.Column(db.String(80))
|
||||||
creation_date = db.Column(db.DateTime(), default=datetime.datetime.now)
|
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):
|
def __str__(self):
|
||||||
return str(self.name)
|
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
|
||||||
|
@@ -0,0 +1,36 @@
|
|||||||
|
"""project_settings
|
||||||
|
|
||||||
|
Revision ID: 52d9e7b917f
|
||||||
|
Revises: 4918c57ece7
|
||||||
|
Create Date: 2014-11-07 11:15:13.057416
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '52d9e7b917f'
|
||||||
|
down_revision = '4918c57ece7'
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('project_setting',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('project_id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('name', sa.String(length=256), nullable=False),
|
||||||
|
sa.Column('description', sa.Text(), nullable=True),
|
||||||
|
sa.Column('value', sa.String(length=100), nullable=False),
|
||||||
|
sa.Column('data_type', sa.String(length=128), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
|
||||||
|
sa.PrimaryKeyConstraint('id'),
|
||||||
|
sa.UniqueConstraint('name')
|
||||||
|
)
|
||||||
|
### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_table('project_setting')
|
||||||
|
### end Alembic commands ###
|
@@ -1,5 +1,5 @@
|
|||||||
Flask==0.10.1
|
Flask==0.10.1
|
||||||
Flask-Admin==1.0.8
|
Flask-Admin==1.0.7
|
||||||
Flask-HTTPAuth==2.3.0
|
Flask-HTTPAuth==2.3.0
|
||||||
Flask-Login==0.2.11
|
Flask-Login==0.2.11
|
||||||
Flask-Mail==0.9.1
|
Flask-Mail==0.9.1
|
||||||
@@ -15,7 +15,7 @@ Mako==1.0.0
|
|||||||
MarkupSafe==0.23
|
MarkupSafe==0.23
|
||||||
Pillow==2.6.1
|
Pillow==2.6.1
|
||||||
SQLAlchemy==0.9.8
|
SQLAlchemy==0.9.8
|
||||||
WTForms==2.0.1
|
WTForms==1.0.5
|
||||||
Werkzeug==0.9.6
|
Werkzeug==0.9.6
|
||||||
alembic==0.6.7
|
alembic==0.6.7
|
||||||
aniso8601==0.83
|
aniso8601==0.83
|
||||||
|
Reference in New Issue
Block a user