notifications: removed usage of pylons translation from models.

This commit is contained in:
Marcin Kuzminski 2017-07-13 17:58:15 +02:00
parent 580a0d0ea5
commit 8ff5e04569
5 changed files with 13 additions and 13 deletions

View file

@ -2029,3 +2029,12 @@ def api_call_example(method, args):
api_url=route_url('apiv2'),
token_url=route_url('my_account_auth_tokens'),
data=args_json))
def notification_description(notification, request):
"""
Generate notification human readable description based on notification type
"""
from rhodecode.model.notification import NotificationModel
return NotificationModel().make_description(
notification, translate=request.translate)

View file

@ -3708,11 +3708,6 @@ class Notification(Base, BaseModel):
return notification
@property
def description(self):
from rhodecode.model.notification import NotificationModel
return NotificationModel().make_description(self)
class UserNotification(Base, BaseModel):
__tablename__ = 'user_to_notification'

View file

@ -23,13 +23,10 @@
Model for notifications
"""
import logging
import traceback
from pylons.i18n.translation import _, ungettext
from sqlalchemy.sql.expression import false, true
from mako import exceptions
import rhodecode
from rhodecode.lib import helpers as h
@ -37,7 +34,6 @@ from rhodecode.lib.utils import PartialRenderer
from rhodecode.model import BaseModel
from rhodecode.model.db import Notification, User, UserNotification
from rhodecode.model.meta import Session
from rhodecode.model.settings import SettingsModel
from rhodecode.translation import TranslationString
log = logging.getLogger(__name__)
@ -238,12 +234,12 @@ class NotificationModel(BaseModel):
.filter(UserNotification.notification == notification)\
.filter(UserNotification.user == user).scalar()
def make_description(self, notification, show_age=True, translate=None):
def make_description(self, notification, translate, show_age=True):
"""
Creates a human readable description based on properties
of notification object
"""
_ = translate
_map = {
notification.TYPE_CHANGESET_COMMENT: [
_('%(user)s commented on commit %(date_or_age)s'),

View file

@ -15,7 +15,7 @@
<div class="desc ${'unread' if not notification.read else '' }">
<a href="${h.route_path('notifications_show', notification_id=notification.notification.notification_id)}">
${base.gravatar(notification.notification.created_by_user.email, 16)}
${notification.notification.description}
${h.notification_description(notification.notification, request)}
</a>
</div>
<div class="delete-notifications">

View file

@ -29,7 +29,7 @@
<div class="notification-header">
${self.gravatar(c.notification.created_by_user.email, 30)}
<div class="desc">
${c.notification.description}
${h.notification_description(c.notification, request)}
</div>
<div class="delete-notifications">
<span class="delete-notification tooltip" title="${_('Delete')}" onclick="deleteNotification(${c.notification.notification_id}, [function(){window.location=pyroutes.url('notifications_show_all')}])" class="delete-notification action"><i class="icon-delete" ></i></span>