当前位置: 首页>>代码示例>>Python>>正文


Python Profile.get_profile_by_profile_unique_name方法代码示例

本文整理汇总了Python中models.profile.Profile.get_profile_by_profile_unique_name方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.get_profile_by_profile_unique_name方法的具体用法?Python Profile.get_profile_by_profile_unique_name怎么用?Python Profile.get_profile_by_profile_unique_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.profile.Profile的用法示例。


在下文中一共展示了Profile.get_profile_by_profile_unique_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import get_profile_by_profile_unique_name [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))
开发者ID:peterjirak,项目名称:sweetvisionart2,代码行数:37,代码来源:artist.py

示例2: post

# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import get_profile_by_profile_unique_name [as 别名]

#.........这里部分代码省略.........
        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)
        profile_obj_for_profile_name = Profile.get_profile_by_profile_unique_name(profile_unique_display_name)
        if profile_obj_for_profile_name is not None:
            # There is already a profile for the given profile unique display name:
            if profile_obj_for_profile_name.application_user_id != application_user_id:
                # The profile that already exists is not for this user but is for another user:
                feedback = "Cannot setup your profile, the profile name '%s' is already in use." % \
                           profile_unique_display_name
                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)
            else:
                # The profile already exists and is for this user:
                profile_changed = False
                if bio is None and profile_obj_for_profile_name.bio is not None:
                    profile_obj_for_profile_name.bio = None
                    profile_changed = True
                if profile_changed:
                    update_success = True
                    try:
                        profile_obj_for_profile_name.put()
                    except:
                        update_success = False
                    if update_success:
                        feedback = 'Successfully updated your profile.'
                        feedback_status = 'Success'
开发者ID:peterjirak,项目名称:sweetvisionart2,代码行数:70,代码来源:edit_profile.py


注:本文中的models.profile.Profile.get_profile_by_profile_unique_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。