Skip to content

Commit

Permalink
Merge branch 'develope'
Browse files Browse the repository at this point in the history
* develope: (42 commits)
  change websocket key, from repository_id to ci_pipeline_id.
  add git_repo_id_to_ci_pipe_id api
  add disconnect.
  Remove disconnect
  fix user cannot save
  hot fixed. web socket will into infinite function
  Emergency bug.
  fix bug
  fix ad  null  handling
  fix plugin status
  add create user from ad by parameter
  add project column on delete action
  change user_reloader=False
  create & delete project add creator_id
  add project creator_id
  Craft NexusIssue and remove redundant API
  add set default project creator
  add alembic version file
  add project  creator id column
  fix  model column
  ...
  • Loading branch information
demoyuw committed May 5, 2021
2 parents c6597b9 + a1f4cde commit 214b7df
Show file tree
Hide file tree
Showing 17 changed files with 721 additions and 302 deletions.
30 changes: 30 additions & 0 deletions apis/alembic/versions/39ac2afbe86f_add_project_creator_column.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""add project creator column
Revision ID: 39ac2afbe86f
Revises: ec4c3aab9b73
Create Date: 2021-05-04 17:06:28.369384
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '39ac2afbe86f'
down_revision = 'ec4c3aab9b73'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('projects', sa.Column('creator_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'projects', 'user', ['creator_id'], ['id'])
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'projects', type_='foreignkey')
op.drop_column('projects', 'creator_id')
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""add user creator_id column ondelete funtion
Revision ID: 856b68aedb0b
Revises: 39ac2afbe86f
Create Date: 2021-05-05 10:15:50.725992
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '856b68aedb0b'
down_revision = '39ac2afbe86f'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint('projects_owner_id_fkey', 'projects', type_='foreignkey')
op.drop_constraint('projects_creator_id_fkey', 'projects', type_='foreignkey')
op.create_foreign_key(None, 'projects', 'user', ['owner_id'], ['id'], ondelete='SET NULL')
op.create_foreign_key(None, 'projects', 'user', ['creator_id'], ['id'], ondelete='SET NULL')
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'projects', type_='foreignkey')
op.drop_constraint(None, 'projects', type_='foreignkey')
op.create_foreign_key('projects_creator_id_fkey', 'projects', 'user', ['creator_id'], ['id'])
op.create_foreign_key('projects_owner_id_fkey', 'projects', 'user', ['owner_id'], ['id'])
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""project member add department title
Revision ID: ec4c3aab9b73
Revises: 63cac0772a9c
Create Date: 2021-05-04 11:27:10.715603
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'ec4c3aab9b73'
down_revision = '63cac0772a9c'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('project_member', sa.Column('department', sa.String(), nullable=True))
op.add_column('project_member', sa.Column('title', sa.String(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('project_member', 'title')
op.drop_column('project_member', 'department')
# ### end Alembic commands ###
17 changes: 9 additions & 8 deletions apis/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ def initialize(db_uri):
logger.logger.info('Server initialized.')


api.add_resource(project.GitRepoIdToCiPipeId, '/git_repo_id_to_ci_pipe_id/<repository_id>')

# Projects
api.add_resource(project.ListMyProjects, '/project/list')
api.add_resource(project.SingleProject, '/project', '/project/<sint:project_id>')
Expand Down Expand Up @@ -272,6 +274,8 @@ def initialize(db_uri):
# Websocket
socketio.on_namespace(rancher.RancherWebsocketLog('/rancher/websocket/logs'))



# issue
api.add_resource(issue.IssueByProject, '/project/<sint:project_id>/issues')
api.add_resource(issue.IssueByTreeByProject, '/project/<sint:project_id>/issues_by_tree')
Expand All @@ -288,17 +292,14 @@ def initialize(db_uri):
api.add_resource(issue.IssueStatus, '/issues_status')
api.add_resource(issue.IssuePriority, '/issues_priority')
api.add_resource(issue.IssueTracker, '/issues_tracker')
api.add_resource(issue.IssueRDbyUser, '/issues_by_user/<user_id>')
api.add_resource(issue.MyIssueStatistics, '/issues/statistics')
api.add_resource(issue.MyOpenIssueStatistics, '/issues/open_statistics')
api.add_resource(issue.MyIssueWeekStatistics, '/issues/week_statistics')
api.add_resource(issue.MyIssueMonthStatistics, '/issues/month_statistics')

## release
# Release
api.add_resource(release.Releases, '/project/<project_id>/releases')
api.add_resource(release.Release, '/project/<project_id>/releases/<release_name>')

# Release
api.add_resource(plugin.Plugins, '/plugins')
api.add_resource(plugin.Plugin, '/plugins/<sint:plugin_id>')

Expand Down Expand Up @@ -444,10 +445,10 @@ def initialize(db_uri):
api.add_resource(gitlab.GitCountEachPjCommitsByDays, '/sync_gitlab/count_each_pj_commits_by_days')

# Subadmin Projects Permission
api.add_resource(project_permission.list_admin_projects, '/project_permission/admin_projects')
api.add_resource(project_permission.list_subadmin_projects, '/project_permission/subadmin_projects')
api.add_resource(project_permission.list_subadmins, '/project_permission/subadmins')
api.add_resource(project_permission.set_subadmin_permission, '/project_permission/set_permission')
api.add_resource(project_permission.AdminProjects, '/project_permission/admin_projects')
api.add_resource(project_permission.SubadminProjects, '/project_permission/subadmin_projects')
api.add_resource(project_permission.Subadmins, '/project_permission/subadmins')
api.add_resource(project_permission.SetPermission, '/project_permission/set_permission')

# System versions
api.add_resource(NexusVersion, '/system_versions')
Expand Down
20 changes: 18 additions & 2 deletions apis/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
'1.0.0.1', '1.0.0.2', '1.3.0.1', '1.3.0.2', '1.3.0.3', '1.3.0.4', '1.3.1', '1.3.1.1',
'1.3.1.2', '1.3.1.3', '1.3.1.4', '1.3.1.5', '1.3.1.6', '1.3.1.7', '1.3.1.8',
'1.3.1.9', '1.3.1.10', '1.3.1.11', '1.3.1.12', '1.3.1.13', '1.3.1.14', '1.3.2.1', '1.3.2.2',
'1.3.2.3', '1.3.2.4', '1.3.2.5', '1.3.2.6', '1.3.2.7', '1.3.2.8','1.3.2.9']
'1.3.2.3', '1.3.2.4', '1.3.2.5', '1.3.2.6', '1.3.2.7', '1.3.2.8','1.3.2.9','1.4.0.0','1.4.0.1','1.4.0.2']
ONLY_UPDATE_DB_MODELS = [
'0.9.2.1', '0.9.2.2', '0.9.2.3', '0.9.2.5', '0.9.2.6', '0.9.2.a8',
'1.0.0.2', '1.3.0.1', '1.3.0.2', '1.3.0.3', '1.3.0.4', '1.3.1', '1.3.1.1', '1.3.1.2',
'1.3.1.3', '1.3.1.4', '1.3.1.5', '1.3.1.6', '1.3.1.7', '1.3.1.8', '1.3.1.9', '1.3.1.10',
'1.3.1.11', '1.3.1.13', '1.3.1.14', '1.3.2.1', '1.3.2.2', '1.3.2.4', '1.3.2.6', '1.3.2.7','1.3.2.9'
'1.3.1.11', '1.3.1.13', '1.3.1.14', '1.3.2.1', '1.3.2.2', '1.3.2.4', '1.3.2.6', '1.3.2.7','1.3.2.9','1.4.0.0','1.4.0.1', '1.4.0.2'
]


Expand Down Expand Up @@ -54,6 +54,22 @@ def upgrade(version):
init_sync_redmine()
elif version == '1.3.2.8':
set_default_user_from_ad_column()
elif version == '1.4.0.1':
set_default_project_creator()

def set_default_project_creator():
rows = db.session.query(Project).\
filter(
Project.owner_id != None,
Project.creator_id == None
).all()
check = []
for row in rows:
if row.id not in check:
row.creator_id = row.owner_id
check.append(row.id)
db.session.commit()




Expand Down
5 changes: 4 additions & 1 deletion apis/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class Project(db.Model):
update_at = Column(DateTime)
disabled = Column(Boolean)
display = Column(String)
owner_id = Column(Integer, ForeignKey(User.id))
owner_id = Column(Integer, ForeignKey(User.id, ondelete='SET NULL'), nullable=True)
creator_id = Column(Integer, ForeignKey(User.id, ondelete='SET NULL'), nullable=True)

def __repr__(self):
fields = {}
Expand Down Expand Up @@ -412,6 +413,8 @@ class ProjectMember(db.Model):
project_name = Column(String)
role_id = Column(Integer)
role_name = Column(String)
department = Column(String)
title = Column(String)


class ProjectMemberCount(db.Model):
Expand Down
Loading

0 comments on commit 214b7df

Please sign in to comment.