Exemplo n.º 1
0
def createProjects(mnd_dataset, allergies_dataset, labels_added_mnd,
                   labels_added_allergies, user1, user2):

    mnd_desc = 'annotating gp referral letters to identify patients that might need to be fast tracked to the MND clinic '
    project = Project(name='mnd',
                      dataset=mnd_dataset,
                      description=mnd_desc,
                      labels=labels_added_mnd,
                      users=[user1, user2])
    db.session.add(project)

    allergies_desc = 'allergies project doing some annotation'
    project2 = Project(name='allergies project',
                       dataset=allergies_dataset,
                       description=allergies_desc,
                       labels=labels_added_allergies,
                       users=[user2])
    db.session.add(project2)

    db.session.commit()

    #   Associate Labels with Project
    db.session.execute(projectlabel_association.insert().values([
        (project.id, labels_added_mnd[0].id),
        (project.id, labels_added_mnd[1].id)
    ]))
Exemplo n.º 2
0
def save_project_info(session, proj_dict):
    ''' Save a dictionary of project info to the datastore session.

        Return an app.Project instance.
    '''
    # Select the current project, filtering on name AND organization.
    filter = Project.name == proj_dict[
        'name'], Project.organization_name == proj_dict['organization_name']
    existing_project = session.query(Project).filter(*filter).first()

    # If this is a new project, save and return it.
    if not existing_project:
        new_project = Project(**proj_dict)
        session.add(new_project)
        return new_project

    # Preserve the existing project
    # :::here (project/true)
    existing_project.keep = True

    # Update existing project details
    for (field, value) in proj_dict.items():
        setattr(existing_project, field, value)

    return existing_project
Exemplo n.º 3
0
def save_project_info(session, proj_dict):
    ''' Save a dictionary of project info to the datastore session.

        Return an app.Project instance.
    '''
    # Select the current project, filtering on name AND organization.
    filter = Project.name == proj_dict[
        'name'], Project.organization_name == proj_dict['organization_name']
    existing_project = session.query(Project).filter(*filter).first()

    # If this is a new project, save and return it.
    if not existing_project:
        new_project = Project(**proj_dict)
        session.add(new_project)
        return new_project

    # Mark the existing project for safekeeping.
    existing_project.keep = True

    # Update existing project details
    for (field, value) in proj_dict.items():
        setattr(existing_project, field, value)

    # Flush existing object, to prevent a sqlalchemy.orm.exc.StaleDataError.
    session.flush()

    return existing_project
Exemplo n.º 4
0
 def newProject(self):
     self.mainDialog.PreparedArea.clear()
     self.mainDialog.ThroughArea.clear()
     self.mainDialog.BacklightArea.clear()
     self.mainnodes = [Node("Samples"), Node("Other")]
     self.project_tree.setMainNodes(self.mainnodes)
     self.project = Project('TEMP')
     self.refresh()
Exemplo n.º 5
0
def test_one(client):
    q = db_session.query(Project).all()
    assert len(q) == 0

    project = Project(name='hey', evernote='google', description='potato')

    db_session.add(project)
    db_session.commit()

    q = db_session.query(Project).all()
    assert len(q) == 1
Exemplo n.º 6
0
def post_project():
    req_data = request.get_json()
    print(req_data)
    project = Project(req_data['title'], req_data['userId'],
                      req_data['description'], req_data['totalCost'],
                      req_data['totalTime'], req_data['auth0subject'])

    db.session.add(project)
    db.session.commit()
    result = project_schema.dump(project)
    print(result)
    return jsonify(result.data)
Exemplo n.º 7
0
def create_prject():
	args = request.get_json() if request.is_json else request.args
	is_present = Project.query.filter_by(title=args['title']).first()
	if is_present is None:
		owner = User.query.filter_by(id=args['participants'][0]).first()
		project = Project(
			title=args['title'], 
			description=args['description']
		)
		owner.projects.append(project)
		db.session.add_all([project, owner])
		db.session.commit()
	res = {
		'new entry?': is_present == None,
		'operation': 'create_prject',
		'args': args, 
		'Host': request.headers['Host'],
	}
	return jsonify(res)
