class EventReadUserDetailedSerializer(EventReadDetailedSerializer): """User specfic event serializer that appends data based on request.user""" activation_time = ActivationTimeField() is_admitted = IsAdmittedField() spots_left = SpotsLeftField() price = serializers.SerializerMethodField() class Meta(EventReadDetailedSerializer.Meta): fields = EventReadDetailedSerializer.Meta.fields + ( "price", "activation_time", "is_admitted", "spots_left", ) def get_price(self, obj): request = self.context.get("request", None) if request: return obj.get_price(user=request.user)
class FrontpageEventSerializer(serializers.ModelSerializer): cover = ImageField(required=False, options={"height": 500}) thumbnail = ImageField( source="cover", required=False, options={ "height": 500, "width": 500, "smart": True }, ) text = ContentSerializerField() activation_time = ActivationTimeField() is_admitted = IsAdmittedField() class Meta: model = Event fields = ( "id", "title", "description", "cover", "text", "event_type", "event_status_type", "location", "start_time", "thumbnail", "end_time", "total_capacity", "company", "registration_count", "tags", "activation_time", "is_admitted", "pinned", ) read_only = True
class EventReadSerializer(TagSerializerMixin, BasisModelSerializer): company = CompanyField(queryset=Company.objects.all()) cover = ImageField(required=False, options={"height": 500}) thumbnail = ImageField( source="cover", required=False, options={ "height": 500, "width": 500, "smart": True }, ) activation_time = ActivationTimeField() is_admitted = IsAdmittedField() class Meta: model = Event fields = ( "id", "title", "description", "cover", "event_type", "event_status_type", "location", "start_time", "end_time", "thumbnail", "total_capacity", "company", "registration_count", "tags", "activation_time", "is_admitted", "survey", ) read_only = True