예제 #1
0
def dev_edit_common_issue(common_issue_id):
    """开发工程师编辑项目共性问题"""

    for index, breadcrumb in enumerate(session['breadcrumbs']):
        if '修改问题' == breadcrumb['text']:
            session['breadcrumbs'] = session['breadcrumbs'][:index + 1]
            break
    else:
        session['breadcrumbs'].append(
            {'text': '修改问题', 'url': url_for('project.dev_edit_common_issue', common_issue_id=common_issue_id)})

    common_issue = CommonIssue.query.filter_by(id=common_issue_id).first()
    if common_issue.attachment:
        attachment = [(tmp, os.path.basename(tmp))for tmp in common_issue.attachment.split('#')]
    else:
        attachment = []

    all_project = [tmp for tmp in ProjectAndroid.query.all() if tmp.status != '关闭']
    all_platform = BPlatform.query.all()
    all_developer = User.query.join(Role).filter(db.and_(User.activate==True, Role.name=='developer')).all()
    all_spm = User.query.join(Role).filter(db.and_(User.activate==True, Role.name=='spm')).all()

    if request.method == 'POST':
        solutions = request.form.get('solutions', '').strip()
        spm_id = request.form.get('spm_id', '')
        attachment = request.form.get('attachment', '')

        common_issue.solutions = solutions
        if spm_id:
            common_issue.spm_id = spm_id
            common_issue.status = 3

        common_issue.submit_solution_time = datetime.now()
        if common_issue.attachment and common_issue.attachment.strip():
            common_issue.attachment = '#'.join([tmp.strip() for tmp in common_issue.attachment.split('#') if tmp]
            + [tmp.strip() for tmp in attachment.split('#') if tmp.strip()])
        else:
            common_issue.attachment = attachment

        db.session.add(common_issue)
        db.session.commit()

        return redirect(url_for('project.common_issue_page'))

    return render_template('project/android/common_issue/common_issue_edit.html',
                           common_issue=common_issue,
                           all_project=all_project,
                           all_developer=all_developer,
                           all_spm=all_spm,
                           all_platform=all_platform,
                           attachment=attachment)
예제 #2
0
def set_project_branch_commit_merge_commit():
    """
    将commit标识为合并提交
    :return:
    """

    first_project_code_id = request.form.get('first_project_code')
    second_project_code_id = request.form.get('second_project_code')
    commit_id = request.form.get('commit_id')
    option = request.form.get('option')

    if option == 'on':
        merge_commit = ProjectBranchMergeCommit()
        merge_commit.commit_id = commit_id
        merge_commit.dest_project_code_id = first_project_code_id
        merge_commit.src_project_code_id = second_project_code_id
        merge_commit.meger_author_email = current_user.email

        db.session.add(merge_commit)
        db.session.commit()
    else:
        merge_commit = ProjectBranchMergeCommit.query.filter(
            db.and_(ProjectBranchMergeCommit.commit_id == commit_id,
                    ProjectBranchMergeCommit.dest_project_code_id == first_project_code_id,
                    ProjectBranchMergeCommit.src_project_code_id == second_project_code_id)).first()
        if merge_commit:
            db.session.delete(merge_commit)
            db.session.commit()

    return '{result: ture}'
예제 #3
0
파일: views.py 프로젝트: AKMFCJ/tms
def edit_system_menu(menu_id):
    """修改菜单"""

    for index, breadcrumb in enumerate(session["breadcrumbs"]):
        if "编辑菜单" == breadcrumb["text"]:
            session["breadcrumbs"] = session["breadcrumbs"][: index + 1]
            break
    else:
        session["breadcrumbs"].append({"text": "编辑菜单", "url": url_for("auth.edit_system_menu", menu_id=menu_id)})

    menu = SystemMenu.query.filter_by(id=menu_id).first()
    if request.method == "POST":
        name = request.form["name"]
        action = request.form.get("action", "")
        activate = request.form.get("activate")
        note = request.form.get("note")
        order = request.form["order"]
        parent_id = request.form["parent"]

        other_menu = SystemMenu.query.filter(
            db.and_(SystemMenu.action == action, SystemMenu.parent_id == parent_id)
        ).first()
        if other_menu and other_menu.id != menu.id:
            flash(u"同名菜单存在", "danger")
        else:
            menu.name = name
            menu.action = action or ""
            menu.note = note
            if activate == "on":
                menu.activate = True
            else:
                menu.activate = False
            menu.style = ""
            menu.note = note
            menu.order = order
            if parent_id:
                menu.parent_id = parent_id
            db.session.add(menu)
            db.session.commit()

            flash(u"修改成功!", "info")

    return render_template(
        "admin/account/system_menu_edit.html",
        menu=menu,
        parent_menus=SystemMenu.query.filter(db.and_(SystemMenu.action == "", SystemMenu.activate == True)).all(),
    )
