def watch_locale(request): """Watch/unwatch a locale.""" locale = request.locale if request.POST.get('watch') == 'yes': NewPostInLocaleEvent.notify(request.user, locale=locale) NewThreadInLocaleEvent.notify(request.user, locale=locale) else: NewPostInLocaleEvent.stop_notifying(request.user, locale=locale) NewThreadInLocaleEvent.stop_notifying(request.user, locale=locale) return HttpResponseRedirect(get_next_url(request))
def watch_locale(request): """Watch/unwatch a locale.""" locale = request.LANGUAGE_CODE if request.POST.get('watch') == 'yes': NewPostInLocaleEvent.notify(request.user, locale=locale) NewThreadInLocaleEvent.notify(request.user, locale=locale) statsd.incr('kbforums.watches.locale') else: NewPostInLocaleEvent.stop_notifying(request.user, locale=locale) NewThreadInLocaleEvent.stop_notifying(request.user, locale=locale) # If there is no next url, send the user to the home page. return HttpResponseRedirect(get_next_url(request) or reverse('home'))
def watch_locale(request): """Watch/unwatch a locale.""" locale = request.locale if request.POST.get("watch") == "yes": NewPostInLocaleEvent.notify(request.user, locale=locale) NewThreadInLocaleEvent.notify(request.user, locale=locale) statsd.incr("kbforums.watches.locale") else: NewPostInLocaleEvent.stop_notifying(request.user, locale=locale) NewThreadInLocaleEvent.stop_notifying(request.user, locale=locale) # If there is no next url, send the user to the home page. return HttpResponseRedirect(get_next_url(request) or reverse("home"))
def locale_discussions(request): locale_name = LOCALES[request.LANGUAGE_CODE].native threads = Thread.objects.filter(document__locale=request.LANGUAGE_CODE, document__allow_discussion=True) try: sort = int(request.GET.get('sort', 0)) except ValueError: sort = 0 try: desc = int(request.GET.get('desc', 0)) except ValueError: desc = 0 desc_toggle = 0 if desc else 1 threads_ = sort_threads(threads, sort, desc) # Ignore sticky-ness: threads_ = threads_.order_by('-last_post__created') threads_ = paginate(request, threads_, per_page=kbforums.THREADS_PER_PAGE) is_watching_locale = (request.user.is_authenticated() and NewThreadInLocaleEvent.is_notifying( request.user, locale=request.LANGUAGE_CODE)) return render( request, 'kbforums/discussions.html', { 'locale_name': locale_name, 'threads': threads_, 'desc_toggle': desc_toggle, 'is_watching_locale': is_watching_locale })
def locale_discussions(request): locale_name = LOCALES[request.LANGUAGE_CODE].native threads = Thread.objects.filter(document__locale=request.LANGUAGE_CODE, document__allow_discussion=True) try: sort = int(request.GET.get('sort', 0)) except ValueError: sort = 0 try: desc = int(request.GET.get('desc', 0)) except ValueError: desc = 0 desc_toggle = 0 if desc else 1 threads_ = sort_threads(threads, sort, desc) # Ignore sticky-ness: threads_ = threads_.order_by('-last_post__created') threads_ = paginate(request, threads_, per_page=kbforums.THREADS_PER_PAGE) is_watching_locale = (request.user.is_authenticated() and NewThreadInLocaleEvent.is_notifying( request.user, locale=request.LANGUAGE_CODE)) return render(request, 'kbforums/discussions.html', { 'locale_name': locale_name, 'threads': threads_, 'desc_toggle': desc_toggle, 'is_watching_locale': is_watching_locale})
def locale_discussions(request): locale_name = LOCALES[request.locale].native threads = Thread.objects.filter(document__locale=request.locale, document__allow_discussion=True) try: sort = int(request.GET.get("sort", 0)) except ValueError: sort = 0 try: desc = int(request.GET.get("desc", 0)) except ValueError: desc = 0 desc_toggle = 0 if desc else 1 threads_ = sort_threads(threads, sort, desc) # Ignore sticky-ness: threads_ = threads_.order_by("-last_post__created") threads_ = paginate(request, threads_, per_page=kbforums.THREADS_PER_PAGE) is_watching_locale = request.user.is_authenticated() and NewThreadInLocaleEvent.is_notifying( request.user, locale=request.locale ) return jingo.render( request, "kbforums/discussions.html", { "locale_name": locale_name, "threads": threads_, "desc_toggle": desc_toggle, "is_watching_locale": is_watching_locale, }, )