Ejemplo n.º 1
0
def update_resource(resource, request_body):
    fields = request_body
    if "owner" in resource:
        if "reason_unassigned" in fields:
            return remove_staff_participant(owner_id=fields['owner_id'],
                                            reason=fields['reason_unassigned'])
        else:
            change_request_status(int(fields['request_id']), "Rerouted")
            return assign_owner(int(fields['request_id']),
                                fields['owner_reason'], fields['owner_email'])
    elif "reopen" in resource:
        change_request_status(int(fields['request_id']), "Reopened")
        return fields['request_id']
    elif "request_text" in resource:
        update_obj(attribute="text",
                   val=fields['request_text'],
                   obj_type="Request",
                   obj_id=fields['request_id'])
    elif "note_text" in resource:
        update_obj(attribute="text",
                   val=fields['note_text'],
                   obj_type="Note",
                   obj_id=fields['response_id'])
        # Need to store note text somewhere else (or just do delete here as well)
    elif "note_delete" in resource:
        # Need to store note somewhere else
        remove_obj("Note", int(fields['response_id']))
    elif "record_delete" in resource:
        remove_obj("Record", int(fields['record_id']))
        # Need to store record somewhere else and prompt them to delete from Scribd as well, if they'd like
    else:
        return False
Ejemplo n.º 2
0
def assign_owner(request_id, reason, email=None):
    """ Called any time a new owner is assigned. This will overwrite the current owner."""
    req = get_obj("Request", request_id)
    past_owner_id = None
    # If there is already an owner, unassign them:
    if req.point_person():
        past_owner_id = req.point_person().id
        past_owner = get_obj("Owner", req.point_person().id)
        update_obj(attribute="is_point_person", val=False, obj=past_owner)
    owner_id, is_new_owner = add_staff_participant(request_id=request_id,
                                                   reason=reason,
                                                   email=email,
                                                   is_point_person=True)
    if (past_owner_id == owner_id
        ):  # Already the current owner, so don't send any e-mails
        return owner_id

    app.logger.info("\n\nA new owner has been assigned: Owner: %s" % owner_id)
    new_owner = get_obj("Owner", owner_id)
    # Update the associated department on request
    update_obj(attribute="department_id",
               val=new_owner.user.department,
               obj=req)
    user_id = get_attribute(attribute="user_id",
                            obj_id=owner_id,
                            obj_type="Owner")
    # Send notifications
    if is_new_owner:
        generate_prr_emails(request_id=request_id,
                            notification_type="Request assigned",
                            user_id=user_id)
    return owner_id
Ejemplo n.º 3
0
def update_resource(resource, request_body):
	fields = request_body
	if "owner" in resource:
		if "reason_unassigned" in fields:
			return remove_staff_participant(owner_id = fields['owner_id'], reason = fields['reason_unassigned'])
		else:
			change_request_status(int(fields['request_id']), "Rerouted")
			return assign_owner(int(fields['request_id']), fields['owner_reason'], fields['owner_email'])
	elif "reopen" in resource:
		change_request_status(int(fields['request_id']), "Reopened")
		return fields['request_id']
	elif "request_text" in resource:
		update_obj(attribute = "text", val = fields['request_text'], obj_type = "Request", obj_id = fields['request_id'])
	elif "note_text" in resource:
		update_obj(attribute = "text", val = fields['note_text'], obj_type = "Note", obj_id = fields['response_id'])
	elif "note_delete" in resource:
		remove_obj("Note", int(fields['response_id']))
	elif "record_delete" in resource:
		remove_obj("Record", int(fields['record_id']))
	else:
		return False
Ejemplo n.º 4
0
def assign_owner(request_id, reason, email = None):
	""" Called any time a new owner is assigned. This will overwrite the current owner."""
	req = get_obj("Request", request_id)
	past_owner_id = None
	# If there is already an owner, unassign them:
	if req.point_person():
		past_owner_id = req.point_person().id
		past_owner = get_obj("Owner", req.point_person().id)
		update_obj(attribute = "is_point_person", val = False, obj = past_owner)
	owner_id, is_new_owner = add_staff_participant(request_id = request_id, reason = reason, email = email, is_point_person = True)
	if (past_owner_id == owner_id): # Already the current owner, so don't send any e-mails
		return owner_id

	app.logger.info("\n\nA new owner has been assigned: Owner: %s" % owner_id)
	new_owner = get_obj("Owner", owner_id)
	# Update the associated department on request
	update_obj(attribute = "department_id", val = new_owner.user.department_id, obj = req)
	user_id = get_attribute(attribute = "user_id", obj_id = owner_id, obj_type = "Owner")
	# Send notifications
	if is_new_owner:
		generate_prr_emails(request_id = request_id, notification_type = "Request assigned", user_id = user_id)
	return owner_id
Ejemplo n.º 5
0
def update_resource(resource, request_body):
	fields = request_body
	if "owner" in resource:
		if "reason_unassigned" in fields:
			return remove_staff_participant(owner_id = fields['owner_id'], reason = fields['reason_unassigned'])
		else:
			change_request_status(int(fields['request_id']), "Rerouted")
			return assign_owner(int(fields['request_id']), fields['owner_reason'], fields['owner_email'])
	elif "reopen" in resource:
		change_request_status(int(fields['request_id']), "Reopened")
		return fields['request_id']
	elif "request_text" in resource:
		update_obj(attribute = "text", val = fields['request_text'], obj_type = "Request", obj_id = fields['request_id'])
	elif "note_text" in resource:
		update_obj(attribute = "text", val = fields['note_text'], obj_type = "Note", obj_id = fields['response_id'])
		# Need to store note text somewhere else (or just do delete here as well)
	elif "note_delete" in resource:
		# Need to store note somewhere else
		remove_obj("Note", int(fields['response_id']))
	elif "record_delete" in resource:
		remove_obj("Record", int(fields['record_id']))
		# Need to store record somewhere else and prompt them to delete from Scribd as well, if they'd like
	else:
		return False