예제 #4
0
def project_myos_app_search(app_name):
    """查找APP被哪些项目及哪些版本使用了"""

    # 配置了此app且开关是打开的的项目
    project_app = ProjectMyOSConfig.query.filter(db.and_(ProjectMyOSConfig.app_name.like('%{0}%'.format(app_name)),
                                                         ProjectMyOSConfig.support == 'yes')).all()

    return render_template('/project/android/project_app_search_page.html', project_app=project_app)
예제 #5
0
def project_myos_app_edit(project_id, project_app_id):
    """
    编辑项目的MYOS应用配置
    :param project_id:
    :param project_app_id:
    :return:
    """

    project_obj = ProjectAndroid.query.filter(ProjectAndroid.id == project_id).first()
    if project_app_id:
        project_app = ProjectMyOSConfig.query.filter(ProjectMyOSConfig.id == project_app_id).first()
        versions = [tmp.version_number for tmp in Version.query.join(SpecialVersion).filter(
            db.and_(SpecialVersion.app_name == project_app.app_name)).order_by(Version.id.desc()).all()]
    else:
        project_app = ProjectMyOSConfig()
        versions = []

    all_app = SpecialVersion.query.all()

    if request.method == 'POST':
        app_name = request.form.get('app_name')

        other = ProjectMyOSConfig.query.filter(db.and_(ProjectMyOSConfig.project_id == project_id,
                                                       ProjectMyOSConfig.app_name == app_name)).first()
        if other and other.id != project_app.id:
            flash('%s:应用配置重复了' % app_name, 'warning')
        else:
            project_app.app_name = app_name
            if request.form.get('support') == 'on':
                project_app.support = 'yes'
            else:
                project_app.support = 'no'
            project_app.overrides = request.form.get('overrides')
            project_app.app_version = request.form.get('version')
            project_app.project = project_obj

            db.session.add(project_app)
            db.session.commit()
            return redirect(url_for('project.project_myos_config_detail_page', project_id=project_id))

    return render_template('/project/android/project_myos_app_edit_page.html',
                           all_app=all_app,
                           project=project_obj,
                           app=project_app,
                           versions=versions)
예제 #6
0
def project_branch_commit_compare(first_project_code_id, second_project_code_id):
    """
    比较两个分支将first上比second多的内容显示出来
    :param first_project_code_id:
    :param second_project_id:
    :return:
    """

    for index, breadcrumb in enumerate(session['breadcrumbs']):
        if '分支比较' == breadcrumb['text']:
            session['breadcrumbs'] = session['breadcrumbs'][:index + 1]
            break
    else:
        session['breadcrumbs'].append(
            {'text': '分支比较', 'url': url_for('project.project_branch_commit_compare',
                                            first_project_code_id=first_project_code_id,
                                            second_project_code_id=second_project_code_id
                                            )})

    second_commits = [commit.commit_id for commit in
                      ProjectBranchCommit.query.filter(ProjectBranchCommit.project_code_id == second_project_code_id).all()]
    difference_commits = ProjectBranchCommit.query.filter(
        db.and_(ProjectBranchCommit.project_code_id == first_project_code_id,
                ~ProjectBranchCommit.commit_id.in_(second_commits)
                )).order_by(ProjectBranchCommit.commit_date.desc()).all()

    merge_commits = [tmp.commit_id for tmp in ProjectBranchMergeCommit.query.filter(
        db.and_(ProjectBranchMergeCommit.dest_project_code_id == first_project_code_id,
                ProjectBranchMergeCommit.src_project_code_id == second_project_code_id)).all()]
    result = []
    for commit in difference_commits:
        if commit.commit_id not in merge_commits:
            result.append(commit)

    first_branch  = ProjectCode.query.filter_by(id=first_project_code_id).first()
    second_branch  = ProjectCode.query.filter_by(id=second_project_code_id).first()

    return render_template('project/android/project_branch_commit_compare.html',
                           difference_commits=result,
                           first_branch=first_branch,
                           second_branch=second_branch
                           )
