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


Python models.UserProfile类代码示例

本文整理汇总了Python中rogerthat.models.UserProfile的典型用法代码示例。如果您正苦于以下问题:Python UserProfile类的具体用法?Python UserProfile怎么用?Python UserProfile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: trans_create

    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()
开发者ID:gitter-badger,项目名称:rogerthat-backend,代码行数:32,代码来源:profile.py

示例2: get_profile_for_google_user

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
开发者ID:gitter-badger,项目名称:rogerthat-backend,代码行数:11,代码来源:profile.py

示例3: trans

    def trans(image):
        changed_properties = []
        user_profile = get_user_profile(app_user)
        if name is not MISSING:
            if user_profile.name != name:
                changed_properties.append(u"name")
            user_profile.name = name

        # has_birthdate and has_gender are used starting from 1.0.999.A and 1.0.137.i
        if has_birthdate is not MISSING and has_gender is not MISSING:
            if has_birthdate is True:
                user_profile.birthdate = birthdate
                user_profile.birth_day = UserProfile.get_birth_day_int(birthdate)
            if has_gender is True:
                user_profile.gender = gender
        else:
            # birthdate and gender are only used without has_gender and has_birthdate in 1.0.998.A
            if birthdate is not MISSING and gender is not MISSING:
                if birthdate == 0 and gender == 0:
                    pass  # user pressed save in 1.0.998.A without setting gender and birthdate
                else:
                    user_profile.birthdate = birthdate
                    user_profile.birth_day = UserProfile.get_birth_day_int(birthdate)
                    if gender != 0:
                        user_profile.gender = gender

        if image:
            avatar = get_avatar_by_id(user_profile.avatarId)
            if not avatar:
                avatar = Avatar(user=user_profile.user)

            image = base64.b64decode(str(image))
            img = Image(image)
            if img.width > 150 or img.height > 150:
                logging.info('Resizing avatar from %sx%s to 150x150', img.width, img.height)
                img.resize(150, 150)
                image = img.execute_transforms(img.format, 100)

            update_avatar_profile(user_profile, avatar, image)
            changed_properties.append(u"avatar")
        user_profile.version += 1
        user_profile.put()

        from rogerthat.bizz.profile import update_mobiles, update_friends
        update_mobiles(user_profile.user, user_profile, current_mobile)  # update myIdentity
        schedule_re_index(app_user)
        if changed_properties:  # Not necessary when only birth date or gender were updated.
            update_friends(user_profile)  # notify my friends.
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:48,代码来源:system.py

示例4: _un_subscribe

    def _un_subscribe(self, app_user, si_user, broadcast_type):
        user_profile, si, fsic = db.get([UserProfile.createKey(app_user),
                                         ServiceIdentity.keyFromUser(add_slash_default(si_user)),
                                         FriendServiceIdentityConnection.createKey(app_user, si_user)])

        logging.info('%s is unsubscribing from notifications of "%s" with type "%s".',
                     user_profile.name if user_profile else app_user.email(),
                     si.name if si else si_user.email(),
                     broadcast_type)

        updated = False
        if fsic:
            if broadcast_type in fsic.enabled_broadcast_types:
                fsic.enabled_broadcast_types.remove(broadcast_type)
                updated = True
            if broadcast_type not in fsic.disabled_broadcast_types:
                fsic.disabled_broadcast_types.append(broadcast_type)
                updated = True

        if updated:
            fsic.put()
            models = db.get([UserData.createKey(fsic.friend, fsic.service_identity_user)] +
                             [get_mobile_key_by_account(mobile.account) for mobile in user_profile.mobiles])
            user_data_model, mobiles = models[0], models[1:]
            create_send_user_data_requests(mobiles, user_data_model, fsic, fsic.friend, fsic.service_identity_user)
            schedule_update_a_friend_of_a_service_identity_user(fsic.service_identity_user, fsic.friend, force=True,
                                                                clear_broadcast_settings_cache=True)
        else:
            logging.info('%s was already unsubscribed from notifications of "%s" with type "%s".',
                         user_profile.name if user_profile else app_user.email(),
                         si.name if si else si_user.email(),
                         broadcast_type)

        return updated, user_profile, si, fsic
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:34,代码来源:unsubscribe_reminder_service.py

示例5: _update_app_asset_for_user

def _update_app_asset_for_user(user_profile_key, request):
    """
    Args:
        user_profile_key (db.Key)
        request (UpdateAppAssetRequestTO)
    """
    user_profile = UserProfile.get(user_profile_key)
    updateAppAsset(update_app_asset_response, logError, user_profile.user, request=request)
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:8,代码来源:update_app_asset.py

