當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。