예제 #7
0
def project_myos_app_info(app_name, version_number):
    """
    显示应用版本的详细信息
    :param app_name:
    :param version_number:
    :return:
    """

    app_version = Version.query.join(SpecialVersion).filter(db.and_(SpecialVersion.app_name == app_name,
                                                                    Version.version_number == version_number)).first()

    return redirect(url_for('developer.version_self_test', version_id=app_version.id))
예제 #8
0
def get_myos_app_verion():
    """
    获取myos 应用所有已发布的版本
    :return:
    """

    app_name = request.args.get('app_name')

    versions = [{'name': tmp.version_number}for tmp in Version.query.join(SpecialVersion).filter(
        db.and_(SpecialVersion.app_name== app_name)).order_by(Version.id.desc()).all()]

    return json.dumps(versions)
예제 #9
0
파일: views.py 프로젝트: AKMFCJ/tms
def edit_special_version(special_version_id):
    """新增或编辑项目版本类型"""

    special_version = SpecialVersion.query.filter(SpecialVersion.id == special_version_id).first()
    project_obj = special_version.project

    # 系统管理员和配置管理员才能修改项目的源码及发布仓库地址

    code_repo_list = Repository.query.filter(Repository.category == 2).all()
    release_repo_list = Repository.query.filter(Repository.category == 3).all()
    # for repo in code_repo_list:
    #     repo.repo_url = '{0}:{1}/{2}'.format(repo.platform.server.remote_name, repo.platform.name, repo.name)
    #
    # for repo in release_repo_list:
    #     repo.repo_url = '{0}:{1}/{2}'.format(repo.platform.server.remote_name, repo.platform.name, repo.name)

    if request.method == 'POST':
        name = request.form.get('name')
        app_name = request.form.get('app_name')
        description = request.form.get('description')
        ftp_path = request.form.get('ftp_path')
        svn_path = request.form.get('svn_path')
        code_repo = request.form.get('code_repo')
        release_repo = request.form.get('release_repo')
        other_special_version = SpecialVersion.query.filter(
            db.and_(SpecialVersion.name == name, SpecialVersion.project_id == project_obj.id)).first()
        if other_special_version and other_special_version.id != special_version_id:
            flash(u'同名版本类型已存在', 'danger')
        else:
            special_version.name = name
            special_version.app_name = app_name
            special_version.description = description
            special_version.ftp_path = ftp_path
            special_version.svn_path = svn_path
            special_version.code_repo = Repository.query.filter(Repository.id == code_repo).first()
            special_version.release_repo = Repository.query.filter(Repository.id == release_repo).first()

            db.session.add(special_version)
            db.session.commit()
            return redirect(url_for('developer.edit_project', project_id=project_obj.id))

    return render_template('/scm/edit_special_version.html',
                           project=project_obj,
                           special_version=special_version,
                           special_version_id=special_version.id,
                           code_repo_list=code_repo_list,
                           release_repo_list=release_repo_list
                           )
예제 #10
0
def project_myos_config_detail_page(project_id):
    """项目myos应用的具体配置信息"""

    for index, breadcrumb in enumerate(session['breadcrumbs']):
        if '项目MyOS应用配置' == breadcrumb['text']:
            session['breadcrumbs'] = session['breadcrumbs'][:index+1]
            break
    else:
        session['breadcrumbs'].append({'text': '项目MyOS应用配置', 'url': url_for('project.project_myos_config_detail_page', project_id=project_id)})

    configs = ProjectMyOSConfig.query.filter(ProjectMyOSConfig.project_id == project_id).all()
    project = ProjectAndroid.query.filter_by(id=project_id).first()
    other_project = ProjectAndroid.query.filter(db.and_(ProjectAndroid.myos_config_patch != '',
                                                        ProjectAndroid.id != project_id)).all()

    return render_template('/project/android/project_myos_config_detail_page.html',
                           project=project,
                           configs=configs,
                           other_project=other_project)
