def get_footer(request): form = GetRequestValidationForm(request.GET) if not form.is_valid(): return HttpResponseBadRequest(_("could not get comments, errors: %s") % form.errors) domain_name = form.cleaned_data["domain"] thread_id = form.cleaned_data["thread"] try: site = Site.objects.get(domain=domain_name) except Site.DoesNotExist: return HttpResponseBadRequest(_("domain with name %s does not exist") % domain_name) thread, created = site.threads.get_or_create(id=thread_id) resp = render( request, "footer.html", { "user": request.user, "site": site, "avatars": range(1, 29), "user_avatar_num": request.session.get("user_avatar_num", 6), "rs_customer_id": site.rs_customer_id, }, ) return {"html": resp.content, "html_container_name": "comments_footer"}
def get_footer(request): form = GetRequestValidationForm(request.GET) if not form.is_valid(): return HttpResponseBadRequest( _('could not get comments, errors: %s') % form.errors ) domain_name = form.cleaned_data['domain'] thread_id = form.cleaned_data['thread'] try: site = Site.objects.get(domain=domain_name) except Site.DoesNotExist: return HttpResponseBadRequest( _('domain with name %s does not exist') % domain_name ) thread, created = site.threads.get_or_create(id=thread_id) resp = render( request, "footer.html", { 'user': request.user, 'site': site, 'avatars': range(1, 29), 'user_avatar_num': request.session.get('user_avatar_num', 6), 'rs_customer_id': site.rs_customer_id, } ) return {"html": resp.content, "html_container_name": "comments_footer"}
def get_footer(request): form = GetRequestValidationForm(request.GET) if not form.is_valid(): return HttpResponseBadRequest( _('could not get comments, errors: %s') % form.errors) domain_name = form.cleaned_data['domain'] thread_id = form.cleaned_data['thread'] try: site = Site.objects.get(domain=domain_name) except Site.DoesNotExist: return HttpResponseBadRequest( _('domain with name %s does not exist') % domain_name) thread, created = site.threads.get_or_create(id=thread_id) resp = render( request, "footer.html", { 'user': request.user, 'site': site, 'avatars': range(1, 29), 'user_avatar_num': request.session.get('user_avatar_num', 6), 'rs_customer_id': site.rs_customer_id, }) return {"html": resp.content, "html_container_name": "comments_footer"}
def get_comments(request): form = GetRequestValidationForm(request.GET) if not form.is_valid(): return HttpResponseBadRequest( _('could not get comments, errors: %s') % form.errors ) domain_name = form.cleaned_data['domain'] thread_id = form.cleaned_data['thread'] try: site = Site.objects.get(domain=domain_name) if not request.user.is_anonymous(): if request.user.hidden.filter(id=site.id): return HttpResponseBadRequest( _('user is disabled on site with id %s') % site.id ) except Site.DoesNotExist: return HttpResponseBadRequest( 'domain with name %s does not exist' % domain_name ) if not thread_id: return HttpResponseBadRequest( _('thread url not provided') ) thread, created = site.threads.get_or_create(id=thread_id) posted_comments = request.session.get('posted_comments', []) all_comments = request.GET.get('all', False) if all_comments: request.session['all_comments'] = True if request.user.is_anonymous(): site_admin = False else: site_admin = request.user.is_site_admin(domain_name) comments = thread.comments.exclude(user__hidden__in=[site]).distinct() resp = render( request, "comments.html", { 'comments': comments, 'posted_comments': posted_comments, 'last_posted_comment_id': posted_comments[-1] if posted_comments else None, 'rs_customer_id': site.rs_customer_id, 'all_comments': all_comments, 'site_admin': site_admin } ) return {"html": resp.content, "html_container_name": "comments_container"}
def get_comments(request): form = GetRequestValidationForm(request.GET) if not form.is_valid(): return HttpResponseBadRequest( _('could not get comments, errors: %s') % form.errors) domain_name = form.cleaned_data['domain'] thread_id = form.cleaned_data['thread'] try: site = Site.objects.get(domain=domain_name) if not request.user.is_anonymous(): if request.user.hidden.filter(id=site.id): return HttpResponseBadRequest( _('user is disabled on site with id %s') % site.id) except Site.DoesNotExist: return HttpResponseBadRequest('domain with name %s does not exist' % domain_name) if not thread_id: return HttpResponseBadRequest(_('thread url not provided')) thread, created = site.threads.get_or_create(id=thread_id) posted_comments = request.session.get('posted_comments', []) all_comments = request.GET.get('all', False) if all_comments: request.session['all_comments'] = True if request.user.is_anonymous(): site_admin = False else: site_admin = request.user.is_site_admin(domain_name) comments = thread.comments.exclude(user__hidden__in=[site]).distinct() resp = render( request, "comments.html", { 'comments': comments, 'posted_comments': posted_comments, 'last_posted_comment_id': posted_comments[-1] if posted_comments else None, 'rs_customer_id': site.rs_customer_id, 'all_comments': all_comments, 'site_admin': site_admin }) return {"html": resp.content, "html_container_name": "comments_container"}
def get_header(request): form = GetRequestValidationForm(request.GET) if not form.is_valid(): return HttpResponseBadRequest(_("could not get comments, errors: %s") % form.errors) domain_name = form.cleaned_data["domain"] thread_id = form.cleaned_data["thread"] try: site = Site.objects.get(domain=domain_name) except Site.DoesNotExist: return HttpResponseBadRequest(_("domain with name %s does not exist") % domain_name) thread, created = site.threads.get_or_create(id=thread_id) resp = render(request, "header.html", {"thread": thread}) return {"html": resp.content, "html_container_name": "comments_header"}
def get_header(request): form = GetRequestValidationForm(request.GET) if not form.is_valid(): return HttpResponseBadRequest( _('could not get comments, errors: %s') % form.errors) domain_name = form.cleaned_data['domain'] thread_id = form.cleaned_data['thread'] try: site = Site.objects.get(domain=domain_name) except Site.DoesNotExist: return HttpResponseBadRequest( _('domain with name %s does not exist') % domain_name) thread, created = site.threads.get_or_create(id=thread_id) resp = render(request, "header.html", {'thread': thread}) return {"html": resp.content, "html_container_name": "comments_header"}
def get_comments(request): form = GetRequestValidationForm(request.GET) if not form.is_valid(): return HttpResponseBadRequest( _('could not get comments, errors: %s') % form.errors) domain_name = form.cleaned_data['domain'] thread_id = form.cleaned_data['thread'] try: site = Site.objects.get(domain=domain_name) except Site.DoesNotExist: return HttpResponseBadRequest('domain with name %s does not exist' % domain_name) if not thread_id: return HttpResponseBadRequest(_('thread url not provided')) thread, created = site.threads.get_or_create(id=thread_id) posted_comments = request.session.get('posted_comments', []) all_comments = request.GET.get('all', False) if all_comments: request.session['all_comments'] = True resp = render( request, "comments.html", { 'comments': thread.comments.all(), 'posted_comments': posted_comments, 'last_posted_comment_id': posted_comments[-1] if posted_comments else None, 'rs_customer_id': site.rs_customer_id, 'all_comments': all_comments, }) return {"html": resp.content, "html_container_name": "comments_container"}
def get_comments(request): form = GetRequestValidationForm(request.GET) if not form.is_valid(): return HttpResponseBadRequest(_("could not get comments, errors: %s") % form.errors) domain_name = form.cleaned_data["domain"] thread_id = form.cleaned_data["thread"] try: site = Site.objects.get(domain=domain_name) except Site.DoesNotExist: return HttpResponseBadRequest("domain with name %s does not exist" % domain_name) if not thread_id: return HttpResponseBadRequest(_("thread url not provided")) thread, created = site.threads.get_or_create(id=thread_id) posted_comments = request.session.get("posted_comments", []) all_comments = request.GET.get("all", False) if all_comments: request.session["all_comments"] = True resp = render( request, "comments.html", { "comments": thread.comments.all(), "posted_comments": posted_comments, "last_posted_comment_id": posted_comments[-1] if posted_comments else None, "rs_customer_id": site.rs_customer_id, "all_comments": all_comments, }, ) return {"html": resp.content, "html_container_name": "comments_container"}