コード例 #1
0
ファイル: UserResource.py プロジェクト: fergalmoran/dss
    def dehydrate(self, bundle):
        del bundle.data["activity_sharing_networks"]
        bundle.data["display_name"] = bundle.obj.get_nice_name()
        bundle.data["avatar_image"] = bundle.obj.get_avatar_image()

        bundle = BaseResource.dehydrate_bitfield(
            bundle=bundle,
            field_name="email_notifications",
            object_field=bundle.obj.email_notifications,
            choices=UserProfile.NOTIFICATION_CHOICES,
        )

        bundle = BaseResource.dehydrate_bitfield(
            bundle=bundle,
            field_name="activity_sharing_facebook",
            object_field=bundle.obj.activity_sharing_facebook,
            choices=UserProfile.NOTIFICATION_CHOICES,
        )

        bundle = BaseResource.dehydrate_bitfield(
            bundle=bundle,
            field_name="activity_sharing_twitter",
            object_field=bundle.obj.activity_sharing_twitter,
            choices=UserProfile.NOTIFICATION_CHOICES,
        )

        if bundle.obj.user.id == bundle.request.user.id:
            bundle.data["email"] = bundle.obj.email
            bundle.data["first_name"] = bundle.obj.first_name
            bundle.data["last_name"] = bundle.obj.last_name

        bundle.data["like_count"] = Mix.objects.filter(likes__user=bundle.obj).count()
        bundle.data["favourite_count"] = Mix.objects.filter(favourites__user=bundle.obj).count()
        # bundle.data['follower_count'] = bundle.obj.followers.count()
        bundle.data["following_count"] = bundle.obj.following.count()
        bundle.data["is_following"] = bundle.obj.is_follower(bundle.request.user)
        bundle.data["url"] = bundle.obj.get_profile_url()
        bundle.data["date_joined"] = bundle.obj.user.date_joined
        bundle.data["last_login"] = bundle.obj.user.last_login
        bundle.data["mix_count"] = bundle.obj.mix_count
        bundle.data["thumbnail"] = bundle.obj.get_small_profile_image()

        return bundle
コード例 #2
0
ファイル: UserResource.py プロジェクト: fergalmoran/dss
    def hydrate(self, bundle):
        bundle = BaseResource.hydrate_bitfield(
            bundle=bundle,
            field_name="email_notifications",
            object_field=UserProfile.email_notifications,
            choices=UserProfile.NOTIFICATION_CHOICES,
        )
        bundle = BaseResource.hydrate_bitfield(
            bundle=bundle,
            field_name="activity_sharing_facebook",
            object_field=UserProfile.activity_sharing_facebook,
            choices=UserProfile.NOTIFICATION_CHOICES,
        )

        bundle = BaseResource.hydrate_bitfield(
            bundle=bundle,
            field_name="activity_sharing_twitter",
            object_field=UserProfile.activity_sharing_twitter,
            choices=UserProfile.NOTIFICATION_CHOICES,
        )

        return bundle