예제 #11
0
파일: views.py 프로젝트: AKMFCJ/tms
def login():
    """用户登录"""

    if request.method == "POST":
        user = User.query.filter_by(username=request.form["username"]).first()

        if user is not None and user.verify_password(request.form["password"]):
            login_user(user, request.form.get("remember"))
            user.last_seen = datetime.now()
            role = user.role
            if role and role.menu:
                menu_ids = [menu_id for menu_id in role.menu.split(",") if id]
                menus = [
                    menu
                    for menu in SystemMenu.query.filter(
                        db.and_(SystemMenu.activate == True, SystemMenu.id.in_(menu_ids))
                    )
                    .order_by(SystemMenu.order)
                    .all()
                ]
                current_page = role.index_page
            else:
                menus = []
                current_page = ""

            session["user"] = {
                "id": user.id,
                "username": user.username,
                "display_name": user.display_name,
                "email": user.email,
                "role_name": role.name,
            }
            session["index_page"] = current_page
            session["menu"] = create_menu(menus)
            session["breadcrumbs"] = [{"text": "Home", "url": url_for(role.index_page)}]

            return redirect(url_for(current_page, url_path=current_page))

        flash("Invalid email or password.", "danger")

    return render_template("auth/login.html")
예제 #12
0
파일: views.py 프로젝트: AKMFCJ/tms
def add_special_version(project_id):
    """新增或编辑项目版本类型"""

    project_obj = Project.query.filter(Project.id == project_id).first()
    # 系统管理员和配置管理员才能修改项目的源码及发布仓库地址

    code_repo_list = Repository.query.filter(Repository.category == 2).all()
    release_repo_list = Repository.query.filter(Repository.category == 3).all()

    if request.method == 'POST':
        name = request.form.get('name')
        description = request.form.get('description')
        ftp_path = request.form.get('ftp_path')
        svn_path = request.form.get('svn_path')
        code_repo = request.form.get('code_repo')
        release_repo = request.form.get('release_repo')
        other_special_version = SpecialVersion.query.filter(
            db.and_(SpecialVersion.name == name, SpecialVersion.project_id == project_id)).first()
        if other_special_version:
            flash(u'同名版本类型已存在', 'danger')
        else:
            special_version = SpecialVersion()
            special_version.name = name
            special_version.description = description
            special_version.ftp_path = ftp_path
            special_version.svn_path = svn_path
            special_version.code_repo = Repository.query.filter(Repository.id == code_repo).first()
            special_version.release_repo = Repository.query.filter(Repository.id == release_repo).first()
            special_version.project = project_obj
            db.session.add(special_version)
            db.session.commit()

            return redirect(url_for('developer.edit_project', project_id=project_id))

    return render_template('/scm/edit_special_version.html',
                           project=project_obj,
                           special_version=None,
                           code_repo_list=code_repo_list,
                           special_version_id=0,
                           release_repo_list=release_repo_list
                           )
예제 #13
0
파일: views.py 프로젝트: AKMFCJ/tms
def add_account():
    """新增账号"""

    for index, breadcrumb in enumerate(session["breadcrumbs"]):
        if "添加账号" == breadcrumb["text"]:
            session["breadcrumbs"] = session["breadcrumbs"][: index + 1]
            break
    else:
        session["breadcrumbs"].append({"text": "添加账号", "url": url_for("auth.add_account")})

    new_user = None
    if request.method == "POST":
        if request.form["password"] != request.form["password2"]:
            flash(u"两次输入的密码不相同", "danger")
            return redirect(url_for("auth.add_account"))

        user = User.query.filter_by(email=request.form["email"]).first()
        if user is not None:
            flash(u"此邮箱地址已注册过", "danger")
            return redirect(url_for("auth.add_account"))

        new_user = User()
        new_user.username = request.form["username"]
        new_user.email = request.form["email"]
        new_user.password = request.form["password"]
        new_user.display_name = request.form["display_name"]
        new_user.role = Role.query.filter_by(id=request.form["role"]).first()

        db.session.add(new_user)
        db.session.commit()

        flash(u"新增成功", "info")

    return render_template(
        "admin/account/account_edit.html",
        user=new_user,
        roles=Role.query.filter(db.and_(Role.name != "translator", Role.name != "customer_manager")).all(),
        current_page="auth.account_page",
    )
