def edit_task(project, id): project = helpers.require_project(project) task = Task.get(project.id, str(id)) input = helpers.get_input() # sprint = Sprint.get(project, input['sprint_id']) data = { # 'sprint_id': sprint.id, # 'swimlane_id': input['swimlane_id'], 'state': input['state'], 'name': input['name'], 'description': input['description'] if input['description'] != '' else None, 'planned_points': input['planned_points'], 'points': input['points'], 'assigned_members': set(input['assigned_members']) & project.all_members() } for k, v in data.items(): setattr(task, k, v) task.save() return jsonify(dict(task))
def new_task(project): project = helpers.require_project(project) input = helpers.get_input() sprint = Sprint.get(project.id, input['sprint_id']) id = str(uuid.uuid4()) data = { 'sprint_id': sprint.id, 'swimlane_id': input['swimlane_id'], 'state': input['state'], 'name': input['name'], 'description': input['description'] if input['description'] != '' else None, 'planned_points': input['planned_points'], 'points': input['points'], 'assigned_members': set(input['assigned_members']) & project.all_members() } task = Task(project.id, id, **data) task.save() return jsonify(dict(task))
def edit_project(id): project = helpers.require_project(id) id = str(id) input = helpers.get_input() members = set(input['members']) name = input['name'] old_members = set(project.members) if project.members is not None else set() removed_members = old_members - members added_members = members - old_members existing = set() for member in User.batch_get(removed_members | added_members): existing.add(member.email) if member in removed_members: member.update(actions=[ User.projects.delete({id}) ]) else: member.update(actions=[ User.projects.add({id}) ]) with User.batch_write() as batch: for member in added_members - existing: batch.save(User(member, projects=[id])) project.name = name project.members = members project.save() return jsonify(dict(project))
def create_project(): input = helpers.get_input() id = str(uuid.uuid4()) members = set(input['members']) owner = helpers.get_user_email() name = input['name'] all_members = members | {owner} existing = set() for member in User.batch_get(all_members): existing.add(member.email) member.update(actions=[ User.projects.add({id}) ]) with User.batch_write() as batch: for member in all_members - existing: batch.save(User(member, projects=[id])) project = Project(id, name=name, members=members, owner=owner) project.save() return jsonify(dict(project))
def edit_task_points(project, id): project = helpers.require_project(project) task = Task.get(project.id, str(id)) # points input = helpers.get_input() task.points = input['points'] task.save() return jsonify(dict(task))
def new_sprint(project): project = helpers.require_project(project) input = helpers.get_input() id = str(uuid.uuid4()) start_date = datetime.datetime.strptime(input['start_date'], '%Y-%m-%d') end_date = datetime.datetime.strptime(input['end_date'], '%Y-%m-%d') name = input['name'] sprint = Sprint(project.id, id, start_date=start_date, end_date=end_date, name=name) sprint.save() return jsonify(dict(sprint))
def edit_sprint(project, id): project = helpers.require_project(project) sprint = Sprint.get(project.id, str(id)) input = helpers.get_input() start_date = datetime.datetime.strptime(input['start_date'], '%Y-%m-%d') end_date = datetime.datetime.strptime(input['end_date'], '%Y-%m-%d') name = input['name'] sprint.name = name sprint.start_date = start_date sprint.end_date = end_date sprint.save() return jsonify(dict(sprint))
def edit_swimlane(project, sprint, id): project = helpers.require_project(project) sprint = Sprint.get(project.id, str(sprint)) id = str(id) input = helpers.get_input() swimlanes = sprint.swimlanes if sprint.swimlanes is not None else [] swimlane = next(x for x in swimlanes if x.id == id) description = input['description'] if input['description'] != '' else None name = input['name'] points = input['points'] swimlane.description = description swimlane.name = name swimlane.points = points sprint.swimlanes = swimlanes sprint.save() return jsonify(dict(swimlane.output_dict(sprint)))
def edit_task_position(project, id): project = helpers.require_project(project) task = Task.get(project.id, str(id)) # state, swimlane_id, input = helpers.get_input() task.swimlane_id = input['swimlane_id'] # assign member when moving from new to any other state and there are no assigned members if task.state == 'new' and input[ 'state'] != 'new' and not task.assigned_members: task.assigned_members = {helpers.get_user_email()} # clear points if moving to done if input['state'] == 'done': task.points = 0 task.state = input['state'] task.save() return jsonify(dict(task))
def new_swimlane(project, sprint): project = helpers.require_project(project) sprint = Sprint.get(project.id, str(sprint)) input = helpers.get_input() swimlanes = sprint.swimlanes if sprint.swimlanes is not None else [] id = str(uuid.uuid4()) description = input['description'] if input['description'] != '' else None name = input['name'] points = input['points'] swimlane = Swimlane(id=id, description=description, name=name, points=points) print(swimlane.description) swimlanes.append(swimlane) sprint.swimlanes = swimlanes sprint.save() return jsonify(dict(swimlane.output_dict(sprint)))