def index(request): suggestions = Suggestion.get_filtered_with_rating({"status__value__in": site_settings.SUGGESTIONS_ARCHIVED_VALUE}, exclude=True).select_related('status').prefetch_related('categories').order_by('-time') context = { 'suggestions_page': get_page(suggestions, request, 25), } return render(request, 'suggestions/index.html', context)
def view_category(request, slug=None): category = Category.objects.get(slug=slug) context = { "category": category, 'forum_struct_page': get_page(category.get_children(), request, 25), } return render(request, 'forum/category.html', context)
def view_topic(request, slug=None): # get sort mode from cookies sortmode=2 topic = Topic.objects.get(slug=slug) context = { "topic": topic, 'post_struct_page': get_page(topic.posts.all(), request, 25), } return render(request, 'forum/topic.html', context)
def view_forum( request, slug=None, ): # get sort mode from cookies sortmode=2 mode = 2 forum = Forum.objects.get(slug=slug) # get sort order #check perm context = { "forum": forum, "nav_help": [x for x in forum.yield_parents_upwards()], 'forum_struct_page': get_page(forum.get_children(), request, 25), 'topic_struct_page': get_page(forum.get_topics_by_sort_order(mode=mode), request, 25), } return render(request, 'forum/forum.html', context)
def filtered_overview(request): query_dict = {} in_all_cats = request.GET.getlist('all', False) categories = request.GET.getlist('c', None) status = request.GET.getlist('s', None) if categories: query_dict["status__value__in"] = status if status: query_dict["categories__value__in"] = status suggestions = Suggestion.get_filtered_with_rating(query_dict) if in_all_cats: suggestions = suggestions.annotate(num_tags=Count('tags')).filter(num_tags=len(categories)) suggestions = suggestions.select_related('status').prefetch_related('categories').order_by('-time') context = { 'suggestions_page': get_page(suggestions, request, 25), } return render(request, 'suggestions/filtered.html', context)