Avoiding the celery warnings that we seem to be confusing people lately.
authorChristopher Allan Webber <cwebber@dustycloud.org>
Wed, 14 Aug 2013 20:08:49 +0000 (15:08 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Wed, 14 Aug 2013 20:08:49 +0000 (15:08 -0500)
Basically, it's shuffling around the notifications stuff.

This commit sponsored by Günter Kraft.  Thank you!

mediagoblin/app.py
mediagoblin/notifications/__init__.py
mediagoblin/templates/mediagoblin/base.html
mediagoblin/templates/mediagoblin/fragments/header_notifications.html
mediagoblin/templates/mediagoblin/utils/comment-subscription.html
mediagoblin/tools/template.py

index 57e09e49feda4782d8732a319ef3bb57b730c677..e9177eff33172c6b1445280792ba439bc2b43f2c 100644 (file)
@@ -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
index 4b7fbb8c1129b0ca8fc8c6aa81c21401df929d35..ed9f8d7896b6b4f1a36da93224ce13c31241cb15 100644 (file)
@@ -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])
 
 
index bbc7735176ab9f679682ea80cb943aec83027344..65dbebc062d28c113f40f325d8d36c58453f2c03 100644 (file)
             {%- 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>
index 613100aaaa0707b9df8d23ab2c5d726b69227f66..70d7935a94d407991bc1b3d360b85ee5cc0d0946 100644 (file)
@@ -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>
index bd367e8066cc4fe68af09bfd27558d813b74e842..75da5e89a037026f617582720de749bab1fec8e9 100644 (file)
@@ -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,
index 4c634ea2c5df4003a36c9e94de0360179c3ee5a6..3cc058c938c17f1a711be0141de34c88a206056f 100644 (file)
@@ -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