def render(self, context): category_id = self.category.resolve(context) user_isLogged = self.user_isLogged.resolve(context) owner = self.owner.resolve(context) topic_is_locked = self.topic_is_locked.resolve(context) try: if len(category_id) == 0: forumActivityContent = get_latest_threads("mostpopular", "limit 5") forumActivityCount = get_latest_threads("mostpopular", "") topic_count = len(forumActivityCount) is_topic = 'false' else: if category_id != 'none': forumActivityContent = get_topic_threads(category_id, "mostpopular", "limit 5") forumActivityCount = get_topic_threads(category_id, "mostpopular", "") else: category_id = "null" forumActivityContent = get_topic_threads(category_id, "mostpopular", "limit 5") forumActivityCount = get_topic_threads(category_id, "mostpopular", "") topic_is_locked = "null" is_topic = 'true' topic_count = len(forumActivityCount) forum_activity = '' if len(forumActivityContent) > 0: for forum_row in forumActivityContent: if is_topic == 'true': forum_context = getForumActivityContext(forum_row, is_topic, topic_count, user_isLogged, owner, topic_is_locked) else: forum_context = getForumActivityContext(forum_row, is_topic, topic_count, user_isLogged, owner, topic_is_locked) forum_template = get_template('home_forumContent.html') forum_activity += forum_template.render(Context(forum_context)) elif len(forumActivityContent) == 0: forum_activity+= '<br/><br/><center><i>No records found.</i></center></br/></br/>' if len(category_id) != 0: forum_activity += '<input type="hidden" value="'+category_id+'" id="cat_id"/>' forum_activity += '<input type="hidden" value="'+`topic_count`+'" id="topic_count"/><input type="hidden" value="mostpopular" id="order_by"/>' return forum_activity except: forum_activity = '<br/><br/><center><i>No Records Found</i></center><br/><br/><br/>' return forum_activity
def forumContentByTopic(request, offset): """ @AUTHOR:Fouzia Riaz @DESCRIPTION:Function For Latest Forum Content Order BY Display on Forum Page """ user_status = is_userLogged(request) if user_status: logged_user = request.session["User_id"] else: logged_user = "" try: topic_id = offset except ValueError: pass try: topic_id = offset except ValueError: pass try: getCategory = Topic.objects.get(id=topic_id) if getCategory.id: forumContent = get_topic_threads(topic_id) latest_forum_by_topic = "" if len(forumContent) > 0: for forum_row in forumContent: thread_date = forum_row[7] thread_time = forum_row[8] # thread_count = forum_row[6] if forum_row[7] is None or forum_row[7] <= 0: thread_date = "0" if forum_row[8] is None or forum_row[8] <= 0: thread_time = "0" if forum_row[6] > 0: thread_count = forum_row[6] - 1 elif forum_row[6] == 0: thread_count = thread_count if logged_user == forum_row[11]: display_activity_links = "true" elif logged_user != forum_row[11]: display_activity_links = "false" forum_context = { "id": forum_row[0], "thread_count": thread_count, "thread_date": thread_date, "thread_time": thread_time, "first_name": forum_row[3], "last_name": forum_row[4], "thread_topic": forum_row[1], "thread_body": mark_safe(forum_row[2]), "is_userLogged": user_status, "display_activity_links": display_activity_links, } forum_template = get_template("home_forumContent.html") latest_forum_by_topic += forum_template.render(Context(forum_context)) elif len(forumContent) == 0: latest_forum_by_topic += "<br/><br/><center><i>No records found.</i></center></br/></br/>" return HttpResponse(latest_forum_by_topic) else: return HttpResponseRedirect("/") except: return HttpResponseRedirect("/")
def orderMoreForumActivity(request, offset): """ @AUTHOR:Fouzia Riaz @DESCRIPTION:Function For Latest Forum Content Order BY/See more on Forum Page """ user_status = is_userLogged(request) if user_status: logged_user = request.session["User_id"] else: logged_user = "" order_field = "mostpopular" try: # If parameters send in url (LIMITS, COUNTS, ORDERS, Category) (For See more, category) if ( (request.GET.get("lim") and request.GET.get("off") and request.GET.get("counts")) or request.GET.get("orders") or (request.GET.get("cat_id")) ): content_limit = str(request.GET.get("lim")).rstrip("/") content_offset = str(request.GET.get("off")).rstrip("/") content_count = str(request.GET.get("counts")).rstrip("/") order_field = str(request.GET.get("orders")).rstrip("/") catid_field = str(request.GET.get("cat_id")).rstrip("/") catid_field = catid_field.rstrip("/") order_field = order_field.rstrip("/") except ValueError: pass if order_field != "": # If no limits provided in url if content_limit == "None" or content_limit is None: if catid_field is None or catid_field == "None": catid_field = "null" forumContent = get_topic_threads(catid_field, order_field, "limit 5") # If limits provided in url else: limits = "limit " + content_limit + " offset " + content_offset forumContent = get_topic_threads(catid_field, order_field, limits) forumActivityCount = get_topic_threads(catid_field, "mostpopular", "") topic_count = len(forumActivityCount) is_topic = "true" forum_activity = "" if catid_field == "null": view_page = "view-all-forum" else: view_page = "" if len(forumContent) > 0: for forum_row in forumContent: if is_topic == "true": forum_context = getForumContext( forum_row, is_topic, topic_count, user_status, logged_user, view_page ) else: forum_context = getForumContext( forum_row, is_topic, topic_count, user_status, logged_user, view_page ) forum_template = get_template("home_forumContent.html") forum_activity += forum_template.render(Context(forum_context)) elif len(forumContent) == 0: forum_activity += "<br/><br/><center><i>No records found.</i></center></br/></br/>" if len(catid_field) != 0: forum_activity += '<input type="hidden" value="' + catid_field + '" id="cat_id"/>' forum_activity += ( '<input type="hidden" value="' + ` topic_count ` + '" id="topic_count"/><input type="hidden" value="' + order_field + '" id="order_by"/>' ) return HttpResponse(forum_activity)