Example #1
0
def requests():
    try:
        # Return first 100, ? limit = 100
        departments_json = open(os.path.join(app.root_path, "static/json/list_of_departments.json"))
        list_of_departments = json.load(departments_json)
        departments = sorted(list_of_departments, key=unicode.lower)
        my_requests = False
        requester_name = ""
        dept_selected = "All departments"
        open_requests = True
        if request.method == "GET":
            filters = request.args.copy()
            if not filters:
                if not current_user.is_anonymous():
                    my_requests = True
                    filters["owner"] = current_user.id
                filters["status"] = "open"
            else:
                if "department" in filters and filters["department"].lower() == "all":
                    del filters["department"]
                if not ("status" in filters and filters["status"].lower() == "open"):
                    open_requests = False
                if "department" in filters:
                    dept_selected = filters["department"]
                    # 	if dept_selected != "All departments":
                    # 		filters['department'] = request.args['department_filter']
                if "owner" in filters and not current_user.is_anonymous():
                    my_requests = True
                if "requester" in filters and current_user.is_anonymous():
                    del filters["requester"]
        record_requests = get_request_table_data(get_requests_by_filters(filters))
        user_id = get_user_id()
        if record_requests:
            template = "all_requests.html"
            if user_id:
                template = "all_requests_city.html"
        else:
            template = "all_requests_noresults.html"
        total_requests_count = get_count("Request")
        return render_template(
            template,
            record_requests=record_requests,
            user_id=user_id,
            title="All Requests",
            open_requests=open_requests,
            departments=departments,
            dept_selected=dept_selected,
            my_requests=my_requests,
            total_requests_count=total_requests_count,
            requester_name=requester_name,
        )
    except Exception, message:
        if "Too long" in message:
            message = "Loading requests is taking a while. Try exploring with more restricted search options."
            print message
        return render_template("error.html", message=message, user_id=get_user_id())
def requests():
	# Return first 100, ? limit = 100
	departments_json = open(os.path.join(app.root_path, 'static/json/list_of_departments.json'))
	list_of_departments = json.load(departments_json)
	departments = sorted(list_of_departments, key=unicode.lower)
	filters = {}
	open_requests = False
	my_requests = False
	requester_name = ""
	dept_selected = "All departments"
	if request.method == 'POST':
		if 'status_filter' in request.form:
			filters['status'] = 'open'
			open_requests = True
		if 'department_filter' in request.form and request.form['department_filter'] != '&nbsp':
			dept_selected = request.form['department_filter']
			if dept_selected != "All departments":
				filters['department'] = request.form['department_filter']
		if 'owner_requests' in request.form and current_user.is_anonymous() == False:
			my_requests = True
			filters['owner'] = current_user.id
		if 'requester' in request.form and current_user.is_anonymous() == False:
			requester_name = request.form['requester']
			filters['requester'] = requester_name
	else:
		# Set defaults for logged in user:
		if current_user.is_anonymous() == False:
			my_requests = True
			open_requests = True
			filters['owner'] = current_user.id
			filters['status'] = 'open'
		else:
			if 'requester' not in request.args:
				filters = request.args
	record_requests = get_request_table_data(get_requests_by_filters(filters))
	user_id = get_user_id()
	if record_requests:
		template = 'all_requests.html'
		if user_id: 
			template = 'all_requests_city.html'
	else:
		template = "all_requests_noresults.html"
	total_requests_count = get_count("Request")
	return render_template(template, record_requests = record_requests, user_id = user_id, title = "All Requests", open_requests = open_requests, departments = departments, dept_selected = dept_selected, my_requests = my_requests, total_requests_count = total_requests_count, requester_name = requester_name)
