Esempio n. 1
0
def delete(id):
    check_admin()
    task = Task.query.get_or_404(id)
    task.is_active = False

    db.session.commit()
    flash('Delete successs')

    return redirect(url_for('task.index'))
Esempio n. 2
0
def delete_user_role(id):
    check_admin()
    user_role = UserRole.query.get_or_404(id)
    user_role.is_active = False

    db.session.commit()
    flash('Delete successs')

    return redirect(url_for('userrole.index_user_role'))
Esempio n. 3
0
def edit(id):
    check_admin()
    add_task = False

    task = Task.query.get_or_404(id)
    form = TaskForm(obj=task)
    if form.validate_on_submit():
        task.task_name = form.task_name.data
        task.task_type = form.task_type.data
        task.man_days_quoted = form.man_days_quoted.data
        task.man_days_dev = form.man_days_dev.data
        task.main_sa = form.main_sa.data
        task.status = form.status.data
        task.assigned_by = form.assigned_by.data
        task.assigned_date = form.assigned_date.data
        task.dev_code = form.dev_code.data.id
        task.est_start_date_dev = form.est_start_date_dev.data
        task.est_end_date_dev = form.est_end_date_dev.data
        task.qa_code = form.qa_code.data
        task.est_start_date_qa = form.est_start_date_qa.data
        task.est_end_date_qa = form.est_end_date_qa.data
        task.description = form.description.data
        task.priority = form.priority.data
        task.parent_task_id = form.parent_task_id.data.id
        task.project_id = form.project_id.data

        db.session.commit()
        socketio.emit('message', {'msg': session.get('username') + ':' + 'ok'}, room=form.dev_code.data.username)
        flash('Edit task success')
        return redirect(url_for('task.index'))

    form.task_name.data = task.task_name
    form.task_type.data = task.task_type
    form.man_days_quoted.data = task.man_days_quoted
    form.man_days_dev.data = task.man_days_dev
    form.main_sa.data = task.main_sa
    form.status.data = task.status
    form.assigned_by.data = task.assigned_by
    form.assigned_date.data = task.assigned_date
    form.dev_code.data = task.dev_code
    form.est_start_date_dev.data = task.est_start_date_dev
    form.est_end_date_dev.data = task.est_end_date_dev
    form.qa_code.data = task.qa_code
    form.est_start_date_qa.data = task.est_start_date_qa
    form.est_end_date_qa.data = task.est_end_date_qa
    form.description.data = task.description
    form.priority.data = task.priority
    form.parent_task_id.data = task.parent_task_id
    form.project_id.data = task.project_id

    return render_template('module_task/task.html', title='Task | Edit Task',
                           add_task=add_task, form=form, task=task)
Esempio n. 4
0
def create():
    check_admin()

    add_task = True

    form = TaskForm()
    if form.validate_on_submit():
        task = Task(
            task_code=form.task_code.data,
            task_name=form.task_name.data,
            task_type=form.task_type.data,
            man_days_quoted=form.man_days_quoted.data,
            man_days_dev=form.man_days_dev.data,
            main_sa=form.main_sa.data,
            status=form.status.data,
            assigned_by=form.assigned_by.data,
            assigned_date=form.assigned_date.data,
            dev_code=form.dev_code.data,
            est_start_date_dev=form.est_start_date_dev.data,
            est_end_date_dev=form.est_end_date_dev.data,
            qa_code=form.qa_code.data.id,
            est_start_date_qa=form.est_start_date_qa.data,
            est_end_date_qa=form.est_end_date_qa.data,
            description=form.description.data,
            parent_task_id=form.parent_task_id.data.id,
            project_id=form.project_id.data,
            priority=form.priority.data
        )

        try:
            db.session.add(task)
            db.session.commit()
            flash('Add Task success')
        except Exception as e:
            print(e)
            flash('Error when add task')

        return redirect(url_for('task.index'))
    return render_template('module_task/task.html', title='Task | Create New Task',
                           add_task=add_task, form=form)
Esempio n. 5
0
def create_user_role():
    check_admin()

    add_user_role = True

    form = UserRoleForm()
    if form.validate_on_submit():
        user_role = UserRole(role_code=form.role_code.data.role_code,
                             username=form.username.data.username)

        try:
            db.session.add(user_role)
            db.session.commit()
            flash('Add User Role success')
        except Exception as e:
            flash('Error when add User Role')

        return redirect(url_for('userrole.index_user_role'))
    return render_template('module_role/user_role.html',
                           title='User Role | Create New User Role',
                           add_user_role=add_user_role,
                           form=form)
Esempio n. 6
0
def edit(id):
    check_admin()
    add_role = False

    role = Role.query.get_or_404(id)
    form = RoleForm(obj=Role)
    if form.validate_on_submit():
        role.role_name = form.role_name.data
        role.is_supervisor = form.is_supervisor.data

        db.session.commit()
        flash('Edit Role success')
        return redirect(url_for('role.index'))

    form.role_name.data = role.role_name
    form.is_supervisor.data = Role.is_supervisor

    return render_template('module_role/role.html',
                           title='Role | Edit Role',
                           add_role=add_role,
                           form=form,
                           role=role)
Esempio n. 7
0
def edit_user_role(id):
    check_admin()
    add_user_role = False

    user_role = UserRole.query.get_or_404(id)
    form = UserRoleForm(obj=user_role)
    if form.validate_on_submit():
        user_role.role_code = form.role_code.data
        user_role.username = form.username.data

        db.session.commit()
        flash('Edit User Role success')
        return redirect(url_for('userrole.index_user_role'))

    form.role_code.data = user_role.role_code
    form.username.data = user_role.username

    return render_template('module_role/user_role.html',
                           title='User Role | Edit User Role',
                           add_user_role=add_user_role,
                           form=form,
                           user_role=user_role)
Esempio n. 8
0
def create():
    check_admin()

    add_role = True

    form = RoleForm()
    if form.validate_on_submit():
        role = Role(role_code=form.role_code.data,
                    role_name=form.role_name.data,
                    is_supervisor=form.is_supervisor.data)

        try:
            db.session.add(role)
            db.session.commit()
            flash('Add Role success')
        except:
            flash('Error when add Role')

        return redirect(url_for('role.index'))
    return render_template('module_role/role.html',
                           title='Role | Create New Role',
                           add_role=add_role,
                           form=form)