# HG changeset patch # User Mads Kiilerich # Date 2020-10-30 15:26:03 # Node ID 180effeba21935b9e253e03dab4faa06739f924a # Parent 1f8eaa4c1dff7dc5927d0ef2a37b48bbf14a1088 model: it is a known layering violation to use helpers in model - import it lazily diff --git a/kallithea/model/notification.py b/kallithea/model/notification.py --- a/kallithea/model/notification.py +++ b/kallithea/model/notification.py @@ -33,7 +33,6 @@ from tg import app_globals from tg import tmpl_context as c from tg.i18n import ugettext as _ -from kallithea.lib import helpers as h from kallithea.model import db @@ -66,6 +65,7 @@ class NotificationModel(object): :param with_email: send email with this notification :param email_kwargs: additional dict to pass as args to email template """ + import kallithea.lib.helpers as h from kallithea.lib.celerylib import tasks email_kwargs = email_kwargs or {} if recipients and not getattr(recipients, '__iter__', False): @@ -203,6 +203,7 @@ class EmailNotificationModel(object): """ return generated template for email based on given type """ + import kallithea.lib.helpers as h base = 'email/' + self.email_types.get(type_, self.email_types[self.TYPE_DEFAULT]) + '.' + content_type email_template = self._tmpl_lookup.get_template(base) diff --git a/kallithea/model/repo.py b/kallithea/model/repo.py --- a/kallithea/model/repo.py +++ b/kallithea/model/repo.py @@ -33,7 +33,6 @@ import traceback from datetime import datetime import kallithea.lib.utils2 -from kallithea.lib import helpers as h from kallithea.lib.auth import HasRepoPermissionLevel, HasUserGroupPermissionLevel from kallithea.lib.exceptions import AttachedForksError from kallithea.lib.hooks import log_delete_repository @@ -110,6 +109,8 @@ class RepoModel(object): from tg import tmpl_context as c from tg.i18n import ugettext as _ + import kallithea.lib.helpers as h + _tmpl_lookup = app_globals.mako_lookup template = _tmpl_lookup.get_template('data_table/_dt_elements.html') @@ -129,6 +130,7 @@ class RepoModel(object): from tg import request from tg import tmpl_context as c + import kallithea.lib.helpers as h from kallithea.model.scm import ScmModel def repo_lnk(name, rtype, rstate, private, fork_of): @@ -153,6 +155,7 @@ class RepoModel(object): cs_cache.get('message')) def desc(desc): + import kallithea.lib.helpers as h return h.urlify_text(desc, truncate=80, stylize=c.visual.stylify_metalabels) def state(repo_state):