def requests():
	# Return first 100, ? limit = 100
	# Taken from list_of_departments.json:
	departments = sorted(["Human Resources", "Council District 7 - Larry Reid", "Department of Planning and Building", "Council District 5 - Noel Gallo", "Council District 3 - Lynette Gibson McElhaney", "City Clerk", "Council District 6 - Desley Brooks", "Health and Human Services", "Fire Department", "Budget and Revenue - Revenue Division", "Office of Controller and Treasury", "Information Technology (IT)", "City Attorney", "Council District 2 - Pat Kernighan", "Parks and Recreation", "City Auditor", "Council District 1 - Dan Kalb", "Office of the Mayor", "Council District 4 - Libby Schaaf", "Council At Large - Rebecca Kaplan", "Library Services", "Public Works Agency", "Contracts and Compliance", "City Administrator", "Office of Neighborhood Investment"], key=str.lower)
	filters = {}
	open_requests = False
	my_requests = False
	requester_name = ""
	dept_selected = "All departments"
	if request.method == 'POST':
		if 'status_filter' in request.form:
			filters['status'] = 'open'
			open_requests = True
		if 'department_filter' in request.form and request.form['department_filter'] != '&nbsp':
			dept_selected = request.form['department_filter']
			if dept_selected != "All departments":
				filters['department'] = request.form['department_filter']
		if 'owner_requests' in request.form and current_user.is_anonymous() == False:
			my_requests = True
			filters['owner'] = current_user.id
		if 'requester' in request.form and current_user.is_anonymous() == False:
			requester_name = request.form['requester']
			filters['requester'] = requester_name
	else:
		# Set defaults for logged in user:
		if current_user.is_anonymous() == False:
			my_requests = True
			open_requests = True
			filters['owner'] = current_user.id
			filters['status'] = 'open'
		else:
			if 'requester' not in request.args:
				filters = request.args
	record_requests = get_request_table_data(get_requests_by_filters(filters))
	user_id = get_user_id()
	if record_requests:
		template = 'all_requests.html'
		if user_id: 
			template = 'all_requests_city.html'
	else:
		template = "all_requests_noresults.html"
	total_requests_count = get_count("Request")
	return render_template(template, record_requests = record_requests, user_id = user_id, title = "All Requests", open_requests = open_requests, departments = departments, dept_selected = dept_selected, my_requests = my_requests, total_requests_count = total_requests_count, requester_name = requester_name)
def requests():
	# Return first 100, ? limit = 100
	departments_json = open(os.path.join(app.root_path, 'static/json/list_of_departments.json'))
	list_of_departments = json.load(departments_json)
	departments = sorted(list_of_departments, key=unicode.lower)
	filters = {}
	open_requests = False
	my_requests = False
	requester_name = ""
	dept_selected = "All departments"
	if request.method == 'GET':
		filters = request.args.copy()
		if not filters:
			if not current_user.is_anonymous():
				my_requests = True
				filters['owner'] = current_user.id
				open_requests = True
				filters['status'] = 'open'
		else:
			if 'department' in filters and filters['department'].lower() == 'all':
				del filters['department']
			if 'status' in filters and filters['status'].lower() == 'open':
				open_requests = True
			if 'department' in filters:
				dept_selected = filters['department']
			# 	if dept_selected != "All departments":
			# 		filters['department'] = request.args['department_filter']
			if 'owner' in filters and not current_user.is_anonymous():
				my_requests = True
			if 'requester' in filters and current_user.is_anonymous():
				del filters['requester']
	record_requests = get_request_table_data(get_requests_by_filters(filters))
	user_id = get_user_id()
	if record_requests:
		template = 'all_requests.html'
		if user_id: 
			template = 'all_requests_city.html'
	else:
		template = "all_requests_noresults.html"
	total_requests_count = get_count("Request")
	return render_template(template, record_requests = record_requests, user_id = user_id, title = "All Requests", open_requests = open_requests, departments = departments, dept_selected = dept_selected, my_requests = my_requests, total_requests_count = total_requests_count, requester_name = requester_name)
Example #5
0
def requests():
    try:
        # Return first 100, ? limit = 100
        departments_json = open(
            os.path.join(app.root_path,
                         'static/json/list_of_departments.json'))
        list_of_departments = json.load(departments_json)
        departments = sorted(list_of_departments, key=unicode.lower)
        my_requests = False
        requester_name = ""
        dept_selected = "All departments"
        open_requests = True
        if request.method == 'GET':
            filters = request.args.copy()
            if not filters:
                if not current_user.is_anonymous():
                    my_requests = True
                    filters['owner'] = current_user.id
                filters['status'] = 'open'
            else:
                if 'department' in filters and filters['department'].lower(
                ) == 'all':
                    del filters['department']
                if not ('status' in filters
                        and filters['status'].lower() == 'open'):
                    open_requests = False
                if 'department' in filters:
                    dept_selected = filters['department']
                # 	if dept_selected != "All departments":
                # 		filters['department'] = request.args['department_filter']
                if 'owner' in filters and not current_user.is_anonymous():
                    my_requests = True
                if 'requester' in filters and current_user.is_anonymous():
                    del filters['requester']
        record_requests = get_request_table_data(
            get_requests_by_filters(filters))
        user_id = get_user_id()
        if record_requests:
            template = 'all_requests.html'
            if user_id:
                template = 'all_requests_city.html'
        else:
            template = "all_requests_noresults.html"
        total_requests_count = get_count("Request")
        return render_template(template,
                               record_requests=record_requests,
                               user_id=user_id,
                               title="All Requests",
                               open_requests=open_requests,
                               departments=departments,
                               dept_selected=dept_selected,
                               my_requests=my_requests,
                               total_requests_count=total_requests_count,
                               requester_name=requester_name)
    except Exception, message:
        if "Too long" in message:
            message = "Loading requests is taking a while. Try exploring with more restricted search options."
            print message
        return render_template('error.html',
                               message=message,
                               user_id=get_user_id())