def _list(request, render, num_per_page=10, filters=[], c={}, community='', widget='', home=False): filters = filters #get_common_filters(request) + filters if community and widget: w = Community.objects.get(key_name=community).widget_set.get(key_name=widget) filters.append(lambda q: q.filter(community_widget=w)) if home: num_per_page = w.num_on_homepage else: num_per_page = w.num_per_page posts = build_query(Topic, filters) p = Paginator(posts, num_per_page) page = p.page(get_int_param(request, 'page', 1)) posts = page.object_list community_obj = None if community: community_obj = Community.objects.get(key_name=community) widget_config = None if widget: widget_config = community_obj.widget_set.get(key_name=widget) context = { 'posts': posts, 'page_info': page, 'community': community, 'community_obj': community_obj, 'widget': widget, 'widget_config': widget_config, 'app_config': APPS.get('tui', None) } context.update(c) return render(request, context)
def _list(request, render, num_per_page=10, filters=[], community='', widget=''): # filters.append(lambda q: q.order('-update')) widget_config = None if community and widget: w = Community.objects.get(key_name=community).widget_set.get(key_name=widget) filters.append(lambda q: q.filter(community_widget=w)) filters.append(lambda q: q.order_by('-updated')) posts = build_query(Topic, filters) p = Paginator(posts, num_per_page) page = p.page(get_int_param(request, 'page', 1)) posts = page.object_list community_obj = None if community: community_obj = Community.objects.get(key_name=community) widget_config = None if widget: widget_config = community_obj.widget_set.get(key_name=widget) context = { 'posts': posts, 'page_info': page, 'community': community, 'community_obj': community_obj, 'widget': widget, 'widget_config': widget_config, 'app_config': APPS.get('forum', None) } return render(request, context)
def _list(request, render, num_per_page=10, filters=[], user='', widget='', c={}): filters = get_common_filters(request) + filters u = get_user_model().objects.get(username=user) w = u.user_widget_set.get(key_name=widget) filters.append(lambda q: q.filter(user_widget=w)) posts = build_query(Topic, filters) p = Paginator(posts, num_per_page) page = p.page(get_int_param(request, 'page', 1)) posts = page.object_list context = { 'posts': posts, 'page_info': page, 'user_obj': u, 'widget': widget, 'widget_config': w, 'app_config': APPS.get('note', None), } context.update(c) return render(request, context)
def _validate_app_id(value): app = APPS.get(value) if not app: raise ValidationError(_(u"%s is not a valid app.") % app) if not app["multiple_widgets"] and c.get_widgets(value): raise ValidationError(_(u"%s is already used.") % app["name"])
def app_config(self): return APPS.get(self.app.key_name, None)