Changeset - 247de7d8efb6
[Not reviewed]
default
0 5 0
Mads Kiilerich (mads) - 5 years ago 2020-10-30 14:56:50
mads@kiilerich.com
Grafted from: 91e38c29da0b
lib: move fmt_date to utils2 - less use of helpers in model
5 files changed with 15 insertions and 12 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/users.py
Show inline comments
 
@@ -44,7 +44,7 @@ from kallithea.lib.auth import AuthUser,
 
from kallithea.lib.base import BaseController, IfSshEnabled, render
 
from kallithea.lib.exceptions import DefaultUserException, UserCreationError, UserOwnsReposException
 
from kallithea.lib.utils import action_logger
 
from kallithea.lib.utils2 import datetime_to_time, generate_api_key, safe_int
 
from kallithea.lib.utils2 import datetime_to_time, fmt_date, generate_api_key, safe_int
 
from kallithea.lib.webutils import url
 
from kallithea.model import db, meta
 
from kallithea.model.api_key import ApiKeyModel
 
@@ -90,7 +90,7 @@ class UsersController(BaseController):
 
                "username": username(user.user_id, user.username),
 
                "firstname": webutils.escape(user.name),
 
                "lastname": webutils.escape(user.lastname),
 
                "last_login": h.fmt_date(user.last_login),
 
                "last_login": fmt_date(user.last_login),
 
                "last_login_raw": datetime_to_time(user.last_login),
 
                "active": h.boolicon(user.active),
 
                "admin": h.boolicon(user.admin),
kallithea/controllers/feed.py
Show inline comments
 
@@ -40,7 +40,7 @@ from kallithea.lib import webutils
 
from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
 
from kallithea.lib.base import BaseRepoController
 
from kallithea.lib.diffs import DiffProcessor
 
from kallithea.lib.utils2 import asbool, safe_int, safe_str, shorter
 
from kallithea.lib.utils2 import asbool, fmt_date, safe_int, safe_str, shorter
 

	
 

	
 
log = logging.getLogger(__name__)
 
@@ -58,7 +58,7 @@ class FeedController(BaseRepoController)
 

	
 
    def __get_desc(self, cs):
 
        desc_msg = [(_('%s committed on %s')
 
                     % (h.person(cs.author), h.fmt_date(cs.date))) + '<br/>']
 
                     % (h.person(cs.author), fmt_date(cs.date))) + '<br/>']
 
        # branches, tags, bookmarks
 
        for branch in cs.branches:
 
            desc_msg.append('branch: %s<br/>' % branch)
kallithea/lib/helpers.py
Show inline comments
 
@@ -38,7 +38,8 @@ from kallithea.lib.auth import HasPermis
 
from kallithea.lib.diffs import BIN_FILENODE, CHMOD_FILENODE, DEL_FILENODE, MOD_FILENODE, NEW_FILENODE, RENAMED_FILENODE
 
from kallithea.lib.markup_renderer import url_re
 
from kallithea.lib.pygmentsutils import get_custom_lexer
 
from kallithea.lib.utils2 import MENTIONS_REGEX, AttributeDict, age, asbool, credentials_filter, safe_bytes, safe_int, safe_str, shorter, time_to_datetime
 
from kallithea.lib.utils2 import (MENTIONS_REGEX, AttributeDict, age, asbool, credentials_filter, fmt_date, safe_bytes, safe_int, safe_str, shorter,
 
                                  time_to_datetime)
 
from kallithea.lib.vcs.backends.base import BaseChangeset, EmptyChangeset
 
from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError
 
#==============================================================================
 
@@ -80,6 +81,7 @@ assert HasRepoGroupPermissionLevel
 
assert HasRepoPermissionLevel
 
# from utils2
 
assert age
 
assert fmt_date
 
assert shorter
 
assert time_to_datetime
 
# from vcs
 
@@ -419,12 +421,6 @@ def show_id(cs):
 
        return raw_id
 

	
 

	
 
def fmt_date(date):
 
    if date:
 
        return date.strftime("%Y-%m-%d %H:%M:%S")
 
    return ""
 

	
 

	
 
def is_git(repository):
 
    if hasattr(repository, 'alias'):
 
        _type = repository.alias
kallithea/lib/utils2.py
Show inline comments
 
@@ -265,6 +265,12 @@ def age(prevdate, show_short_version=Fal
 
    return _('just now')
 

	
 

	
 
def fmt_date(date):
 
    if date:
 
        return date.strftime("%Y-%m-%d %H:%M:%S")
 
    return ""
 

	
 

	
 
def uri_filter(uri):
 
    """
 
    Removes user:password from given url string
kallithea/model/notification.py
Show inline comments
 
@@ -33,6 +33,7 @@ from tg import app_globals
 
from tg import tmpl_context as c
 
from tg.i18n import ugettext as _
 

	
 
from kallithea.lib.utils2 import fmt_date
 
from kallithea.model import db
 

	
 

	
 
@@ -102,7 +103,7 @@ class NotificationModel(object):
 
            headers['References'] = ' '.join('<%s>' % x for x in email_kwargs['threading'])
 

	
 
        # this is passed into template
 
        created_on = h.fmt_date(datetime.datetime.now())
 
        created_on = fmt_date(datetime.datetime.now())
 
        html_kwargs = {
 
                  'subject': subject,
 
                  'body': h.render_w_mentions(body, repo_name),
0 comments (0 inline, 0 general)