Example #1
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
Example #2
0
def close_request(request_id, reason = "", user_id = None):
	req = get_obj("Request", request_id)
	change_request_status(request_id, "Closed")
	# Create a note to capture closed information:
	create_note(request_id, reason, user_id)
	generate_prr_emails(request_id = request_id, notification_type = "Request closed")
	add_staff_participant(request_id = request_id, user_id = user_id)
Example #3
0
def show_request(request_id, template = "manage_request_public.html"):
	req = get_obj("Request", request_id)
	if not req:
		return render_template('error.html', message = "A request with ID %s does not exist." % request_id)
	if req.status and "Closed" in req.status and template != "manage_request_feedback.html":
		template = "closed.html"
	return render_template(template, req = req)
Example #4
0
def show_response(request_id):
    req = get_obj("Request", request_id)
    if not req:
        return render_template('error.html',
                               message="A request with ID %s does not exist." %
                               request_id)
    return render_template("response.html", req=req)
Example #5
0
 def __init__(self, request, qa=None, note=None, index=None, public=False):
     self.index = index
     self.public = public
     self.request = request
     if qa:
         self.response = qa
         self.type = "qa"
         self.uid = self.response.owner_id
         self.staff = get_obj("User", self.uid)
         self.staff_email = "N/A"
         self.staff_department = "N/A"
         self.staff_phone = "N/A"
         self.staff_alias = "N/A"
         if self.staff:
             if self.staff.email:
                 self.staff_email = self.staff.email
             if self.staff.department:
                 self.staff_department = self.staff.department
             if self.staff.phone:
                 self.staff_phone = self.staff.phone
             if self.staff.alias:
                 self.staff_alias = self.staff.alias
         directory_popover = "directoryPopover('%s', '%s', '%s', '#contactinfoPopoverQA%s')" % (
             self.staff_email, self.staff_department, self.staff_phone,
             index)
         self.owner_link = '<a href="/staff_card/%s" data-placement="top" data-toggle="popover" href="#" id="contactinfoPopoverQA%s" class="hidden-phone hidden-tablet"><span class="contactinfoPopover" onmouseover="%s">%s</span></a>' % (
             self.response.owner_id, index, directory_popover,
             self.staff_alias or self.staff_email)
         self.icon = "icon-question icon-large"
     if note:
         self.response = note
         self.type = "note"
         self.icon = "icon-edit icon-large"
	def __init__(self, request, qa = None, note = None, index = None, public = False):
		self.index = index
		self.public = public
		self.request = request
		if qa:
			self.response = qa
			self.type = "qa"
			self.uid = self.response.owner_id
			self.staff = get_obj("User", self.uid)
			self.staff_email = "N/A"
			self.staff_department = "N/A"
			self.staff_phone = "N/A"
			self.staff_alias = "N/A"
			if self.staff:
				if self.staff.email:
					self.staff_email = self.staff.email
				if self.staff.department_id:
					self.staff_department = self.staff.department_id
				if self.staff.phone:
					self.staff_phone = self.staff.phone
				if self.staff.alias:
					self.staff_alias = self.staff.alias
			directory_popover = "directoryPopover('%s', '%s', '%s', '#contactinfoPopoverQA%s')" %(self.staff_email, self.staff_department, self.staff_phone, index)
			self.owner_link = '<a href="/staff_card/%s" data-placement="top" data-toggle="popover" href="#" id="contactinfoPopoverQA%s" class="hidden-phone hidden-tablet"><span class="contactinfoPopover" onmouseover="%s">%s</span></a>' % (self.response.owner_id, index, directory_popover, self.staff_alias or self.staff_email)
			self.icon = "icon-question icon-large"
		if note:
			self.response = note
			self.type = "note"
			self.icon = "icon-edit icon-large"
Example #7
0
def show_request(request_id, template="manage_request_public.html"):
    req = get_obj("Request", request_id)
    if not req:
        return render_template('error.html',
                               message="A request with ID %s does not exist." %
                               request_id)
    if req.status and "Closed" in req.status and template != "manage_request_feedback.html":
        template = "closed.html"
    return render_template(template, req=req)
Example #8
0
def ask_a_question(request_id, user_id, question):
	""" City staff can ask a question about a request they are confused about."""
	req = get_obj("Request", request_id)
	qa_id = create_QA(request_id = request_id, question = question, user_id = user_id)
	if qa_id:
		change_request_status(request_id, "Pending")
		requester = req.requester()
		if requester:
			generate_prr_emails(request_id, notification_type = "Question asked", user_id = requester.user_id)
		add_staff_participant(request_id = request_id, user_id = user_id)
		return qa_id
	return False
Example #9
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
Example #10
0
def well_known_status():
	'''
	'''
	response = {
		'status': 'ok',
		'updated': int(time()),
		'dependencies': ['Akismet', 'Scribd', 'Sendgrid', 'Postgres'],
		'resources': {}
		}

	#
	# Try to connect to the database and get the first user.
	#
	try:
		if not get_obj('User', 1):
			raise Exception('Failed to get the first user')

	except Exception, e:
		response['status'] = 'Database fail: %s' % e
		return jsonify(response)
Example #11
0
def well_known_status():
    '''
	'''
    response = {
        'status': 'ok',
        'updated': int(time()),
        'dependencies': ['Akismet', 'Scribd', 'Sendgrid', 'Postgres'],
        'resources': {}
    }

    #
    # Try to connect to the database and get the first user.
    #
    try:
        if not get_obj('User', 1):
            raise Exception('Failed to get the first user')

    except Exception, e:
        response['status'] = 'Database fail: %s' % e
        return jsonify(response)
Example #12
0
def close_request_spam(user_id, request_id, reason = "This is spam"):
	req = get_obj("Request", request_id)
	change_request_status(request_id, "Closed")
	# Create a note to capture closed information:
	create_note(request_id, reason, user_id)
	add_staff_participant(request_id = request_id, user_id = user_id)
Example #13
0
def edit_case(request_id):
	req = get_obj("Request", request_id)
	return render_template("edit_case.html", req = req)
Example #14
0
def show_response(request_id):
	req = get_obj("Request", request_id)
	if not req:
		return render_template('error.html', message = "A request with ID %s does not exist." % request_id)
	return render_template("response.html", req = req)
Example #15
0
def edit_case(request_id):
    req = get_obj("Request", request_id)
    return render_template("edit_case.html", req=req)