Пример #1
0
def tool_control(request, tool_id=None):
	""" Presents the tool control view to the user, allowing them to being/end using a tool or see who else is using it. """
	if request.user.active_project_count() == 0:
		return render(request, 'no_project.html')
	# The tool-choice sidebar is not available for mobile devices, so redirect the user to choose a tool to view.
	if request.device == 'mobile' and tool_id is None:
		return redirect('choose_tool', next_page='tool_control')
	tools = Tool.objects.filter(visible=True).order_by('category', 'name')
	dictionary = {
		'tools': tools,
		'selected_tool': tool_id,
	}
	# The tool-choice sidebar only needs to be rendered for desktop devices, not mobile devices.
	if request.device == 'desktop':
		dictionary['rendered_tool_tree_html'] = ToolTree().render(None, {'tools': tools})
	return render(request, 'tool_control/tool_control.html', dictionary)
Пример #2
0
def calendar(request, tool_id=None):
    """ Present the calendar view to the user. """

    if request.device == 'mobile':
        if tool_id:
            return redirect('view_calendar', tool_id)
        else:
            return redirect('choose_tool', 'view_calendar')

    tools = Tool.objects.filter(visible=True).order_by('category', 'name')
    rendered_tool_tree_html = ToolTree().render(None, {'tools': tools})
    dictionary = {
        'rendered_tool_tree_html': rendered_tool_tree_html,
        'tools': tools,
        'auto_select_tool': tool_id,
    }
    if request.user.is_staff:
        dictionary['users'] = User.objects.all()
    return render(request, 'calendar/calendar.html', dictionary)