def rescan_users(): """ This task goes through all users on JIRA and ensures that they are assigned to the correct group based on the user's email address. It's meant to be run regularly: once an hour or so. """ # a mapping of group name to email domain domain_groups = { "edx-employees": "@edx.org", "qualcomm": ".qualcomm.com", "ubc": "@cs.ubc.ca", "ubc": "@ubc.ca", } if request.method == "GET": return render_template("jira_rescan_users.html", domain_groups=domain_groups) requested_group = request.form.get("group") if requested_group: if requested_group not in domain_groups: resp = jsonify({"error": "Not found", "groups": domain_groups.keys()}) resp.status_code = 404 return resp requested_groups = {requested_group: domain_groups[requested_group]} else: requested_groups = domain_groups result = rescan_user_task.delay(requested_groups) status_url = url_for("tasks.status", task_id=result.id, _external=True) resp = jsonify({"message": "queued", "status_url": status_url}) resp.status_code = 202 resp.headers["Location"] = status_url return resp
def rescan_users(): """ This task goes through all users on JIRA and ensures that they are assigned to the correct group based on the user's email address. It's meant to be run regularly: once an hour or so. """ requested_group = request.form.get("group") if requested_group: if requested_group not in domain_groups: resp = jsonify({ "error": "Not found", "groups": domain_groups.keys() }) resp.status_code = 404 return resp requested_groups = {requested_group: domain_groups[requested_group]} else: requested_groups = domain_groups result = rescan_user_task.delay(requested_groups) status_url = url_for("tasks.status", task_id=result.id, _external=True) resp = jsonify({"message": "queued", "status_url": status_url}) resp.status_code = 202 resp.headers["Location"] = status_url return resp
def rescan_users(): """ This task goes through all users on JIRA and ensures that they are assigned to the correct group based on the user's email address. It's meant to be run regularly: once an hour or so. """ requested_group = request.form.get("group") if requested_group: if requested_group not in domain_groups: resp = jsonify({"error": "Not found", "groups": domain_groups.keys()}) resp.status_code = 404 return resp requested_groups = {requested_group: domain_groups[requested_group]} else: requested_groups = domain_groups result = rescan_user_task.delay(requested_groups) status_url = url_for("tasks.status", task_id=result.id, _external=True) resp = jsonify({"message": "queued", "status_url": status_url}) resp.status_code = 202 resp.headers["Location"] = status_url return resp