本文整理汇总了Python中pylons.i18n.translation._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: pwchange
def pwchange(self, userid):
"""Reset a user password"""
user = self._get_user(userid)
if not user:
abort(404)
c.form = ChangePasswordForm(request.POST, csrf_context=session)
if request.POST and c.form.validate():
if user.local and not user.is_superadmin:
user.set_password(c.form.password1.data)
Session.add(user)
Session.commit()
flash(_('The account password for %(name)s has been reset')
% dict(name=user.username))
info = PASSWORDCHANGE_MSG % dict(u=user.username)
audit_log(c.user.username,
2, unicode(info), request.host,
request.remote_addr, now())
else:
if user.is_superadmin:
flash(_('Admin accounts can not be modified via the web'))
else:
flash(_('This is an external account, use'
' external system to reset the password'))
redirect(url('account-detail', userid=user.id))
c.id = userid
c.username = user.username
c.posturl = 'accounts-pw-change'
return render('/accounts/pwchange.html')
开发者ID:TetraAsh,项目名称:baruwa2,代码行数:28,代码来源:accounts.py
示例2: delete
def delete(self, userid):
"""/accounts/delete/id"""
user = self._get_user(userid)
if not user:
abort(404)
c.form = EditUserForm(request.POST, user, csrf_context=session)
del c.form.domains
if request.POST and c.form.validate():
username = user.username
user_id = unicode(user.id)
Session.delete(user)
Session.commit()
update_serial.delay()
flash(_('The account has been deleted'))
info = DELETEACCOUNT_MSG % dict(u=username)
audit_log(c.user.username,
4, unicode(info), request.host,
request.remote_addr, now())
if userid == user_id:
redirect(url('/logout'))
redirect(url(controller='accounts', action='index'))
else:
flash_info(_('The account: %(a)s and all associated data'
' will be deleted, This action is not reversible.') %
dict(a=user.username))
c.fields = FORM_FIELDS
c.id = userid
return render('/accounts/delete.html')
开发者ID:TetraAsh,项目名称:baruwa2,代码行数:30,代码来源:accounts.py
示例3: _get_node_history
def _get_node_history(self, cs, f_path):
changesets = cs.get_file_history(f_path)
hist_l = []
changesets_group = ([], _("Changesets"))
branches_group = ([], _("Branches"))
tags_group = ([], _("Tags"))
for chs in changesets:
n_desc = 'r%s:%s' % (chs.revision, chs.short_id)
changesets_group[0].append((chs.raw_id, n_desc,))
hist_l.append(changesets_group)
for name, chs in c.rhodecode_repo.branches.items():
#chs = chs.split(':')[-1]
branches_group[0].append((chs, name),)
hist_l.append(branches_group)
for name, chs in c.rhodecode_repo.tags.items():
#chs = chs.split(':')[-1]
tags_group[0].append((chs, name),)
hist_l.append(tags_group)
return hist_l
开发者ID:lmamsen,项目名称:rhodecode,代码行数:25,代码来源:files.py
示例4: comment
def comment(self, repo_name, revision):
status = request.POST.get('changeset_status')
change_status = request.POST.get('change_changeset_status')
text = request.POST.get('text')
if status and change_status:
text = text or (_('Status change -> %s')
% ChangesetStatus.get_status_lbl(status))
c.co = comm = ChangesetCommentsModel().create(
text=text,
repo=c.rhodecode_db_repo.repo_id,
user=c.rhodecode_user.user_id,
revision=revision,
f_path=request.POST.get('f_path'),
line_no=request.POST.get('line'),
status_change=(ChangesetStatus.get_status_lbl(status)
if status and change_status else None)
)
# get status if set !
if status and change_status:
# if latest status was from pull request and it's closed
# disallow changing status !
# dont_allow_on_closed_pull_request = True !
try:
ChangesetStatusModel().set_status(
c.rhodecode_db_repo.repo_id,
status,
c.rhodecode_user.user_id,
comm,
revision=revision,
dont_allow_on_closed_pull_request=True
)
except StatusChangeOnClosedPullRequestError:
log.error(traceback.format_exc())
msg = _('Changing status on a changeset associated with '
'a closed pull request is not allowed')
h.flash(msg, category='warning')
return redirect(h.url('changeset_home', repo_name=repo_name,
revision=revision))
action_logger(self.rhodecode_user,
'user_commented_revision:%s' % revision,
c.rhodecode_db_repo, self.ip_addr, self.sa)
Session().commit()
if not request.environ.get('HTTP_X_PARTIAL_XHR'):
return redirect(h.url('changeset_home', repo_name=repo_name,
revision=revision))
#only ajax below
data = {
'target_id': h.safeid(h.safe_unicode(request.POST.get('f_path'))),
}
if comm:
data.update(comm.get_dict())
data.update({'rendered_text':
render('changeset/changeset_comment_block.html')})
return data
开发者ID:jeffjirsa,项目名称:rhodecode,代码行数:60,代码来源:changeset.py
示例5: repo_check
def repo_check(self, repo_name):
c.repo = repo_name
task_id = request.GET.get('task_id')
if task_id and task_id not in ['None']:
from kallithea import CELERY_ON
from celery.result import AsyncResult
if CELERY_ON:
task = AsyncResult(task_id)
if task.failed():
raise HTTPInternalServerError(task.traceback)
repo = Repository.get_by_repo_name(repo_name)
if repo and repo.repo_state == Repository.STATE_CREATED:
if repo.clone_uri:
clone_uri = repo.clone_uri_hidden
h.flash(_('Created repository %s from %s')
% (repo.repo_name, clone_uri), category='success')
else:
repo_url = h.link_to(repo.repo_name,
h.url('summary_home',
repo_name=repo.repo_name))
fork = repo.fork
if fork:
fork_name = fork.repo_name
h.flash(h.literal(_('Forked repository %s as %s')
% (fork_name, repo_url)), category='success')
else:
h.flash(h.literal(_('Created repository %s') % repo_url),
category='success')
return {'result': True}
return {'result': False}
开发者ID:zhumengyuan,项目名称:kallithea,代码行数:32,代码来源:repos.py
示例6: enqueue
def enqueue(self):
try:
data = json.load(request.environ['wsgi.input'])
except ValueError:
log.error('ENQUEUE: Could not parse JSON data')
abort(400, _('Malformed JSON data'))
files = data.get('files')
if not (files and len(files) > 0):
log.error('ENQUEUE: No files specified')
abort(400, _('No files specified'))
jukebox = Jukebox()
for file in files:
if not file:
log.error('ENQUEUE: Skipping empty file')
abort(400, _('Missing file name'))
try:
jukebox.queue(file.encode('utf8'))
except QueueFull:
log.error('ENQUEUE: Full, aborting')
response.status = "409 %s" % _('The queue is full')
return
abort(204) # no content
开发者ID:ahmadiga,项目名称:fookebox,代码行数:29,代码来源:jukebox.py
示例7: update_perms
def update_perms(self, group_name):
"""
Update permissions for given repository group
:param group_name:
"""
c.repo_group = RepoGroupModel()._get_repo_group(group_name)
valid_recursive_choices = ['none', 'repos', 'groups', 'all']
form_result = RepoGroupPermsForm(valid_recursive_choices)().to_python(request.POST)
if not c.authuser.is_admin:
if self._revoke_perms_on_yourself(form_result):
msg = _('Cannot revoke permission for yourself as admin')
h.flash(msg, category='warning')
return redirect(url('edit_repo_group_perms', group_name=group_name))
recursive = form_result['recursive']
# iterate over all members(if in recursive mode) of this groups and
# set the permissions !
# this can be potentially heavy operation
RepoGroupModel()._update_permissions(c.repo_group,
form_result['perms_new'],
form_result['perms_updates'],
recursive)
#TODO: implement this
#action_logger(self.authuser, 'admin_changed_repo_permissions',
# repo_name, self.ip_addr, self.sa)
Session().commit()
h.flash(_('Repository Group permissions updated'), category='success')
return redirect(url('edit_repo_group_perms', group_name=group_name))
开发者ID:zhumengyuan,项目名称:kallithea,代码行数:29,代码来源:repo_groups.py
示例8: repo_refs_data
def repo_refs_data(self, repo_name):
repo = Repository.get_by_repo_name(repo_name).scm_instance
res = []
_branches = repo.branches.items()
if _branches:
res.append({
'text': _('Branch'),
'children': [{'id': rev, 'text': name, 'type': 'branch'} for name, rev in _branches]
})
_tags = repo.tags.items()
if _tags:
res.append({
'text': _('Tag'),
'children': [{'id': rev, 'text': name, 'type': 'tag'} for name, rev in _tags]
})
_bookmarks = repo.bookmarks.items()
if _bookmarks:
res.append({
'text': _('Bookmark'),
'children': [{'id': rev, 'text': name, 'type': 'book'} for name, rev in _bookmarks]
})
data = {
'more': False,
'results': res
}
return data
开发者ID:msabramo,项目名称:kallithea,代码行数:26,代码来源:home.py
示例9: make_description
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
开发者ID:elfixit,项目名称:rhodecode,代码行数:25,代码来源:notification.py
示例10: getInitDetail
def getInitDetail(self, params , user=None):
'''
to complete the token normalisation, the response of the initialiastion
should be build by the token specific method, the getInitDetails
'''
response_detail = {}
info = self.getInfo()
response_detail.update(info)
response_detail['serial'] = self.getSerial()
tok_type = self.type.lower()
otpkey = None
if 'otpkey' in info:
otpkey = info.get('otpkey')
if otpkey != None:
response_detail["otpkey"] = {
"order" : '1',
"description": _("OTP seed"),
"value" : "seed://%s" % otpkey,
"img" : create_img(otpkey, width=200),
}
try:
p = {}
p.update(params)
p['otpkey'] = otpkey
p['serial'] = self.getSerial()
# label
goo_url = create_google_authenticator(p, user=user,
context=self.context)
response_detail["googleurl"] = {
"order" : '0',
"description": _("OTPAuth Url"),
"value" : goo_url,
"img" : create_img(goo_url, width=250)
}
except NoOtpAuthTokenException as exx:
log.warning("%r" % exx)
if user is not None:
try:
oath_url = create_oathtoken_url(user.login, user.realm,
otpkey, tok_type,
serial=self.getSerial(),
context=self.context)
response_detail["oathurl"] = {
"order" : '2',
"description" : _("URL for OATH token"),
"value" : oath_url,
"img" : create_img(oath_url, width=250)
}
except Exception as ex:
log.info('failed to set oath or google url: %r' % ex)
return response_detail
开发者ID:rogerwangzy,项目名称:LinOTP,代码行数:60,代码来源:hmactoken.py
示例11: doEdit
def doEdit(self):
member = self.lmf.getUser(session['identity'])
try:
language = Session.query(Preferences).filter(and_(Preferences.uidNumber == member.uidNumber, Preferences.key == 'language')).one()
language.last_change = datetime.now()
language.value = request.params['language']
session['language'] = language.value
session['flash'] = _('Changes saved!')
session['flash_class'] = 'success'
except NoResultFound:
pref = Preferences()
pref.uidNumber = member.uidNumber
pref.last_change = datetime.now().date()
pref.key = 'language'
pref.value = request.params['language']
Session.add(pref)
session['language'] = request.params['language']
session['flash'] = _('Changes saved!')
session['flash_class'] = 'success'
except:
session['flash'] = _('Unknown error, nothing saved')
session['flash_class'] = 'error'
Session.commit()
session.save()
redirect(url(controller='preferences', action='edit'))
开发者ID:ot4me,项目名称:mematool,代码行数:31,代码来源:preferences.py
示例12: lnk
def lnk(rev, repo_name):
if isinstance(rev, BaseChangeset) or isinstance(rev, AttributeDict):
lazy_cs = True
if getattr(rev, 'op', None) and getattr(rev, 'ref_name', None):
lazy_cs = False
lbl = '?'
if rev.op == 'delete_branch':
lbl = '%s' % _('Deleted branch: %s') % rev.ref_name
title = ''
elif rev.op == 'tag':
lbl = '%s' % _('Created tag: %s') % rev.ref_name
title = ''
_url = '#'
else:
lbl = '%s' % (rev.short_id[:8])
_url = url('changeset_home', repo_name=repo_name,
revision=rev.raw_id)
title = tooltip(rev.message)
else:
## changeset cannot be found/striped/removed etc.
lbl = ('%s' % rev)[:12]
_url = '#'
title = _('Changeset not found')
if parse_cs:
return link_to(lbl, _url, title=title, class_='tooltip')
return link_to(lbl, _url, raw_id=rev.raw_id, repo_name=repo_name,
class_='lazy-cs' if lazy_cs else '')
开发者ID:greenboxindonesia,项目名称:rhodecode,代码行数:28,代码来源:helpers.py
示例13: ldap_settings
def ldap_settings(self):
"""POST ldap create and store ldap settings"""
_form = LdapSettingsForm([x[0] for x in self.tls_reqcert_choices],
[x[0] for x in self.search_scope_choices],
[x[0] for x in self.tls_kind_choices])()
try:
form_result = _form.to_python(dict(request.POST))
try:
for k, v in form_result.items():
if k.startswith('ldap_'):
setting = RhodeCodeSettings.get_by_name(k)
setting.app_settings_value = v
self.sa.add(setting)
self.sa.commit()
h.flash(_('Ldap settings updated successfully'),
category='success')
except (DatabaseError,):
raise
except LdapImportError:
h.flash(_('Unable to activate ldap. The "python-ldap" library '
'is missing.'), category='warning')
except formencode.Invalid, errors:
e = errors.error_dict or {}
return htmlfill.render(
render('admin/ldap/ldap.html'),
defaults=errors.value,
errors=e,
prefix_error=False,
encoding="UTF-8")
开发者ID:lmamsen,项目名称:rhodecode,代码行数:35,代码来源:ldap_settings.py
示例14: _get_node_history
def _get_node_history(self, cs, f_path, changesets=None):
if changesets is None:
changesets = cs.get_file_history(f_path)
hist_l = []
changesets_group = ([], _("Changesets"))
branches_group = ([], _("Branches"))
tags_group = ([], _("Tags"))
_hg = cs.repository.alias == 'hg'
for chs in changesets:
_branch = '(%s)' % chs.branch if _hg else ''
n_desc = 'r%s:%s %s' % (chs.revision, chs.short_id, _branch)
changesets_group[0].append((chs.raw_id, n_desc,))
hist_l.append(changesets_group)
for name, chs in c.rhodecode_repo.branches.items():
branches_group[0].append((chs, name),)
hist_l.append(branches_group)
for name, chs in c.rhodecode_repo.tags.items():
tags_group[0].append((chs, name),)
hist_l.append(tags_group)
return hist_l
开发者ID:yujiro,项目名称:rhodecode,代码行数:25,代码来源:files.py
示例15: delete
def delete(self, user, cur_user=None):
if not cur_user:
cur_user = getattr(get_current_authuser(), 'username', None)
user = self._get_user(user)
if user.username == User.DEFAULT_USER:
raise DefaultUserException(
_(u"You can't remove this user since it's"
" crucial for entire application")
)
if user.repositories:
repos = [x.repo_name for x in user.repositories]
raise UserOwnsReposException(
_(u'User "%s" still owns %s repositories and cannot be '
'removed. Switch owners or remove those repositories: %s')
% (user.username, len(repos), ', '.join(repos))
)
if user.repo_groups:
repogroups = [x.group_name for x in user.repo_groups]
raise UserOwnsReposException(
_(u'User "%s" still owns %s repository groups and cannot be '
'removed. Switch owners or remove those repository groups: %s')
% (user.username, len(repogroups), ', '.join(repogroups))
)
if user.user_groups:
usergroups = [x.users_group_name for x in user.user_groups]
raise UserOwnsReposException(
_(u'User "%s" still owns %s user groups and cannot be '
'removed. Switch owners or remove those user groups: %s')
% (user.username, len(usergroups), ', '.join(usergroups))
)
self.sa.delete(user)
from kallithea.lib.hooks import log_delete_user
log_delete_user(user.get_dict(), cur_user)
开发者ID:msabramo,项目名称:kallithea,代码行数:35,代码来源:user.py
示例16: new
def new(self):
"""Render new record form and redirect to save."""
flash_message(_("success message"), "success")
flash_message(_("warning message"), "warning")
flash_message(_("error message"), "error")
flash_message(_("notice message"), "notice")
return render('/derived/rock/new.mako')
开发者ID:lazaret,项目名称:archeobases,代码行数:7,代码来源:rock.py
示例17: delete_perms
def delete_perms(self, id):
"""
DELETE an existing repository group permission user
:param group_name:
"""
try:
obj_type = request.POST.get('obj_type')
obj_id = None
if obj_type == 'user':
obj_id = safe_int(request.POST.get('user_id'))
elif obj_type == 'user_group':
obj_id = safe_int(request.POST.get('user_group_id'))
if not c.authuser.is_admin:
if obj_type == 'user' and c.authuser.user_id == obj_id:
msg = _('Cannot revoke permission for yourself as admin')
h.flash(msg, category='warning')
raise Exception('revoke admin permission on self')
if obj_type == 'user':
UserGroupModel().revoke_user_permission(user_group=id,
user=obj_id)
elif obj_type == 'user_group':
UserGroupModel().revoke_user_group_permission(target_user_group=id,
user_group=obj_id)
Session().commit()
except Exception:
log.error(traceback.format_exc())
h.flash(_('An error occurred during revoking of permission'),
category='error')
raise HTTPInternalServerError()
开发者ID:msabramo,项目名称:kallithea,代码行数:31,代码来源:user_groups.py
示例18: delete
def delete(self, user, cur_user=None):
if not cur_user:
cur_user = getattr(get_current_rhodecode_user(), "username", None)
user = self._get_user(user)
try:
if user.username == "default":
raise DefaultUserException(
_(u"You can't remove this user since it's" " crucial for entire application")
)
if user.repositories:
repos = [x.repo_name for x in user.repositories]
raise UserOwnsReposException(
_(
u'user "%s" still owns %s repositories and cannot be '
"removed. Switch owners or remove those repositories. %s"
)
% (user.username, len(repos), ", ".join(repos))
)
self.sa.delete(user)
from rhodecode.lib.hooks import log_delete_user
log_delete_user(user.get_dict(), cur_user)
except Exception:
log.error(traceback.format_exc())
raise
开发者ID:nzinfo,项目名称:rhodecode,代码行数:27,代码来源:user.py
示例19: repo_public_journal
def repo_public_journal(self, repo_name):
"""
Set's this repository to be visible in public journal,
in other words assing default user to follow this repo
:param repo_name:
"""
cur_token = request.POST.get('auth_token')
token = get_token()
if cur_token == token:
try:
repo_id = Repository.get_by_repo_name(repo_name).repo_id
user_id = User.get_by_username('default').user_id
self.scm_model.toggle_following_repo(repo_id, user_id)
h.flash(_('Updated repository visibility in public journal'),
category='success')
Session.commit()
except:
h.flash(_('An error occurred during setting this'
' repository in public journal'),
category='error')
else:
h.flash(_('Token mismatch'), category='error')
return redirect(url('edit_repo', repo_name=repo_name))
开发者ID:elfixit,项目名称:rhodecode,代码行数:26,代码来源:repos.py
示例20: update_perm
def update_perm(self, id):
"""PUT /users_perm/id: Update an existing item"""
# url('user_perm', id=ID, method='put')
grant_perm = request.POST.get('create_repo_perm', False)
user_model = UserModel()
if grant_perm:
perm = Permission.get_by_key('hg.create.none')
user_model.revoke_perm(id, perm)
perm = Permission.get_by_key('hg.create.repository')
user_model.grant_perm(id, perm)
h.flash(_("Granted 'repository create' permission to user"),
category='success')
Session.commit()
else:
perm = Permission.get_by_key('hg.create.repository')
user_model.revoke_perm(id, perm)
perm = Permission.get_by_key('hg.create.none')
user_model.grant_perm(id, perm)
h.flash(_("Revoked 'repository create' permission to user"),
category='success')
Session.commit()
return redirect(url('edit_user', id=id))
开发者ID:elfixit,项目名称:rhodecode,代码行数:26,代码来源:users.py
注:本文中的pylons.i18n.translation._函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论