Basically, it's shuffling around the notifications stuff.
This commit sponsored by Günter Kraft. Thank you!
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__)
# Log user out if authentication_disabled
no_auth_logout(request)
- request.notifications = notifications
-
mg_request.setup_user_in_request(request)
request.controller_name = None
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__)
media_entry,
request)
+ from mediagoblin.notifications.task import email_notification_task
email_notification_task.apply_async([cn.id, message])
{%- 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">▼</a>
<a href="#no_header" class="button_action header_dropdown_up">▲</a>
-{% 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>
# 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,
from mediagoblin.meddleware.csrf import render_csrf_form_token
-
SETUP_JINJA_ENVS = {}
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