예제 #14
0
파일: views.py 프로젝트: AKMFCJ/tms
def edit_account(user_id):
    """编辑账号"""

    for index, breadcrumb in enumerate(session["breadcrumbs"]):
        if "编辑账号" == breadcrumb["text"]:
            session["breadcrumbs"] = session["breadcrumbs"][: index + 1]
            break
    else:
        session["breadcrumbs"].append({"text": "编辑账号", "url": url_for("auth.edit_account", user_id=user_id)})

    user = user = User.query.filter_by(id=user_id).first()

    if request.method == "POST":
        other_user = User.query.filter_by(email=request.form["email"]).first()
        if user.id != other_user.id:
            flash(u"此邮箱地址已注册过", "danger")
        if request.form["password"] != request.form["password2"]:
            flash(u"两次输入的密码不相同", "danger")

        if user.password_hash != request.form["password"]:
            user.password = request.form["password"]

        user.username = request.form["username"]
        user.email = request.form["email"]
        user.display_name = request.form["display_name"]
        user.role = Role.query.filter_by(id=request.form["role"]).first()

        db.session.add(user)
        db.session.commit()
        flash(u"更新成功!", "info")

    return render_template(
        "admin/account/account_edit.html",
        user=user,
        roles=Role.query.filter(db.and_(Role.name != "translator", Role.name != "customer_manager")).all(),
    )
예제 #15
0
def qa_edit_common_issue(common_issue_id):
    """测试工程师编辑项目共性问题"""

    for index, breadcrumb in enumerate(session['breadcrumbs']):
        if '修改问题' == breadcrumb['text']:
            session['breadcrumbs'] = session['breadcrumbs'][:index + 1]
            break
    else:
        session['breadcrumbs'].append(
            {'text': '修改问题', 'url': url_for('project.qa_edit_common_issue', common_issue_id=common_issue_id)})

    common_issue = CommonIssue.query.filter_by(id=common_issue_id).first()
    if common_issue.attachment:
        attachment = [(tmp, os.path.basename(tmp))for tmp in common_issue.attachment.split('#')]
    else:
        attachment = []

    all_project = [tmp for tmp in ProjectAndroid.query.all() if tmp.status != '关闭']
    all_platform = BPlatform.query.all()
    all_developer = User.query.join(Role).filter(db.and_(User.activate==True, Role.name=='developer')).all()
    all_spm = User.query.join(Role).filter(db.and_(User.activate==True, Role.name=='spm')).all()

    if request.method == 'POST':
        name = request.form.get('name', '').strip()
        description = request.form.get('description', '').strip()
        solutions = request.form.get('solutions', '').strip()
        effect_scope = ','.join(request.form.getlist('effect_scope'))
        platform_name = request.form.get('platform_name', '')
        baseline_name = request.form.get('baseline_name', '').strip()
        jira_key = request.form.get('jira_key', '').strip()
        attachment = request.form.get('attachment', '')
        developer_id = request.form.get('developer_id', '')
        spm_id = request.form.get('spm_id', '')

        current_app.logger.info(developer_id)

        other = CommonIssue.query.filter(CommonIssue.name == name).first()
        if other and other.id != common_issue_id:
            flash(u'同名的共性问题已存在', 'warning')
        else:
            common_issue.name = name
            common_issue.description = description
            common_issue.solutions = solutions
            if effect_scope != ',':
                common_issue.effect_scope = effect_scope
            common_issue.platform_name = platform_name
            common_issue.baseline_name = baseline_name
            if jira_key:
                common_issue.jira_key = jira_key
            if developer_id:
                common_issue.developer_id = developer_id
                common_issue.status = 2
            if spm_id:
                common_issue.spm_id = spm_id
            common_issue.submit_issue_time = datetime.now()
            if common_issue.attachment and common_issue.attachment.strip():
                common_issue.attachment = '#'.join([tmp.strip() for tmp in common_issue.attachment.split('#') if tmp]
                + [tmp.strip() for tmp in attachment.split('#') if tmp.strip()])
            else:
                common_issue.attachment = attachment

            db.session.add(common_issue)
            db.session.commit()

            return redirect(url_for('project.common_issue_page'))

    return render_template('project/android/common_issue/common_issue_edit.html',
                           common_issue=common_issue,
                           all_project=all_project,
                           all_developer=all_developer,
                           all_spm=all_spm,
                           all_platform=all_platform,
                           attachment=attachment)
