本文整理汇总了Python中models.profile.Profile.get_profile_by_application_user_id方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.get_profile_by_application_user_id方法的具体用法?Python Profile.get_profile_by_application_user_id怎么用?Python Profile.get_profile_by_application_user_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.profile.Profile
的用法示例。
在下文中一共展示了Profile.get_profile_by_application_user_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import get_profile_by_application_user_id [as 别名]
def get(self, artist_id):
# artist_id may be a profile_unique_name or an application_user_id
profile_obj = Profile.get_profile_by_profile_unique_name(artist_id)
if profile_obj is not None:
application_user_id = profile_obj.application_user_id
user_obj = User.get_user_by_application_user_id(application_user_id)
if user_obj is None:
# TODO : All profiles should have a user associated with them. Log or handle the event where there is no User associated with a profile.
# There is no user associated with the profile!
pass
else:
user_obj = User.get_user_by_application_user_id(artist_id)
if user_obj is not None:
profile_obj = Profile.get_profile_by_application_user_id(user_obj.application_user_id)
if user_obj is not None:
self.template_values['user_exists'] = True
self.template_values['artist_name'] = user_obj.first_name + ' ' + user_obj.last_name
if profile_obj is not None:
self.template_values['profile_unique_name'] = profile_obj.profile_unique_name
if profile_obj.bio is not None and not re.match(r"^\s*$", profile_obj.bio):
self.template_values['profile_bio'] = profile_obj.bio
if profile_obj.profile_picture is not None:
self.template_values['profile_picture'] = profile_obj.profile_picture
art_objs = Art.get_art(user_obj.application_user_id)
art_list = list()
for art_obj in art_objs:
art_list.append({'art_obj': art_obj})
self.template_values['art_list'] = art_list
self.template_values['artist_image_count'] = len(self.template_values['art_list'])
else:
self.template_values['user_exists'] = False
template = self.get_template('templates/artist_content.html')
self.response.write(template.render(self.template_values))
示例2: __init__
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import get_profile_by_application_user_id [as 别名]
def __init__(self, request=None, response=None):
super(BasePageHandler, self).__init__(request, response)
self.LogInOutURL = users.create_logout_url('/')
self.template_values = {}
self.application_user = None
self.google_user = None
self.logged_in = None
self.redirected = False
google_user = users.get_current_user()
if google_user is not None:
try:
Visitor.add_or_get_current_user_as_visitor()
except:
# Simply ignore failures to add the google_user object as a Visitor to our model for now:
pass
self.google_user = google_user
self.logged_in = True
google_user_id = google_user.user_id()
application_user = User.get_user_by_google_user_id(google_user_id)
if application_user is not None:
self.application_user = application_user
display_user_name = application_user.first_name + ' ' + application_user.last_name
self.template_values['display_user_name'] = display_user_name
user_profile = Profile.get_profile_by_application_user_id(application_user.application_user_id)
user_page_url = self.request.application_url
if not re.match(r"^.*/$", user_page_url):
user_page_url += '/'
if user_profile is not None:
user_page_url += urllib.quote(str(user_profile.profile_unique_display_name), safe='')
else:
user_page_url += str(application_user.application_user_id)
self.template_values['user_page_url'] = user_page_url
else:
if google_user.email():
display_user_name = google_user.email()
elif google_user.nickname():
display_user_name = google_user.nickname()
else:
display_user_name = 'Sweet Vision User'
self.template_values['display_user_name'] = display_user_name
else:
self.logged_in = False
self.LogInOutURL = users.create_login_url('/')
self.template_values['LogInOutURL'] = self.LogInOutURL
示例3: get
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import get_profile_by_application_user_id [as 别名]
def get(self):
application_url = self.request.application_url
if not re.match(r"^.*/$", application_url):
application_url += '/'
art_objs = Art.get_art()
art_list = list()
artists_by_app_user_id = dict()
artists_looked_up_by_app_user_id = dict()
profiles_by_app_user_id = dict()
profiles_looked_up_by_app_user_id = dict()
for art_obj in art_objs:
art = dict()
art['art_obj'] = art_obj
app_user_id = art_obj.application_user_id
if app_user_id is not None:
user_obj = artists_by_app_user_id.get(app_user_id)
if user_obj is None and not artists_looked_up_by_app_user_id.get(app_user_id):
artists_looked_up_by_app_user_id[app_user_id] = True
user_obj = User.get_user_by_application_user_id(app_user_id)
if user_obj is not None:
artists_by_app_user_id[app_user_id] = user_obj
profile_obj = profiles_by_app_user_id.get(app_user_id)
if profile_obj is None and not profiles_looked_up_by_app_user_id.get(app_user_id):
profiles_looked_up_by_app_user_id[app_user_id] = True
profile_obj = Profile.get_profile_by_application_user_id(app_user_id)
if profile_obj is not None:
profiles_by_app_user_id[app_user_id] = profile_obj
artist_nickname = None
if profile_obj is not None:
artist_nickname = profile_obj.profile_unique_display_name
art['artist_nickname'] = artist_nickname
if user_obj is not None:
art['artist_name'] = user_obj.first_name + ' ' + user_obj.last_name
if artist_nickname is not None:
art['artist_url'] = application_url + urllib.quote(artist_nickname, safe='')
else:
art['artist_url'] = application_url + app_user_id
art_list.append(art)
self.template_values['art_list'] = art_list
template = self.get_template('templates/index.html')
self.response.write(template.render(self.template_values))
示例4: get
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import get_profile_by_application_user_id [as 别名]
def get(self):
if self.redirected:
# The call was redirected in the __init__ -- do not do anything in this
# handler -- just return
return
if not self.google_user:
# The __init__ definitions in the base classes should redirect to authentication, so this should never
# happen. However, we include this check if somehow this get handler is invoked but the user is not
# authenticated
raise UnauthorizedException("/edit_profile invoked but user has not been authenticated. " +
"Unable to handle request.")
elif not self.application_user:
# The __init__ definitions in the base classes should redirect to /register_user, so this should never
# happen. However, we include this check if somehow this get handler is invoked but the user is
# not registered.
raise NotRegisteredException("/edit_profile invoked but the user has not registered. " +
"Unable to handle request.")
template = self.get_template('templates/edit_profile.html')
feedback = self.request.get('feedback')
feedback_status = self.request.get('feedback_status')
if feedback is not None and not re.match(r"^\s*$", feedback):
feedback = feedback.strip()
self.template_values['feedback'] = feedback
if feedback_status is None or re.match(r"^\s*$", feedback_status):
feedback_status = 'No_Change'
feedback_status = feedback_status.strip()
self.template_values['feedback_status'] = feedback_status
continue_to = self.request.get('continue')
if continue_to is None or re.match(r"^\s*$", continue_to):
if self.request.path is not None and not re.match(r"r^\s*$", self.request.path):
continue_to = self.request.path
if continue_to is None or re.match(r"^\s*$", continue_to):
continue_to = '/edit_profile'
self.template_values['after_editing_profile_continue_to'] = continue_to
application_user = self.application_user
if application_user.first_name is not None and \
not re.match(r"^\s*$", application_user.first_name):
self.template_values['first_name'] = application_user.first_name
if application_user.middle_name is not None and \
not re.match(r"^\s*$", application_user.middle_name):
self.template_values['middle_name'] = application_user.middle_name
if application_user.last_name is not None and \
not re.match(r"^\s*$", application_user.last_name):
self.template_values['last_name'] = application_user.last_name
google_user = self.google_user
email = google_user.email()
if email and not re.match(r"^\s*$", email):
self.template_values['email'] = email
application_user_id = application_user.application_user_id
profile_obj = Profile.get_profile_by_application_user_id(application_user_id)
if profile_obj is not None:
profile_unique_display_name = profile_obj.profile_unique_display_name
if profile_unique_display_name is not None and not re.match(r"^\s*$", profile_unique_display_name):
self.template_values['profile_unique_display_name'] = profile_unique_display_name
bio = profile_obj.bio
if bio is not None and not re.match(r"^\s*$", bio):
self.template_values['bio'] = bio
self.template_values['is_update'] = True
self.response.write(template.render(self.template_values))
示例5: post
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import get_profile_by_application_user_id [as 别名]
def post(self):
if self.redirected:
# The call was redirected in the __init__ -- do not do anything in this
# handler -- just return
return
if not self.google_user:
# The __init__ definitions in the base classes should redirect to authentication, so this should never
# happen. However, we include this check if somehow this get handler is invoked but the user is not
# authenticated
raise UnauthorizedException("/edit_profile invoked but user has not been authenticated. " +
"Unable to handle request.")
elif not self.application_user:
# The __init__ definitions in the base classes should redirect to /register_user, so this should never
# happen. However, we include this check if somehow this get handler is invoked but the user is
# not registered.
raise NotRegisteredException("/edit_profile invoked but the user has not registered. " +
"Unable to handle request.")
continue_to = self.request.get('after_editing_profile_continue_to')
if continue_to is None or re.match(r"^\s*$", continue_to):
continue_to = '/'
continue_to = str(continue_to)
google_user = self.google_user
application_user = self.application_user
first_name = self.request.get('first_name')
middle_name = self.request.get('middle_name')
last_name = self.request.get('last_name')
if first_name is not None:
first_name = first_name.strip()
if last_name is not None:
last_name = last_name.strip()
if middle_name is not None:
middle_name = middle_name.strip()
application_user_changed = False
feedback = None
feedback_status = None
if first_name is not None and not re.match(r"^\s*$", first_name):
if first_name != application_user.first_name:
application_user.first_name = first_name
application_user_changed = True
if last_name is not None and not re.match(r"^\s*$", last_name):
if last_name != application_user.last_name:
application_user.last_name = last_name
application_user_changed = True
if middle_name is None or middle_name == '':
if application_user.middle_name is not None and not re.match(r"^\s*$", application_user.middle_name):
application_user.middle_name = None
application_user_changed = True
else:
if application_user.middle_name is None or re.match(r"^\s*$", application_user.middle_name):
application_user.middle_name = middle_name
application_user_changed = True
elif application_user.middle_name != application_user.middle_name:
application_user.middle_name = middle_name
application_user_changed = True
if application_user_changed:
update_success = True
try:
application_user.put()
except:
update_success = False
if update_success:
feedback = 'Successfully updated your registration.'
feedback_status = 'Success'
else:
feedback = 'Attempt to update your registration failed.'
feedback_status = 'Failure'
edit_profile_url = self.request.application_url
if not re.match(r"^.*$", edit_profile_url):
edit_profile_url += '/'
edit_profile_url += 'edit_profile'
feedback = urllib.quote(feedback, safe='')
feedback_status = urllib.quote(feedback_status, safe='')
return self.redirect(edit_profile_url + '?feedback=' + feedback + '&feedback_status=' + feedback_status)
bio = self.request.get('bio')
if bio is not None:
bio = bio.strip()
if bio == '' or re.match(r"^\s*$", bio):
bio = None
application_user_id = application_user.application_user_id
profile_unique_display_name = self.request.get('profile_unique_display_name')
profile_unique_display_name = profile_unique_display_name.strip()
profile_obj_for_user = Profile.get_profile_by_application_user_id(application_user_id)
#.........这里部分代码省略.........