def contentlisting_context(handler, request, node): language = get_active_language() q = node_proxy_factory(Node, language).objects.children(node).filter(contentbase__language=language).order_by("position") if not access.has_access(request.user, node): q = q.public() return dict(contents=q)
def _render(self, request, context, instance): if 'comment_post' in request.session: data = request.session['comment_post'] del request.session['comment_post'] form = CommentForm(data) else: form = CommentForm() ha = has_access(request.user, instance) comments = self.show_comments(instance, request) return ("wheelcms_comments/commentform.html", {'form':form, 'comments':comments, 'ha':ha, 'instance':instance, 'content':instance.content()})
def show_comments(self, instance, request): ha = has_access(request.user, instance) lang = instance.content().language # if ha, show all, else show published + owner (from session) comments = [x.content() for x in instance.children().filter( contentbase__language=lang, contentbase__meta_type=Comment.classname, contentbase__state__in=("pending", "published"))] mine = request.session.get('posted_comments', []) if not ha: comments = [c for c in comments if c.state == "published" or c.node.path in mine] return comments
def show_settings(self): ## XXX decent permissions user = self.request.user return access.has_access(user)
def test_hasaccess(self, client): """ only powerusers have access """ if self.has_access: assert access.has_access(self.provide_user()) else: assert not access.has_access(self.provide_user())