Skip to content

Vendor Shop Serializer

Shop Serializers Documentation

This documentation provides an explanation of the serializers defined for managing shop-related data. These serializers are used to handle shop details, followers, and reviews/ratings, ensuring that the API returns consistent and meaningful data.


1. ShopRatingReviewInShopSerializer

  • Purpose: Serializes individual ratings and reviews for a shop, including user information and media files.
  • Fields:
  • id: Unique identifier for the review.
  • user: Reviewer details (serialized using ShopRatingReviewUserSerializer).
  • rating: Star rating given by the user.
  • review_text: Textual review content.
  • review_image1 to review_image5: Images uploaded as part of the review.
  • review_video: Video uploaded as part of the review.
  • created_at, updated_at: Timestamps for the review.

2. ShopSerializer

  • Purpose: Serializes the core details of a shop, including vendor information, follower count, ratings/reviews, and average ratings.
  • Key Methods:
  • get_shop_image: Builds the full URL for the shop's primary image.
  • get_shop_cover_image: Builds the full URL for the shop's cover image.
  • get_products: Retrieves all active products associated with the shop.
  • get_follower_count: Counts the number of followers who have followed the shop.
  • get_rating_reviews: Fetches all reviews and ratings for the shop, ordered by the latest.
  • get_average_ratings: Calculates the average rating and percentage distribution across all star levels.
  • Fields:
  • id: Unique shop identifier.
  • vendor: Vendor details (serialized using VendorSerializer).
  • follower_count: Total number of followers.
  • rating_reviews: List of ratings/reviews (serialized using ShopRatingReviewInShopSerializer).
  • average_ratings: Summary of average ratings and distribution.
  • description, shop_location, shop_image, shop_cover_image, created_at, updated_at: Shop details and metadata.

3. ShopFollowersSerializer

  • Purpose: Handles data for shop followers, ensuring valid relationships between users and shops.
  • Validation:
  • Ensures that vendors cannot follow shops (via validate_shop).
  • Fields:
  • id: Unique identifier for the follower record.
  • shop: Shop being followed (serialized using ShopInShopFollower).
  • has_followed: Boolean indicating if the user is currently following the shop.
  • created_at, updated_at: Timestamps for the follower record.

4. ShopFollowerDetailSerializer

  • Purpose: Provides a minimal representation of shop followers, focusing on whether the user has followed the shop.
  • Fields:
  • has_followed: Boolean indicating if the user is following the shop.

5. ShopWithFollowersCountSerializer

  • Purpose: Simplified serializer to provide shop details along with the follower count.
  • Fields:
  • id: Unique shop identifier.
  • vendor: Vendor details.
  • description: Brief description of the shop.
  • created_at, updated_at: Timestamps.
  • follower_count: Total number of followers.

6. `ShopReviewsRatingsSerializer

  • Purpose: Handles the serialization of reviews and ratings for a shop.
  • Fields:
  • id: Unique identifier for the review.
  • shop: Shop being reviewed.
  • user: User who provided the review.
  • rating: Star rating given.
  • review_text: Text review.
  • review_image1 to review_image5: Images associated with the review.
  • review_video: Video associated with the review.
  • created_at, updated_at: Timestamps for the review.

7. MoreShopSerializer

  • Purpose: Provides a lightweight representation of shop details.
  • Fields:
  • id: Unique shop identifier.
  • vendor: Vendor details.
  • description: Brief description of the shop.
  • shop_location: Location of the shop.
  • shop_image: Primary image for the shop.
  • shop_cover_image: Cover image for the shop.
  • created_at, updated_at: Timestamps for the shop record.

Summary

These serializers provide comprehensive data handling for shops, followers, and reviews/ratings. By including helper methods and validations, they ensure the API delivers accurate and user-friendly responses while maintaining data integrity.