Example #1
0
    def make_description(self, notification, show_age=True):
        """
        Creates a human readable description based on properties
        of notification object
        """
        #alias
        _n = notification
        _map = {
            _n.TYPE_CHANGESET_COMMENT:
            _('%(user)s commented on changeset at %(when)s'),
            _n.TYPE_MESSAGE:
            _('%(user)s sent message at %(when)s'),
            _n.TYPE_MENTION:
            _('%(user)s mentioned you at %(when)s'),
            _n.TYPE_REGISTRATION:
            _('%(user)s registered in RhodeCode at %(when)s'),
            _n.TYPE_PULL_REQUEST:
            _('%(user)s opened new pull request at %(when)s'),
            _n.TYPE_PULL_REQUEST_COMMENT:
            _('%(user)s commented on pull request at %(when)s')
        }
        tmpl = _map[notification.type_]

        if show_age:
            when = h.age(notification.created_on)
        else:
            when = h.fmt_date(notification.created_on)

        return tmpl % dict(
            user=notification.created_by_user.username,
            when=when,
        )
Example #2
0
    def make_description(self, notification, show_age=True):
        """
        Creates a human readable description based on properties
        of notification object
        """

        _map = {
            notification.TYPE_CHANGESET_COMMENT: _('commented on commit'),
            notification.TYPE_MESSAGE: _('sent message'),
            notification.TYPE_MENTION: _('mentioned you'),
            notification.TYPE_REGISTRATION: _('registered in RhodeCode')
        }

        tmpl = "%(user)s %(action)s %(when)s"
        if show_age:
            when = h.age(notification.created_on)
        else:
            DTF = lambda d: datetime.datetime.strftime(d, DATETIME_FORMAT)
            when = DTF(notification.created_on)

        data = dict(
            user=notification.created_by_user.username,
            action=_map[notification.type_], when=when,
        )
        return tmpl % data
Example #3
0
    def make_description(self, notification, show_age=True):
        """
        Creates a human readable description based on properties
        of notification object
        """

        _map = {
            notification.TYPE_CHANGESET_COMMENT: _('commented on commit'),
            notification.TYPE_MESSAGE: _('sent message'),
            notification.TYPE_MENTION: _('mentioned you'),
            notification.TYPE_REGISTRATION: _('registered in RhodeCode')
        }

        tmpl = "%(user)s %(action)s %(when)s"
        if show_age:
            when = h.age(notification.created_on)
        else:
            DTF = lambda d: datetime.datetime.strftime(d, DATETIME_FORMAT)
            when = DTF(notification.created_on)

        data = dict(
            user=notification.created_by_user.username,
            action=_map[notification.type_],
            when=when,
        )
        return tmpl % data
Example #4
0
    def make_description(self, notification, show_age=True):
        """
        Creates a human readable description based on properties
        of notification object
        """
        #alias
        _n = notification
        _map = {
            _n.TYPE_CHANGESET_COMMENT: _('commented on commit at %(when)s'),
            _n.TYPE_MESSAGE: _('sent message at %(when)s'),
            _n.TYPE_MENTION: _('mentioned you at %(when)s'),
            _n.TYPE_REGISTRATION: _('registered in RhodeCode at %(when)s'),
            _n.TYPE_PULL_REQUEST: _('opened new pull request at %(when)s'),
            _n.TYPE_PULL_REQUEST_COMMENT: _('commented on pull request at %(when)s')
        }

        # action == _map string
        tmpl = "%(user)s %(action)s "
        if show_age:
            when = h.age(notification.created_on)
        else:
            when = h.fmt_date(notification.created_on)

        data = dict(
            user=notification.created_by_user.username,
            action=_map[notification.type_]
        )
        return (tmpl % data) % {'when': when}
Example #5
0
    def edit_form(self, gist_id, format='html'):
        """GET /admin/gists/gist_id/edit: Form to edit an existing item"""
        # url('edit_gist', gist_id=ID)
        self._add_gist_to_context(gist_id)

        owner = c.gist.gist_owner == c.rhodecode_user.user_id
        if not (h.HasPermissionAny('hg.admin')() or owner):
            raise HTTPForbidden()

        try:
            c.file_last_commit, c.files = GistModel().get_gist_files(gist_id)
        except VCSError:
            log.exception("Exception in gist edit")
            raise HTTPNotFound()

        if c.gist.gist_expires == -1:
            expiry = _('never')
        else:
            # this cannot use timeago, since it's used in select2 as a value
            expiry = h.age(h.time_to_datetime(c.gist.gist_expires))
        self.__load_defaults(extra_values=('0',
                                           _('%(expiry)s - current value') % {
                                               'expiry': expiry
                                           }))
        return render('admin/gists/edit.html')
Example #6
0
    def make_description(self, notification, show_age=True):
        """
        Creates a human readable description based on properties
        of notification object
        """
        #alias
        _n = notification
        _map = {
            _n.TYPE_CHANGESET_COMMENT: _('%(user)s commented on changeset at %(when)s'),
            _n.TYPE_MESSAGE: _('%(user)s sent message at %(when)s'),
            _n.TYPE_MENTION: _('%(user)s mentioned you at %(when)s'),
            _n.TYPE_REGISTRATION: _('%(user)s registered in RhodeCode at %(when)s'),
            _n.TYPE_PULL_REQUEST: _('%(user)s opened new pull request at %(when)s'),
            _n.TYPE_PULL_REQUEST_COMMENT: _('%(user)s commented on pull request at %(when)s')
        }
        tmpl = _map[notification.type_]

        if show_age:
            when = h.age(notification.created_on)
        else:
            when = h.fmt_date(notification.created_on)

        return tmpl % dict(
            user=notification.created_by_user.username,
            when=when,
            )
Example #7
0
    def make_description(self, notification, show_age=True):
        """
        Creates a human readable description based on properties
        of notification object
        """

        _map = {
            notification.TYPE_CHANGESET_COMMENT: [
                _('%(user)s commented on commit %(date_or_age)s'),
                _('%(user)s commented on commit at %(date_or_age)s'),
            ],
            notification.TYPE_MESSAGE: [
                _('%(user)s sent message %(date_or_age)s'),
                _('%(user)s sent message at %(date_or_age)s'),
            ],
            notification.TYPE_MENTION: [
                _('%(user)s mentioned you %(date_or_age)s'),
                _('%(user)s mentioned you at %(date_or_age)s'),
            ],
            notification.TYPE_REGISTRATION: [
                _('%(user)s registered in RhodeCode %(date_or_age)s'),
                _('%(user)s registered in RhodeCode at %(date_or_age)s'),
            ],
            notification.TYPE_PULL_REQUEST: [
                _('%(user)s opened new pull request %(date_or_age)s'),
                _('%(user)s opened new pull request at %(date_or_age)s'),
            ],
            notification.TYPE_PULL_REQUEST_COMMENT: [
                _('%(user)s commented on pull request %(date_or_age)s'),
                _('%(user)s commented on pull request at %(date_or_age)s'),
            ],
        }

        templates = _map[notification.type_]

        if show_age:
            template = templates[0]
            date_or_age = h.age(notification.created_on)
        else:
            template = templates[1]
            date_or_age = h.format_date(notification.created_on)

        return template % {
            'user': notification.created_by_user.username,
            'date_or_age': date_or_age,
        }