示例6: _ensure_data

 def _ensure_data(self):
     if self.has_data:
         return
     else:
         if self.is_service:
             self._service_profile = get_service_profile(self.service_user)
             self._profile_info = get_service_identity(self.service_identity_user)
         else:
             self._profile_info = db.get(UserProfile.createKey(self.user))
         self.has_data = True
开发者ID:our-city-app,项目名称:mobicage-backend,代码行数:10,代码来源:friend_helper.py

示例7: trans

    def trans(user):
        helper = FriendHelper.serialize(user, friend_type)

        if friend_type == FRIEND_TYPE_SERVICE:
            user = remove_slash_default(user)
        else:
            update_friend_service_identity_connections(UserProfile.createKey(user), changed_properties)

        run_job(get_friends_friends_maps_keys_query, [user], _update_friend, [helper, clear_broadcast_settings_cache],
                worker_queue=worker_queue)
开发者ID:our-city-app,项目名称:mobicage-backend,代码行数:10,代码来源:update_friends.py

示例8: send_birthday_messages

def send_birthday_messages():
    messages_per_app = get_all_app_birthday_messages()
    receivers_per_app = defaultdict(list)
    for user_profile in UserProfile.list_by_birth_day(now()):
        assert (isinstance(user_profile, UserProfile))
        if user_profile.app_id not in messages_per_app:  # this will be faster than doing multiple queries on app ids
            continue
        receivers_per_app[user_profile.app_id].append(UserMemberTO(user_profile.user, Message.ALERT_FLAG_VIBRATE))
    for app_id, receivers in receivers_per_app.iteritems():
        message, branding_hash = messages_per_app[app_id]
        deferred.defer(sendMessage, MC_DASHBOARD, receivers, Message.FLAG_ALLOW_DISMISS, 0, None, message, [], None,
                       branding_hash, None, is_mfr=False)
开发者ID:our-city-app,项目名称:mobicage-backend,代码行数:12,代码来源:birthday.py

示例9: get

    def get(self):
        data_dict, app_user = self.get_user_info()
        if not data_dict or not app_user:
            return

        azzert(data_dict['a'] == "unsubscribe deactivate")

        app, user_profile = db.get([App.create_key(get_app_id_from_app_user(app_user)),
                                    UserProfile.createKey(app_user)])

        if not user_profile:
            self.redirect("/")
            return

        mobiles = list(get_user_active_mobiles(app_user))
        if mobiles:
            mobile = mobiles[0]
            if mobile.type in Mobile.ANDROID_TYPES:
                page_type = "android"
            elif mobile.type in Mobile.IOS_TYPES:
                page_type = "ios"
            else:
                return self.return_error()
        else:
            mobile = None
            page_type = "web"

        page_type = self.request.get("page_type", page_type)
        language = self.request.get("language", user_profile.language)

        ActivationLog(timestamp=now(), email=app_user.email(), mobile=mobile,
                      description="Visit unsubscribe page %s %s" % (page_type, user_profile.language)).put()

        jinja_template = self.get_jinja_environment().get_template('unsubscribe_deactivate.html')

        params = {
            'name': data_dict['n'],
            'app_name': get_app_by_user(app_user).name,
            'hide_header': True,
            'data': self.request.get("data"),
            'app_email': app_user.email(),
            'email': get_human_user_from_app_user(app_user).email(),
            'action': data_dict['a'],
            'page_type': page_type,
            'language': language,
            'is_city_app': app.type == App.APP_TYPE_CITY_APP
        }

        self.response.out.write(jinja_template.render(params))
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:49,代码来源:unsubscribe_reminder_service.py

示例10: delete_app

def delete_app(app_id):
    app = get_app(app_id)
    validate_can_delete_app(app)
    to_delete = [
        AppSettings.create_key(app_id),
        app.key()
    ]
    to_put = []
    for profile_key in UserProfile.all(keys_only=True).filter('app_id', app_id):
        delete_account(users.User(profile_key.parent().name()))
    for other_app in App.all():
        if app_id in other_app.orderable_app_ids:
            other_app.orderable_app_ids.remove(app_id)
            to_put.append(other_app)
    db.delete(to_delete)
    if to_put:
        put_and_invalidate_cache(to_put)
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:17,代码来源:app.py

示例11: _delete_ownership_users

