本文整理汇总了Python中indico.modules.users.User.first_name方法的典型用法代码示例。如果您正苦于以下问题:Python User.first_name方法的具体用法?Python User.first_name怎么用?Python User.first_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.users.User
的用法示例。
在下文中一共展示了User.first_name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _process_POST
# 需要导入模块: from indico.modules.users import User [as 别名]
# 或者: from indico.modules.users.User import first_name [as 别名]
def _process_POST(self):
if User.has_rows():
return redirect(url_for('misc.index'))
setup_form = BootstrapForm(request.form)
if not setup_form.validate():
flash(_("Some fields are invalid. Please, correct them and submit the form again."), 'error')
return redirect(url_for('bootstrap.index'))
# Creating new user
user = User()
user.first_name = to_unicode(setup_form.first_name.data)
user.last_name = to_unicode(setup_form.last_name.data)
user.affiliation = to_unicode(setup_form.affiliation.data)
user.email = to_unicode(setup_form.email.data)
user.is_admin = True
identity = Identity(provider='indico', identifier=setup_form.username.data, password=setup_form.password.data)
user.identities.add(identity)
db.session.add(user)
db.session.flush()
user.settings.set('timezone', Config.getInstance().getDefaultTimezone())
user.settings.set('lang', to_unicode(setup_form.language.data))
login_user(user, identity)
full_name = user.full_name # needed after the session closes
transaction.commit()
# Configuring server's settings
minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
minfo.setOrganisation(setup_form.affiliation.data)
minfo.setLang(setup_form.language.data)
message = get_template_module('bootstrap/flash_messages.html').bootstrap_success(name=full_name)
flash(Markup(message), 'success')
# Activate instance tracking
if setup_form.enable_tracking.data:
contact_name = setup_form.contact_name.data
contact_email = setup_form.contact_email.data
try:
register_instance(contact_name, contact_email)
except (HTTPError, ValueError) as err:
message = get_template_module('bootstrap/flash_messages.html').community_error(err=err)
category = 'error'
except Timeout:
message = get_template_module('bootstrap/flash_messages.html').community_timeout()
category = 'error'
except RequestException as exc:
message = get_template_module('bootstrap/flash_messages.html').community_exception(exc=exc)
category = 'error'
else:
message = get_template_module('bootstrap/flash_messages.html').community_success()
category = 'success'
flash(Markup(message), category)
return redirect(url_for('misc.index'))
示例2: user_create
# 需要导入模块: from indico.modules.users import User [as 别名]
# 或者: from indico.modules.users.User import first_name [as 别名]
def user_create(grant_admin):
"""Creates new user"""
user = User()
user_type = 'user' if not grant_admin else 'admin'
print()
name = prompt("First name")
surname = prompt("Last name")
affiliation = prompt("Affiliation")
print()
username = prompt("Enter username")
email = prompt_email()
if email is None:
return
password = prompt_pass()
if password is None:
return
user.first_name = to_unicode(name)
user.last_name = to_unicode(surname)
user.affiliation = to_unicode(affiliation)
user.email = email
user.is_admin = grant_admin
print_user_info(user)
if prompt_bool(cformat("%{yellow}Create the new {}?").format(user_type), default=True):
# TODO: adapt to new authentication system, create local identity with username/password
# user.identities.append(UserIdentity(..., identifier=username, password=password))
db.session.add(user)
transaction.commit()
success("New {} created successfully with ID: {}".format(user_type, user.id))
示例3: _create_user
# 需要导入模块: from indico.modules.users import User [as 别名]
# 或者: from indico.modules.users.User import first_name [as 别名]
def _create_user(id_, first_name=u'Guinea', last_name=u'Pig', rb_admin=False, admin=False, email=None, groups=None,
legacy=False):
user = User.get(id_)
if user:
return user.as_avatar if legacy else user
user = User()
user.id = id_
user.first_name = first_name
user.last_name = last_name
user.email = email or u'{}@example.com'.format(id_)
user.is_admin = admin
user.local_groups = {g.group for g in (groups or ())}
db.session.add(user)
db.session.flush()
if rb_admin:
rb_settings.acls.add_principal('admin_principals', user)
db.session.flush()
return user.as_avatar if legacy else user
示例4: _create_user
# 需要导入模块: from indico.modules.users import User [as 别名]
# 或者: from indico.modules.users.User import first_name [as 别名]
def _create_user(id_, name=u'Pig', surname=u'Guinea', rb_admin=False, email=None, groups=None):
user = User.get(id_)
if user:
return user.as_avatar
user = User()
user.id = id_
user.first_name = name
user.last_name = surname
user.email = email or u'{}@example.com'.format(id_)
user.local_groups = {g.group for g in (groups or ())}
db.session.add(user)
db.session.flush()
if rb_admin:
rb_settings.set('admin_principals', rb_settings.get('admin_principals') + [user.as_principal])
db.session.flush()
_users.add(user)
avatar = user.as_avatar
avatar.email = user.email
return avatar