本文整理汇总了Python中rogerthat.models.UserProfile.language方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.language方法的具体用法?Python UserProfile.language怎么用?Python UserProfile.language使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rogerthat.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.language方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: trans_create
# 需要导入模块: from rogerthat.models import UserProfile [as 别名]
# 或者: from rogerthat.models.UserProfile import language [as 别名]
def trans_create():
rogerthat_profile = get_service_or_user_profile(users.User(email))
if rogerthat_profile and isinstance(rogerthat_profile, ServiceProfile):
from rogerthat.bizz.service import AppFailedToCreateUserProfileWithExistingServiceException
raise AppFailedToCreateUserProfileWithExistingServiceException(email)
user_profile = get_user_profile(app_user, cached=False)
is_new_profile = False
if not user_profile:
deactivated_user_profile = get_deactivated_user_profile(app_user)
if deactivated_user_profile:
deferred.defer(reactivate_user_profile, deactivated_user_profile, app_user, _transactional=True)
ActivationLog(timestamp=now(), email=app_user.email(), mobile=None, description="Reactivate user account by registering a paper loyalty card").put()
else:
is_new_profile = True
avatar, image = _create_new_avatar(app_user, add_trial_overlay=False)
user_profile = UserProfile(parent=parent_key(app_user), key_name=app_user.email())
user_profile.name = name
user_profile.language = language
user_profile.avatarId = avatar.key().id()
user_profile.app_id = app_id
_calculateAndSetAvatarHash(user_profile, image)
pp = ProfilePointer(key=db.Key.from_path(ProfilePointer.kind(), user_code))
pp.user = app_user
pp.short_url_id = short_url_id
if is_new_profile:
put_and_invalidate_cache(user_profile, pp, ProfilePointer.create(app_user))
else:
pp.put()
示例2: get_profile_for_google_user
# 需要导入模块: from rogerthat.models import UserProfile [as 别名]
# 或者: from rogerthat.models.UserProfile import language [as 别名]
def get_profile_for_google_user(email, language, name):
user = users.User(email)
user_profile = get_user_profile(user)
if not user_profile:
user_profile = UserProfile(parent=parent_key(user), key_name=user.email())
user_profile.name = name if name else user.email()
user_profile.language = language
user_profile.version = 1
put_and_invalidate_cache(user_profile, ProfilePointer.create(user))
update_friends(user_profile)
return user_profile
示例3: trans_create
# 需要导入模块: from rogerthat.models import UserProfile [as 别名]
# 或者: from rogerthat.models.UserProfile import language [as 别名]
def trans_create(avatar_image):
azzert(not get_user_profile(app_user, cached=False))
avatar, image = _create_new_avatar(app_user, False, avatar_image)
user_profile = UserProfile(parent=parent_key(app_user), key_name=app_user.email())
user_profile.name = name
user_profile.language = language
user_profile.avatarId = avatar.key().id()
user_profile.app_id = get_app_id_from_app_user(app_user)
user_profile.owncloud_password = owncloud_password
if tos_version:
user_profile.tos_version = tos_version
if consent_push_notifications_shown:
user_profile.consent_push_notifications_shown = True
_calculateAndSetAvatarHash(user_profile, image)
put_and_invalidate_cache(user_profile, ProfilePointer.create(app_user), ProfileHashIndex.create(app_user))
return user_profile
示例4: post
# 需要导入模块: from rogerthat.models import UserProfile [as 别名]
# 或者: from rogerthat.models.UserProfile import language [as 别名]
def post(self):
from rogerthat.pages.shortner import get_short_url_by_code
from rogerthat.service.api import friends as service_api_friends
version = self.request.get("version", None)
install_id = self.request.get("install_id", None)
registration_time = self.request.get("registration_time", None)
device_id = self.request.get("device_id", None)
registration_id = self.request.get("registration_id", None)
qr_url = self.request.get("qr_url", None)
signature = self.request.get("signature", None)
language = self.request.get("language", None)
country = self.request.get("country", None)
app_id = self.request.get("app_id", App.APP_ID_ROGERTHAT)
use_xmpp_kick_channel = self.request.get('use_xmpp_kick', 'true') == 'true'
GCM_registration_id = self.request.get('GCM_registration_id', '')
if '-' in language:
language = get_iso_lang(language.lower())
elif language and country:
language = '%s_%s' % (language, country)
server_settings = get_server_settings()
calculated_signature = sha256_hex(version + " " + install_id + " " + registration_time + " " + device_id + " " + \
registration_id + " " + qr_url + base64.b64decode(server_settings.registrationMainSignature.encode("utf8")))
try:
if signature.upper() != calculated_signature.upper():
logging.error("Invalid request signature.")
self.response.set_status(500)
return
app = _verify_app_id(app_id)
azzert(app is not None, "app_id is not found")
bizz_check(install_id and qr_url, u"Could not validate QR code")
installation = Installation.get_by_key_name(install_id)
if not installation:
platform = self.request.get("platform", None)
if platform == "android":
mobile_type = Mobile.TYPE_ANDROID_HTTP
elif platform == "iphone":
if use_xmpp_kick_channel:
mobile_type = Mobile.TYPE_IPHONE_HTTP_XMPP_KICK
else:
mobile_type = Mobile.TYPE_IPHONE_HTTP_APNS_KICK
elif platform == "windows_phone":
mobile_type = Mobile.TYPE_WINDOWS_PHONE
else:
logging.error("Unknown platform: %s" % platform)
self.response.set_status(500)
return
now_ = now()
installation = Installation(key_name=install_id, version=version, platform=mobile_type, timestamp=now_, app_id=app_id)
installation_log = InstallationLog(parent=installation, timestamp=now_,
description="Installed with language %s" % language)
installation_log_app_id = InstallationLog(parent=installation, timestamp=now_,
description="Installed with app_id: %s" % app_id)
put_and_invalidate_cache(installation, installation_log, installation_log_app_id)
InstallationLog(parent=installation, timestamp=now(),
description="Creating qr based profile & validating registration request. Language: %s, QR url: %s" % (language, qr_url)).put()
m = re.match('(.*)/(M|S)/(.*)', qr_url)
bizz_check(m, u"Could not validate QR code")
entry_point = m.group(2)
code = m.group(3)
bizz_check(entry_point == "S", u"Could not validate QR code")
su = get_short_url_by_code(code)
bizz_check(su, u"Could not validate QR code")
logging.debug("register_via_qr qr_url: %s", qr_url)
logging.debug("register_via_qr su.full: %s", su.full)
match = re.match("^/q/s/(.+)/(\\d+)$", su.full)
bizz_check(match, u"Could not validate QR code")
user_code = match.group(1)
service_profile = get_service_profile_via_user_code(user_code)
bizz_check(service_profile, u"Could not validate QR code")
service_user = service_profile.user
sid = int(match.group(2))
service_interaction_def = get_service_interaction_def(service_user, int(sid))
service_identity_user = create_service_identity_user(service_user, service_interaction_def.service_identity)
service_identity = get_identity_from_service_identity_user(service_identity_user)
svc_profile = get_service_profile(service_user)
logging.debug("register_via_qr service_identity_user: %s", service_identity_user)
human_user = users.User(u"user%[email protected]" % uuid.uuid4().get_hex())
app_user = create_app_user(human_user, app_id)
from rogerthat.bizz.profile import _create_new_avatar
avatar, _ = _create_new_avatar(app_user, add_trial_overlay=False)
user_profile = UserProfile(parent=parent_key(app_user), key_name=app_user.email())
#.........这里部分代码省略.........