aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2013-08-14 15:08:49 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2013-08-14 15:08:49 -0500
commit7949d88a751e52a2e0aef42e4801e17283556467 (patch)
treed76df995d33b18acdaea87942f37e40ea3dc6f93 /mediagoblin
parent135dd5296b16a8612a787e8beca28ea805e32583 (diff)
downloadmediagoblin-7949d88a751e52a2e0aef42e4801e17283556467.tar.lz
mediagoblin-7949d88a751e52a2e0aef42e4801e17283556467.tar.xz
mediagoblin-7949d88a751e52a2e0aef42e4801e17283556467.zip
Avoiding the celery warnings that we seem to be confusing people lately.
Basically, it's shuffling around the notifications stuff. This commit sponsored by Günter Kraft. Thank you!
Diffstat (limited to 'mediagoblin')
-rw-r--r--mediagoblin/app.py3
-rw-r--r--mediagoblin/notifications/__init__.py2
-rw-r--r--mediagoblin/templates/mediagoblin/base.html6
-rw-r--r--mediagoblin/templates/mediagoblin/fragments/header_notifications.html2
-rw-r--r--mediagoblin/templates/mediagoblin/utils/comment-subscription.html3
-rw-r--r--mediagoblin/tools/template.py9
6 files changed, 14 insertions, 11 deletions
diff --git a/mediagoblin/app.py b/mediagoblin/app.py
index 57e09e49..e9177eff 100644
--- a/mediagoblin/app.py
+++ b/mediagoblin/app.py
@@ -39,7 +39,6 @@ from mediagoblin.init import (get_jinja_loader, get_staticdirector,
from mediagoblin.tools.pluginapi import PluginManager, hook_transform
from mediagoblin.tools.crypto import setup_crypto
from mediagoblin.auth.tools import check_auth_enabled, no_auth_logout
-from mediagoblin import notifications
_log = logging.getLogger(__name__)
@@ -199,8 +198,6 @@ class MediaGoblinApp(object):
# Log user out if authentication_disabled
no_auth_logout(request)
- request.notifications = notifications
-
mg_request.setup_user_in_request(request)
request.controller_name = None
diff --git a/mediagoblin/notifications/__init__.py b/mediagoblin/notifications/__init__.py
index 4b7fbb8c..ed9f8d78 100644
--- a/mediagoblin/notifications/__init__.py
+++ b/mediagoblin/notifications/__init__.py
@@ -18,7 +18,6 @@ import logging
from mediagoblin.db.models import Notification, \
CommentNotification, CommentSubscription
-from mediagoblin.notifications.task import email_notification_task
from mediagoblin.notifications.tools import generate_comment_message
_log = logging.getLogger(__name__)
@@ -50,6 +49,7 @@ def trigger_notification(comment, media_entry, request):
media_entry,
request)
+ from mediagoblin.notifications.task import email_notification_task
email_notification_task.apply_async([cn.id, message])
diff --git a/mediagoblin/templates/mediagoblin/base.html b/mediagoblin/templates/mediagoblin/base.html
index bbc77351..65dbebc0 100644
--- a/mediagoblin/templates/mediagoblin/base.html
+++ b/mediagoblin/templates/mediagoblin/base.html
@@ -60,10 +60,10 @@
{%- if request.user %}
{% if request.user and request.user.status == 'active' %}
- {% set notification_count = request.notifications.get_notification_count(request.user.id) %}
+ {% set notification_count = get_notification_count(request.user.id) %}
{% if notification_count %}
- <a href="#notifications" class="notification-gem button_action" title="Notifications">
- {{ notification_count }}</a>
+ <a href="#notifications" class="notification-gem button_action" title="Notifications">
+ {{ notification_count }}</a>
{% endif %}
<a href="#header" class="button_action header_dropdown_down">&#9660;</a>
<a href="#no_header" class="button_action header_dropdown_up">&#9650;</a>
diff --git a/mediagoblin/templates/mediagoblin/fragments/header_notifications.html b/mediagoblin/templates/mediagoblin/fragments/header_notifications.html
index 613100aa..70d7935a 100644
--- a/mediagoblin/templates/mediagoblin/fragments/header_notifications.html
+++ b/mediagoblin/templates/mediagoblin/fragments/header_notifications.html
@@ -1,4 +1,4 @@
-{% set notifications = request.notifications.get_notifications(request.user.id) %}
+{% set notifications = get_notifications(request.user.id) %}
{% if notifications %}
<div class="header_notifications">
<h3>{% trans %}New comments{% endtrans %}</h3>
diff --git a/mediagoblin/templates/mediagoblin/utils/comment-subscription.html b/mediagoblin/templates/mediagoblin/utils/comment-subscription.html
index bd367e80..75da5e89 100644
--- a/mediagoblin/templates/mediagoblin/utils/comment-subscription.html
+++ b/mediagoblin/templates/mediagoblin/utils/comment-subscription.html
@@ -16,8 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{%- if request.user %}
- {% set subscription = request.notifications.get_comment_subscription(
- request.user.id, media.id) %}
+ {% set subscription = get_comment_subscription(request.user.id, media.id) %}
{% if not subscription or not subscription.notify %}
<a type="submit" href="{{ request.urlgen('mediagoblin.notifications.subscribe_comments',
user=media.get_uploader.username,
diff --git a/mediagoblin/tools/template.py b/mediagoblin/tools/template.py
index 4c634ea2..3cc058c9 100644
--- a/mediagoblin/tools/template.py
+++ b/mediagoblin/tools/template.py
@@ -32,7 +32,6 @@ from mediagoblin.tools.timesince import timesince
from mediagoblin.meddleware.csrf import render_csrf_form_token
-
SETUP_JINJA_ENVS = {}
@@ -90,6 +89,14 @@ def get_jinja_env(template_loader, locale):
template_env.globals = hook_transform(
'template_global_context', template_env.globals)
+ #### THIS IS TEMPORARY, PLEASE FIX IT
+ ## Notifications stuff is not yet a plugin (and we're not sure it will be),
+ ## but it needs to add stuff to the context. This is THE WRONG WAY TO DO IT
+ from mediagoblin import notifications
+ template_env.globals['get_notifications'] = notifications.get_notifications
+ template_env.globals[
+ 'get_comment_subscription'] = notifications.get_comment_subscription
+
if exists(locale):
SETUP_JINJA_ENVS[locale] = template_env