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 is_watching_discussion_locale(user, locale): """Return True if `user` is watching the discussion for `locale` and False, otherwise.""" return NewPostInLocaleEvent.is_notifying(user, locale=locale)