def render(self, context): view_from_page = self.view_from_page.resolve(context) is_userLogged = self.is_userLogged.resolve(context) owner = self.owner.resolve(context) forumCount = "" if view_from_page == 'home': forumContent = get_latest_threads("mostpopular", "limit 4") elif view_from_page == 'medical-content': forumContent = get_latest_threads("datedtime", "limit 2") latest_forum = '' if len(forumContent) > 0: for forum_row in forumContent: thread_date = forum_row[6] thread_time = forum_row[7] if forum_row[6] is None or forum_row[6] <= 0: thread_date = '0' if forum_row[7] is None or forum_row[7] <= 0: thread_time = '0' if forum_row[5] > 0: thread_count = forum_row[5]-1 elif forum_row[5] == 0: thread_count = forum_row[5] if view_from_page == 'medical-content': thread_body = forum_row[2][0:60]+"...." elif view_from_page == 'home': thread_body = forum_row[2] if owner == forum_row[11]: display_activity_links = 'true' elif owner != forum_row[11]: display_activity_links = 'false' if forum_row[12]: is_locked = True else: is_locked = 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(thread_body), 'topic_id':forum_row[10], 'view_from_page':view_from_page, 'most_popular':forum_row[8], 'user_isLogged':is_userLogged, 'display_activity_links':display_activity_links, 'is_locked':is_locked} forum_template = get_template('home_forumContent.html') latest_forum += forum_template.render(Context(forum_context)) elif len(forumContent) == 0: latest_forum+= '<br/><br/><center><i>No records found.</i></center></br/></br/>' return latest_forum
def orderForumActivityHome(request, offset): """ @AUTHOR:Fouzia Riaz @DESCRIPTION:Function For Latest Forum Content Order BY Display on Home Page (AJAX) """ user_status = is_userLogged(request) if user_status: logged_user = request.session["User_id"] else: logged_user = "" try: order_field = str(offset) except ValueError: pass forumContent = get_latest_threads(order_field, "limit 4") user_status = is_userLogged(request) latest_forum = "" if len(forumContent) > 0: for forum_row in forumContent: thread_date = forum_row[6] thread_time = forum_row[7] if forum_row[6] is None or forum_row[6] <= 0: thread_date = "0" if forum_row[7] is None or forum_row[7] <= 0: thread_time = "0" if forum_row[5] > 0: thread_count = forum_row[5] - 1 elif forum_row[5] == 0: thread_count = forum_row[5] if logged_user == forum_row[11]: display_activity_links = "true" elif logged_user != forum_row[11]: display_activity_links = "false" if forum_row[12]: is_locked = True else: is_locked = 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]), "topic_id": forum_row[10], "most_popular": forum_row[8], "user_isLogged": user_status, "display_activity_links": display_activity_links, "is_locked": is_locked, "view_from_page": "home", } forum_template = get_template("home_forumContent.html") latest_forum += forum_template.render(Context(forum_context)) elif len(forumContent) == 0: latest_forum += "<br/><br/><center><i>No records found.</i></center></br/></br/>" return HttpResponse(latest_forum)
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