def assign(institute_id, case_name, user_id=None): """Assign and unassign a user from a case.""" institute_obj, case_obj = institute_and_case(store, institute_id, case_name) link = url_for('.case', institute_id=institute_id, case_name=case_name) if user_id: user_obj = store.user(user_id) else: user_obj = store.user(current_user.email) if request.form.get('action') == 'DELETE': store.unassign(institute_obj, case_obj, user_obj, link) else: store.assign(institute_obj, case_obj, user_obj, link) return redirect(request.referrer)
def assign(institute_id, case_name, user_id=None, inactivate=False): """Assign and unassign a user from a case.""" institute_obj, case_obj = institute_and_case(store, institute_id, case_name) link = url_for(".case", institute_id=institute_id, case_name=case_name) if user_id: user_obj = store.user(user_id) else: user_obj = store.user(current_user.email) if request.form.get("action") == "DELETE": store.unassign(institute_obj, case_obj, user_obj, link, inactivate) else: store.assign(institute_obj, case_obj, user_obj, link) return redirect(request.referrer)
def test_events_timeline(app, user_obj, institute_obj, case_obj): """Test the wiew that returns the last 100 groups of events for a user""" # GIVEN an initialized app with app.test_client() as client: # GIVEN that the user could be logged in client.get(url_for("auto_login")) # GIVEN one user event present in the database store.assign(institute=institute_obj, case=case_obj, user=user_obj, link="test_link") assert store.event_collection.find_one() resp = client.get(url_for("overview.timeline", )) # THEN the page should not return error assert resp.status_code == 200 # AND the event should be displayed on the timeline page assert "assigned" in str(resp.data)