Exemplo n.º 8
0
 def project_init(self):
     self.project = Project('New')
Exemplo n.º 9
0
    return data


if __name__ == '__main__':

    for org in get_orgs():
        print >> stderr, 'Found', org['name'], 'with projects at', org[
            'projects_url']

        got = get(org['projects_url'])
        data = list(DictReader(StringIO(got.text), dialect='excel-tab'))

        shuffle(data)

        for row in data:
            row = update_project_info(row)
            print row

            kwargs = dict(name=row.get('name', None),
                          code_url=row.get('code_url', None),
                          link_url=row.get('link_url', None),
                          description=row.get('description', None),
                          type=row.get('type', None),
                          category=row.get('category', None))

            project = Project(**kwargs)
            db.session.add(project)

    db.session.commit()
Exemplo n.º 10
0
from app import db, User, Project, Vote
# Create all the tables
db.create_all()

# create Projects
education = Project(name='Gift an education...Make a life !')
health = Project(name='Less Privileged Elders Need Care & Meal Support')

# add projects to session
db.session.add(education)
db.session.add(health)

# commit the projects to database
db.session.commit()

Exemplo n.º 11
0
from flask import Flask, request, send_file
from flask_cors import CORS
from app import Project
from json import dumps, loads
from bson.json_util import dumps as bsonDumps # to convert cursor object to json
from defaults import *
api = Flask(__name__)
CORS(api)
project = Project(uri="mongodb://*****:*****@api.route('/head')
def hello_world():
    return str(project.head())

@api.route('/plot')
def get_plot():
    bytes_obj = project.plot()
    return send_file(bytes_obj,
                     attachment_filename='plot.png',
                     mimetype='image/png')

# requests.get(url, params={'filter': json.dumps(filter), 'limit': json.dumps(limit)})
@api.route('/crud/find', methods=['GET'])
def find_from_db():
    args = request.args
    # j = loads(dumps(args))
    argsJSON = parseRequestArgs(findArgsJSON, args)
    print (argsJSON)
    cursor = project.find(**argsJSON)
    response_list = bsonDumps(cursor)
    # cursor = project.find(filter=argsJSON['filter'], limit=argsJSON['limit'])
Exemplo n.º 12
0
        projects = get_projects(organization['name'],
                                organization['projects_list_url'])

        for project in projects:

            # Mark this project for safe-keeping
            project['keep'] = True

            # Select the current project, filtering on name AND brigade
            # filter = Project.name == project['name'], Project.brigade == project['brigade']
            existing_project = db.session.query(Project).filter(
                Project.name == project['name'],
                Project.brigade == project['brigade']).first()

            # If this is a new project
            if not existing_project:
                project = Project(**project)
                db.session.add(project)
                continue

            # Update exisiting project details
            for (field, value) in project.items():
                setattr(existing_project, field, value)

            # Save each project to db
            db.session.commit()

    # Remove everything marked for deletion.
    db.session.execute(db.delete(Project).where(Project.keep == False))
    db.session.commit()
Exemplo n.º 13
0
        print 'Gathering all of ' + organization['name']+ "'s projects."

        projects = get_projects(organization['name'], organization['projects_list_url'])

        for project in projects:

            # Mark this project for safe-keeping
            project['keep'] = True

            # Select the current project, filtering on name AND brigade
            # filter = Project.name == project['name'], Project.brigade == project['brigade']
            existing_project = db.session.query(Project).filter(Project.name == project['name'], Project.brigade == project['brigade']).first()

            # If this is a new project
            if not existing_project:
                project = Project(**project)
                db.session.add(project)
                continue

            # Update exisiting project details
            for (field, value) in project.items():
                setattr(existing_project, field, value)

            # Save each project to db
            db.session.commit()

    # Remove everything marked for deletion.
    db.session.execute(db.delete(Project).where(Project.keep == False))
    db.session.commit()