예제 #16
0
def add_common_issue():
    """添加项目共性问题"""

    for index, breadcrumb in enumerate(session['breadcrumbs']):
        if '添加问题' == breadcrumb['text']:
            session['breadcrumbs'] = session['breadcrumbs'][:index + 1]
            break
    else:
        session['breadcrumbs'].append(
            {'text': '添加问题', 'url': url_for('project.add_common_issue')})

    common_issue = CommonIssue()

    all_project = [tmp for tmp in ProjectAndroid.query.all() if tmp.status != '关闭']
    all_platform = BPlatform.query.all()
    all_developer = User.query.join(Role).filter(db.and_(User.activate==True, Role.name=='developer')).all()
    all_spm = User.query.join(Role).filter(db.and_(User.activate==True, Role.name=='spm')).all()

    if request.method == 'POST':
        name = request.form.get('name', '').strip()
        project_id = request.form.get('project_id', '')
        description = request.form.get('description', '').strip()
        solutions = request.form.get('solutions', '').strip()
        effect_scope = ','.join(request.form.getlist('effect_scope'))
        platform_name = request.form.get('platform_name', '')
        baseline_name = request.form.get('baseline_name', '').strip()
        jira_key = request.form.get('jira_key', '').strip()
        attachment = request.form.get('attachment', '')
        developer_id = request.form.get('developer_id', '')
        spm_id = request.form.get('spm_id', '')

        other = CommonIssue.query.filter(CommonIssue.name == name).first()
        if other:
            flash(u'同名的共性问题已存在', 'warning')
        else:
            common_issue.name = name
            common_issue.project_id = project_id
            common_issue.description = description
            common_issue.solutions = solutions
            common_issue.effect_scope = effect_scope
            common_issue.platform_name = platform_name
            common_issue.baseline_name = baseline_name
            common_issue.tester_id = current_user.id
            if jira_key:
                common_issue.jira_key = jira_key
            if developer_id:
                common_issue.developer_id = developer_id
                common_issue.status = 2
            if spm_id:
                common_issue.spm_id = spm_id
            common_issue.submit_issue_time = datetime.now()
            common_issue.attachment = attachment

            db.session.add(common_issue)
            db.session.commit()

            # 给开发工程师发送邮件,让其填写解决方案
            cc_list = [user.email for user in User.query.join(Role).filter(Role.name == 'scm').all()]

            msg = Message(
                u'[TSDS] %s 新增项目共性问题' % (project.name),
                sender='*****@*****.**',
                # recipients=[common_issue.developer.email]
                recipients=['*****@*****.**']
            )
            msg.html = '<h5>项目共性问题名称</h5>:<br>{0}<br><br>' \
                       '<h5>问题创建人</h5>:<br>{1}<{2}><br><br>' \
                       '<h5>提出问题项目</h5>:<br>{3}<br><br>' \
                       '<h5>项目所属平台名称</h5>:<br>{4}<br><br>' \
                       '<h5>项目当前基线</h5>:<br>{5}<br><br>' \
                       '问题描述:<br>{6}<br>'.format(common_issue.name, current_user.display_name, current_user.email,
                                                 common_issue.project.name, common_issue.platform_name,
                                                 common_issue.baseline_name, common_issue.description)
            mail.send(msg)

            return redirect(url_for('project.common_issue_page'))

    return render_template('project/android/common_issue/common_issue_edit.html',
                           common_issue=common_issue,
                           all_project=all_project,
                           all_developer=all_developer,
                           all_spm=all_spm,
                           all_platform=all_platform)