Exemplo n.º 1
0
def edit_member():

    form = MemberOfProjectForm()

    pfactory = PosGraduationFactory(current_user.pg_initials)
    dao = pfactory.projects_database_dao()
    projects = pfactory.projects_database_dao().find()
    projects = list(projects)
    projects = dumps(projects)
    if form.validate_on_submit():
        index = str(form.index.data)
        new_member = {
            'name': form.name.data,
            'general_role': form.general_role.data,
            'project_role': form.project_role.data
        }
        dao.find_one_and_update({'_id': ObjectId(form.project_id.data)},
                                {'$set': {
                                    'members.' + index: new_member
                                }})
        projects = pfactory.projects_database_dao().find()
        projects = list(projects)
        projects = dumps(projects)
        return jsonify(projects=projects)
    else:
        return jsonify({'error': 'Houve um erro'})
Exemplo n.º 2
0
def view_member():

    form = MemberOfProjectForm()

    pfactory = PosGraduationFactory(current_user.pg_initials)
    projects = pfactory.projects_database_dao().find()
    projects = list(projects)
    projects = dumps(projects)
    if request.args.get('crud_type') == 'Adicionar':
        return render_template('admin/add_member_in_project.html',
                               form=form,
                               projects=projects,
                               crud_type=request.args.get('crud_type'),
                               success_msg=request.args.get('success_msg'))
    if request.args.get('crud_type') == 'Deletar':
        return render_template('admin/delete_member_in_project.html',
                               form=form,
                               projects=projects,
                               crud_type=request.args.get('crud_type'),
                               success_msg=request.args.get('success_msg'))
    else:
        return render_template('admin/edit_member_in_project.html',
                               form=form,
                               projects=projects,
                               crud_type=request.args.get('crud_type'),
                               success_msg=request.args.get('success_msg'))
def delete_member():

    form = MemberOfProjectForm()

    pfactory = PosGraduationFactory(current_user.pg_initials)
    dao = pfactory.projects_database_dao()
    projects = pfactory.projects_database_dao().find()
    projects = list(projects)
    projects = dumps(projects)
    if form.validate_on_submit():
        index = str(form.index.data)
        dao.find_one_and_update({'_id' : ObjectId(form.project_id.data)}, {
            '$set': {'members.' + index + '.deleted' : '' }})
        projects = pfactory.projects_database_dao().find()
        projects = list(projects)
        projects = dumps(projects)
        return jsonify(projects=projects)
    else:
        return jsonify({'error':'Houve um erro'})
Exemplo n.º 4
0
def delete_member():

    form = MemberOfProjectForm()

    pfactory = PosGraduationFactory(current_user.pg_initials)
    dao = pfactory.projects_database_dao()
    projects = pfactory.projects_database_dao().find()
    projects = list(projects)
    projects = dumps(projects)
    if form.validate_on_submit():
        index = str(form.index.data)
        dao.find_one_and_update(
            {'_id': ObjectId(form.project_id.data)},
            {'$set': {
                'members.' + index + '.deleted': ''
            }})
        projects = pfactory.projects_database_dao().find()
        projects = list(projects)
        projects = dumps(projects)
        return jsonify(projects=projects)
    else:
        return jsonify({'error': 'Houve um erro'})
def add_member():

    form = MemberOfProjectForm()

    pfactory = PosGraduationFactory(current_user.pg_initials)
    dao = pfactory.projects_database_dao()
    projects = pfactory.projects_database_dao().find()
    projects = list(projects)
    projects = dumps(projects)
    if form.validate_on_submit():
        new_member = {
            'name' : form.name.data,
            'general_role' : form.general_role.data,
            'project_role' : form.project_role.data
        }
        dao.find_one_and_update({'_id' : ObjectId(form.project_id.data)}, {
            '$push': {'members': new_member}})
        projects = pfactory.projects_database_dao().find()
        projects = list(projects)
        projects = dumps(projects)
        return jsonify(projects=projects)
    else:
        return jsonify({'error':'Houve um erro'})