def pin_variant(institute_id, case_name, variant_id): """Pin and unpin variants to/from the list of suspects.""" institute_obj, case_obj = institute_and_case(store, institute_id, case_name) variant_obj = store.variant(variant_id) user_obj = store.user(current_user.email) link = url_for('variants.variant', institute_id=institute_id, case_name=case_name, variant_id=variant_id) if request.form['action'] == 'ADD': store.pin_variant(institute_obj, case_obj, user_obj, link, variant_obj) elif request.form['action'] == 'DELETE': store.unpin_variant(institute_obj, case_obj, user_obj, link, variant_obj) return redirect(request.referrer or link)