def index(request): """ The main index of Teamwork, referred to as "Home" in the sidebar. Accessible to public and logged in users. """ # TODO: get feed of project updates (or public projects) to display on login # Populate with defaults for not logged in user page_name = "Grepthink" page_description = "Build Better Teams" title = "Welcome" date_updates = None logged_in = request.user.is_authenticated() if not logged_in: return render( request, 'core/landing.html', { 'page_name': page_name, 'page_description': page_description, 'title': title }) # If the user is a professor, return the dashboard html if logged_in and request.user.profile.isProf: page_name = "Dashboard" page_description = "Instructor Control Panel" title = "Dashboard" active_courses = get_user_active_courses(request.user) disabled_courses = get_user_disabled_courses(request.user) return render( request, 'core/dashboard.html', { 'page_name': page_name, 'page_description': page_description, 'title': title, 'active_courses': active_courses, 'disabled_courses': disabled_courses }) if logged_in: page_name = "Timeline" page_description = "Recent Updates from Courses and Projects" title = "Timeline" all_courses = get_user_active_courses(request.user) date_updates = [] for course in all_courses: course_updates = course.get_updates_by_date() date_updates.extend(course.get_updates_by_date()) return render( request, 'core/index.html', { 'page_name': page_name, 'page_description': page_description, 'title': title, 'date_updates': date_updates, 'logged_in': logged_in })
def view_matches(request): """Generic view for serving a list of projects and potential teammate matches for each project.""" project_match_list = [] course_set = [] page_name = "View Matches" page_description = "View Matching Students" title = "View Matches" if request.user.profile.isProf: courses = get_user_active_courses(request.user) for course in courses: for project in course.projects.all(): p_match = po_match(project) project_match_list.extend([(course, project, p_match)]) course_set.append(course) else: my_projects = Project.get_my_active_projects(request.user) for project in my_projects: p_match = po_match(project) project_match_list.extend([(project, p_match)]) if request.POST.get('matchstats'): matches = request.POST.get('matchstats') return render( request, 'core/view_matches.html', { 'project_match_list': project_match_list, 'course_set': course_set, 'page_name': page_name, 'page_description': page_description, 'title': title })
def render_dashboard(request): """Render Professor Dashboard. Args: request (requests.request): Page request. Returns: django.shortcuts.render: Page render. """ page_name = "Dashboard" page_description = "Instructor Control Panel" title = "Dashboard" active_courses = get_user_active_courses(request.user) disabled_courses = get_user_disabled_courses(request.user) return render(request, 'core/dashboard.html', { 'page_name' : page_name, 'page_description' : page_description, 'title' : title, 'active_courses' : active_courses, 'disabled_courses': disabled_courses })
def render_timeline(request): """Render student timeline. Args: request (requests.request): Page request. Returns: django.shortcuts.render: Page render. """ page_name = "Timeline" page_description = "Recent Updates from Courses and Projects" title = "Timeline" all_courses = get_user_active_courses(request.user) date_updates = [] for course in all_courses: date_updates.extend(course.get_updates_by_date()) return render(request, 'core/index.html', { 'page_name' : page_name, 'page_description' : page_description, 'title' : title, 'date_updates' : date_updates, 'logged_in' : True })
def view_courses(request): """ Public method that takes a request, retrieves all course objects associated with request.user """ return _courses(request, get_user_active_courses(request.user))