def get(self, request): """ returns add result form """ context = get_base_context(request) context["tags"] = get_all_tags() return render(request, 'result/add_result.html', context)
def get(self, request): """ returns add news form """ context = get_base_context(request) #tags used for the autocomplete feature of the tag input context["tags"] = get_all_tags() return render(request, 'news_event/add-news.html', context)
def get(self, request): """ returns add news form """ context = get_base_context(request) #tags used for the autocomplete feature of the tag input context["tags"] = get_all_tags() return render(request, 'news_event/add-news.html', context)
def post(self, request): context = get_base_context(request) response = functions.add_schedule(request) if response["result"] == 1: return redirect('/schedule/') else: context["tags"] = get_all_tags() print response["error"] return render(request, 'schedule/add_schedule.html', context)
def get(self, request): """ Returns the login register page. If the user is already logged in, it returns the home page """ context = {} if request.user.is_authenticated() and UserProfile.objects.filter(user=request.user).exists(): context = get_base_context(request) return render(request, 'home.html', context) return render(request, 'login-register.html')
def post(self, request): context = get_base_context(request) response = functions.add_schedule(request) if response["result"] == 1: return redirect('/schedule/') else: context["tags"] = get_all_tags() print response["error"] return render(request, 'schedule/add_schedule.html', context)
def post(self, request): """ endpoint for the login form submission """ context = {} context["is_login_page"] = True if request.user.is_authenticated() and UserProfile.objects.filter(user=request.user).exists(): context = get_base_context(request) return render(request, 'home.html', context) response = login(request) if response["result"] == result.RESULT_SUCCESS: context = get_base_context(request) return render(request, 'home.html', context) else: context["message"] = get_response_text(response) return render(request, 'login-register.html', context)
def get(self, request, pk): """ profile page for user with id pk """ context=get_base_context(request) # As base context already has a key 'user' that contains the logged in user, the details of the user with id pk, whose profile page is # to be displayed is saved as other_user context['other_user'] = get_user_profile(pk) return render(request, 'profile.html', context)
def get(self, request, pk): """ profile page for user with id pk """ context = get_base_context(request) # As base context already has a key 'user' that contains the logged in user, the details of the user with id pk, whose profile page is # to be displayed is saved as other_user context['other_user'] = get_user_profile(pk) return render(request, 'profile.html', context)
def get(self, request): """ Returns the login register page. If the user is already logged in, it returns the home page """ context = {} if request.user.is_authenticated() and UserProfile.objects.filter( user=request.user).exists(): context = get_base_context(request) return render(request, 'home.html', context) return render(request, 'login-register.html')
def get(self, request, pk): """ returns add reply form for discussion with id pk Note - this function is no longer used as the add discussion form is moved to the discussion details page """ context = get_base_context(request) response = functions.get_discussion(pk) context["discussion"] = response["data"] return render(request, 'reply.html', context)
def post(self, request): """ endpoint for the login form submission """ context = {} context["is_login_page"] = True if request.user.is_authenticated() and UserProfile.objects.filter( user=request.user).exists(): context = get_base_context(request) return render(request, 'home.html', context) response = login(request) if response["result"] == result.RESULT_SUCCESS: context = get_base_context(request) return render(request, 'home.html', context) else: context["message"] = get_response_text(response) return render(request, 'login-register.html', context)
def post(self, request): """ creates a news article with data from the add news form """ context = get_base_context(request) response = functions.add_news(request) if response["result"] == 1: return redirect('/news/') else: context["tags"] = get_all_tags() #if creation of event failed return to add event form with the errors return render(request, 'news_event/add-news.html', context)
def post(self, request): """ creates a news article with data from the add news form """ context = get_base_context(request) response = functions.add_news(request) if response["result"] == 1: return redirect('/news/') else: context["tags"] = get_all_tags() #if creation of event failed return to add event form with the errors return render(request, 'news_event/add-news.html', context)
def post(self, request): """ create new result with data sent from the add result form """ context = get_base_context(request) response = functions.add_result(request) if response["result"] == 1: return redirect('/results/') else: context["tags"] = get_all_tags() print response["error"] return render(request, 'result/add_result.html', context)
def post(self, request): """ adds a discussion thread with data send from the add discussion form If unable to create the thread, it returns the discussion form with a list of errors """ context = get_base_context(request) response = functions.add_discussion_thread(request) if response["result"] == 1: return redirect('/discussions/') else: return render(request, 'add-discussion.html', context)
def get_context_data(self, **kwargs): context = super(EventList, self).get_context_data(**kwargs) context['user'] = get_base_context(self.request)["user"] news_list = self.get_queryset() count = len(news_list) page_count = count / PAGE_SIZE + 1 context["pages"] = range(1, page_count + 1) my_tags = [tag.name for tag in context['user'].followed_tags.all()] if 'tag' in self.request.GET and not self.request.GET["tag"] in my_tags: context['tag'] = self.request.GET["tag"] return context
def get_context_data(self, **kwargs): context = super(ScheduleList, self).get_context_data(**kwargs) context['user'] = get_base_context(self.request)["user"] schedule_list = self.get_queryset() count = len(schedule_list) page_count = count/PAGE_SIZE + 1 context["pages"] = range(1, page_count+1) my_tags = [tag.name for tag in context['user'].followed_tags.all()] if 'tag' in self.request.GET and not self.request.GET["tag"] in my_tags: context['tag'] = self.request.GET["tag"] return context
def post(self, request, pk): """ Adds a reply to discussion thread with id pk """ context = get_base_context(request) response = functions.add_reply(pk, request) context["discussion"] = response["data"] if response["result"] == 1: return redirect('/discussions/' + str(pk)) else: print response return render(request, 'reply.html', context)
def get(self, request): """ returns the login/register page. If the user is already logged in then this returns the home page """ context = {} context["is_login_page"] = True if request.user.is_authenticated() and UserProfile.objects.filter(user=request.user).exists(): context = get_base_context(request) return render(request, 'home.html', context) return render(request, 'login-register.html', context) response = login(request) if response["result"] == result.RESULT_SUCCESS: context = get_base_context(request) return render(request, 'home.html', context) else: context["message"] = get_response_text(response) return render(request, 'login-register.html', context)
def get(self, request): """ returns tag page for tag with id pk """ context=get_base_context(request) tag = Tag.objects.get(name = request.GET["tag"]) context["tag"] = tag results = get_top_results([tag]) schedules = get_top_schedules([tag]) context["results"] = results context["schedules"] = schedules context["events"] = get_top_events([tag]) context["news_list"] = get_top_news([tag]) context["discussions"] = get_top_discussions([tag]) return render(request, 'tag_page.html', context)
def get(self, request): """ returns tag page for tag with id pk """ context = get_base_context(request) tag = Tag.objects.get(name=request.GET["tag"]) context["tag"] = tag results = get_top_results([tag]) schedules = get_top_schedules([tag]) context["results"] = results context["schedules"] = schedules context["events"] = get_top_events([tag]) context["news_list"] = get_top_news([tag]) context["discussions"] = get_top_discussions([tag]) return render(request, 'tag_page.html', context)
def get(self, request, pk): context = get_base_context(request) discussion = DiscussionThread.objects.get(id=pk) userProfile = UserProfile.objects.get(user=request.user) response = functions.get_replies(pk, request) page_count = response["page_count"] #if user is already subscribed to the discussion, unsubscribe button is displayed context["subscribed"] = (userProfile in discussion.subscribed.all()) #list of page numbers to be displayed at the pagination in the bottom of the page context["pages"] = range(1, page_count + 1) context["replies"] = response["data"]["replies"] context["discussion"] = response["data"]["discussion"] return render(request, 'discussion-detail.html', context)
def get_context_data(self, **kwargs): context = super(NewsList, self).get_context_data(**kwargs) context['user'] = get_base_context(self.request)["user"] #add the list of page numbers to be displayed in the pagination at the bottom of the page news_list = self.get_queryset() count = len(news_list) page_count = count/PAGE_SIZE + 1 context["pages"] = range(1, page_count+1) #if a tag is sent as a query, a link to subscribe to that tag is displayed at the top of the list #if the user already follows that tag, this link is not shown my_tags = [tag.name for tag in context['user'].followed_tags.all()] if 'tag' in self.request.GET and not self.request.GET["tag"] in my_tags: #tag added to the context to show follow link context['tag'] = self.request.GET["tag"] return context
def get_context_data(self, **kwargs): context = super(NewsList, self).get_context_data(**kwargs) context['user'] = get_base_context(self.request)["user"] #add the list of page numbers to be displayed in the pagination at the bottom of the page news_list = self.get_queryset() count = len(news_list) page_count = count / PAGE_SIZE + 1 context["pages"] = range(1, page_count + 1) #if a tag is sent as a query, a link to subscribe to that tag is displayed at the top of the list #if the user already follows that tag, this link is not shown my_tags = [tag.name for tag in context['user'].followed_tags.all()] if 'tag' in self.request.GET and not self.request.GET["tag"] in my_tags: #tag added to the context to show follow link context['tag'] = self.request.GET["tag"] return context
def get(self, request): """ returns discussion list, if a tag is sent as a query, the list of discussions is filtered by that tag """ context = get_base_context(request) response = functions.get_discussion_list(request) page_count = response["page_count"] #page numers to be displayed in the pagination at the bottom of the page context["pages"] = range(1, page_count + 1) #if a tag is sent as a query, a link to subscribe to that tag is displayed at the top of the list #if the user already follows that tag, this link is not shown my_tags = [tag.name for tag in context['user'].followed_tags.all()] if 'tag' in self.request.GET and not self.request.GET["tag"] in my_tags: #tag added to the context to show follow link context['tag'] = self.request.GET["tag"] context["discussions"] = response["data"] return render(request, 'discussion-list.html', context)
def get_context_data(self, **kwargs): context = super(NewsDetail, self).get_context_data(**kwargs) context['user'] = get_base_context(self.request)["user"] return context
def get(self, request): context = get_base_context(request) context["tags"] = get_all_tags() return render(request, 'schedule/add_schedule.html', context)
def get(self, request): context = get_base_context(request) context["tags"] = get_all_tags() return render(request, 'schedule/add_schedule.html', context)
def get_context_data(self, **kwargs): context = super(NewsDetail, self).get_context_data(**kwargs) context['user'] = get_base_context(self.request)["user"] return context