def get(self, request, category_name, page_number=None): category = HelpCategory.objects.get(name=category_name) if request.user.is_authenticated: group_names = get_group_names(request.user) else: group_names = None if not page_number: context = {'page_file_name': 'help/' + category_name + '.html', 'category': category_name, 'previous': None, 'next': None, 'group_names': group_names, 'critiques': get_critiques(request.path_info), 'tester': is_tester(request.user)} else: help_page = HelpPage.objects.get(category=category, number=page_number) page_count = len(HelpPage.objects.filter(category=category)) page_number = help_page.number previous_page_num = page_number - 1 if previous_page_num <= 0: previous = None else: previous = previous_page_num next_page_num = page_number + 1 if next_page_num > page_count: next_page = None else: next_page = next_page_num context = {'page_file_name': 'help/' + help_page.name + '.html', 'category': category_name, 'previous': previous, 'next': next_page, 'group_names': group_names, 'critiques': get_critiques(request.path_info), 'tester': is_tester(request.user)} return render(request, self.template_name, context)
def get(self, request): if request.user.is_authenticated: group_names = get_group_names(request.user) else: group_names = None if 'Administrator' in group_names or 'Supervisor' in group_names: supervisors = Group.objects.get( name="Supervisor").user_set.all().order_by('last_name') team_members = Group.objects.get( name="Team").user_set.all().order_by('last_name') candidates = Group.objects.get( name="Candidate").user_set.all().order_by('last_name') testers = Group.objects.get( name="Tester").user_set.all().order_by('last_name') context = { 'group_names': group_names, 'supervisors': supervisors, 'team_members': team_members, 'candidates': candidates, 'testers': testers, 'critiques': get_critiques(request.path_info), 'tester': is_tester(request.user) } return render(request, self.template_name, context) else: raise PermissionDenied
def get(self, request, activity_slug, page_index): activity, page, responses, context = get_response_info(request.user, activity_slug, page_index) if not page.allowed(request.user, activity_slug, page_index): return redirect('summary', activity_slug) page_type = page.page_type reports = [] if page_type == 'IN': self.template_name = 'activity/instruction.html' reports = get_instruction_report(activity, page, request.user) elif page_type == 'ES': self.template_name = 'activity/essay.html' reports = get_essay_report(activity, page, request.user) elif page_type == 'MC': self.template_name = 'activity/multi-choice.html' choices = Choice.objects.filter(page=page) context['choices'] = choices reports = get_multi_choice_report(activity, page, request.user, choices) elif page_type == 'TF': self.template_name = 'activity/true-false.html' reports = get_true_false_report(activity, page, request.user) elif page_type == 'DS': return redirect('discussion', activity_slug, page_index) context['critiques'] = get_critiques(request.path_info) context['tester'] = is_tester(request.user) context['reports'] = reports context['page_type'] = page.page_type return render(request, self.template_name, context)
def get(self, request): activities = Activity.objects.filter(publish_date__lte=datetime.date.today(), closing_date__gt=datetime.date.today(), visible=True) data = [] for activity in activities: pages = Page.objects.filter(activity=activity) page_count = len(pages) completed = len(Response.objects.filter(user=request.user, activity=activity, completed=True)) if page_count != 0: percent_completed = completed/page_count * 100 if percent_completed < 100: msg = '{:.1f}'.format(percent_completed) + '% Complete' else: msg = 'Finished!' else: msg = 'Not Yet Available' data.append((activity, msg)) group_names = get_group_names(request.user) # set 'critiques_visible' to true if it is not set try: test = request.session['critiques_visible'] except KeyError: request.session['critiques_visible'] = True return render(request, self.template_name, {'data': data, 'group_names': group_names, 'critiques': get_critiques(request.path_info), 'tester': is_tester(request.user), 'reports': get_welcome_report(request.user)})
def get(self, request, activity_slug=None, page_index=None): activity, page, user_responses, context = get_response_info( request.user, activity_slug, page_index) if not page.allowed(request.user, activity_slug, page_index): return redirect('summary', activity_slug) context['responses'] = Response.objects.filter( activity=activity, page=page) # get all the page's responses context['critiques'] = get_critiques(request.path_info) context['tester'] = is_tester(request.user) return render(request, self.template_name, context)
def get(self, request, pk=None): page_url = request.META['QUERY_STRING'].replace( 'next=', '') # the page from which this came critique = Critique.objects.get(pk=pk) context = { 'page_url': page_url, 'critique': critique, 'critiques': get_critiques(request.path_info), 'tester': is_tester(request.user) } return render(request, self.template_name, context)
def get(self, request, activity_slug=None, page_index=None, response_pk=None): activity, page, responses, context = get_response_info( request.user, activity_slug, page_index) response = Response.objects.get(pk=response_pk) context['response'] = response context['critiques'] = get_critiques(request.path_info), context['tester'] = is_tester(request.user) return render(request, 'discussion/discussion_edit.html', context)
def get(self, request): group_names = get_group_names(request.user) if 'Administrator' in group_names or 'Supervisor' in group_names or 'Team' in group_names: dev_activities = DevelopingActivity.objects.all() return render( request, self.template_name, { 'group_names': group_names, 'dev_activities': dev_activities, 'critiques': get_critiques(request.path_info), 'tester': is_tester(request.user) }) else: raise PermissionDenied
def get(self, request, activity_slug): activity = Activity.objects.get(slug=activity_slug) pages = Page.objects.filter(activity=activity.pk) responses = Response.objects.filter(user=request.user, activity=activity.pk) data = [] first_pass = True # this changes as soon as an incomplete page is found for page in pages: if responses.filter(page=page.pk) and first_pass: data.append((page, 'Completed')) # If user has a response, call the page complete elif first_pass: data.append((page, 'Up next...')) # This is the next page to do first_pass = False # after that, enter 'Pending' for the rest of the pages else: data.append((page, 'Pending')) group_names = get_group_names(request.user) return render(request, self.template_name, {'activity': activity, 'data': data, 'group_names': group_names, 'critiques': get_critiques(request.path_info), 'tester': is_tester(request.user), 'reports': get_summary_report(activity, request.user)})
def get(self, request, activity_slug=None, page_index=None): activity, page, responses, context = get_response_info(request.user, activity_slug, page_index) if page.page_type == 'IN': return redirect('page', activity_slug, page_index) elif page.page_type == 'ES': self.template_name = 'activity/essay_edit.html' elif page.page_type == 'MC': if page.reveal_answer: # They can't edit it if the answer has been revealed return redirect('page', activity_slug, page_index) else: self.template_name = 'activity/multi-choice-edit.html' choices = Choice.objects.filter(page=page) context['choices'] = choices elif page.page_type == 'TF': if not page.reveal_answer: # They can't edit it if the answer has been revealed response = context['response'] response.true_false = not response.true_false response.save() return redirect('page', activity_slug, page_index) context['critiques'] = get_critiques(request.path_info), context['tester'] = is_tester(request.user) return render(request, self.template_name, context)
def get(self, request): return render(request, self.template_name, {'group_names': get_group_names(request.user), 'critiques': get_critiques(request.path_info), 'tester': is_tester(request.user)})