def _delete_ownership_users(service_email):
    to_put = []
    for up in UserProfile.all().filter("owningServiceEmails =", service_email):
        if service_email in up.owningServiceEmails:
            up.owningServiceEmails.remove(service_email)
        if list(get_user_active_mobiles(up.user)):
            if not up.owningServiceEmails:
                up.isCreatedForService = False
            to_put.append(up)
        else:
            if not up.owningServiceEmails:
                deferred.defer(delete_account, up.user, _countdown=5)
            else:
                to_put.append(up)

    if to_put:
        put_and_invalidate_cache(*to_put)
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:17,代码来源:delete_service.py

示例12: trans_create

    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
开发者ID:our-city-app,项目名称:mobicage-backend,代码行数:20,代码来源:profile.py

示例13: post

    def post(self):
        app_id = self.request.POST.get("app_id", None)

        self.response.headers['Content-Type'] = 'text/json'
        if not app_id:
            self.response.out.write(json.dumps(dict(success=False, errormsg=u"Failed to delete app (app_id was empty)!")))
        else:
            app = get_app_by_id(app_id)
            if app:
                if len(UserProfile.all().filter('app_id =', app_id).fetch(1)) > 0:
                    self.response.out.write(json.dumps(dict(success=False, errormsg=u"Failed to remove app (has users)")))
                else:
                    if len(ServiceIdentity.all().filter('app_ids =', app_id).fetch(1)) > 0:
                        self.response.out.write(json.dumps(dict(success=False, errormsg=u"Failed to remove app (service_identies contain app)")))
                    else:
                        app.delete()
                        self.response.out.write(json.dumps(dict(success=True, errormsg=u"Successfully removed app!")))
            else:
                self.response.out.write(json.dumps(dict(success=False, errormsg=u"Could not delete unknown app")))
开发者ID:gitter-badger,项目名称:rogerthat-backend,代码行数:19,代码来源:apps.py

示例14: send_overview_email

def send_overview_email(from_, to, dry_run=True, skipped_users=None):
    if skipped_users is None:
        skipped_users = set()
    server_settings = get_server_settings()
    key = '%s-%s' % (from_, to)
    dsp = DSPickler.read(key)
    users = sorted(set(dsp.data[0]) - skipped_users)
    body = u"\n".join(users) or u"No reminders sent"
    body = "COUNT: %s (%.02f%%)\nDRY_RUN: %s\n\n%s" % (len(users),
                                                       100.0 * len(users) / UserProfile.all().count(None),
                                                       dry_run,
                                                       body)
    msg = MIMEMultipart('alternative')
    msg['Subject'] = "Rogerthat reminders sent"
    msg['From'] = server_settings.senderEmail
    msg['To'] = ', '.join(server_settings.supportWorkers)
    msg.attach(MIMEText(body.encode('utf-8'), 'plain', 'utf-8'))
    send_mail_via_mime(server_settings.dashboardEmail, server_settings.supportWorkers, msg)
    deferred.defer(cleanup, key)
开发者ID:gitter-badger,项目名称:rogerthat-backend,代码行数:19,代码来源:send_unread_messages.py

示例15: get_service_grants

def get_service_grants(service_user, filtered_service_identity=ServiceIdentity.DEFAULT, filtered_role_id=None,
                       filtered_role_type=None):
    from rogerthat.bizz.roles import ROLE_TYPE_ADMIN, ROLE_TYPE_SERVICE
    service_user_email = service_user.email()
    if not isinstance(service_user_email, unicode):
        service_user_email = service_user_email.decode('utf-8')

    profiles = UserProfile.list_by_service_role_email(service_user_email)
    for p in profiles:
        for si, roles in p.grants.iteritems():
            if si.startswith(service_user_email + '/'):
                _, identity = get_service_identity_tuple(users.User(si))
                if filtered_service_identity != ServiceIdentity.DEFAULT and identity != filtered_service_identity:
                    continue
                for role in roles:
                    gto = GrantTO()
                    try:
                        role_id = int(role)
                        role_type = ROLE_TYPE_SERVICE
                        role = None
                    except ValueError:  # build-int role (see ROLES constant)
                        role_id = -1
                        role_type = ROLE_TYPE_ADMIN
                    gto.role_type = role_type
                    gto.role_id = role_id
                    gto.role = role

                    if filtered_role_id is not None and filtered_role_id != gto.role_id:
                        continue
                    if filtered_role_type is not None and filtered_role_type != gto.role_type:
                        continue

                    gto.identity = identity
                    gto.service_email = service_user_email
                    gto.user_email = get_human_user_from_app_user(p.user).email()
                    gto.user_name = p.name
                    gto.user_avatar_id = p.avatarId
                    gto.app_id = p.app_id
                    yield gto
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:39,代码来源:roles.py


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