fix(schema):add subscriptions_count in channel
This commit is contained in:
		
							parent
							
								
									0b2e457052
								
							
						
					
					
						commit
						f9d9376aa4
					
				|  | @ -263,6 +263,7 @@ class ChannelSerializer(serializers.ModelSerializer): | ||||||
|     attributed_to = federation_serializers.APIActorSerializer() |     attributed_to = federation_serializers.APIActorSerializer() | ||||||
|     rss_url = serializers.CharField(source="get_rss_url") |     rss_url = serializers.CharField(source="get_rss_url") | ||||||
|     url = serializers.SerializerMethodField() |     url = serializers.SerializerMethodField() | ||||||
|  |     subscriptions_count = serializers.SerializerMethodField() | ||||||
| 
 | 
 | ||||||
|     class Meta: |     class Meta: | ||||||
|         model = models.Channel |         model = models.Channel | ||||||
|  | @ -276,6 +277,7 @@ class ChannelSerializer(serializers.ModelSerializer): | ||||||
|             "rss_url", |             "rss_url", | ||||||
|             "url", |             "url", | ||||||
|             "downloads_count", |             "downloads_count", | ||||||
|  |             "subscriptions_count", | ||||||
|         ] |         ] | ||||||
| 
 | 
 | ||||||
|     def to_representation(self, obj): |     def to_representation(self, obj): | ||||||
|  | @ -284,6 +286,7 @@ class ChannelSerializer(serializers.ModelSerializer): | ||||||
|             data["subscriptions_count"] = self.get_subscriptions_count(obj) |             data["subscriptions_count"] = self.get_subscriptions_count(obj) | ||||||
|         return data |         return data | ||||||
| 
 | 
 | ||||||
|  |     @extend_schema_field(OpenApiTypes.INT) | ||||||
|     def get_subscriptions_count(self, obj) -> int: |     def get_subscriptions_count(self, obj) -> int: | ||||||
|         return obj.actor.received_follows.exclude(approved=False).count() |         return obj.actor.received_follows.exclude(approved=False).count() | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -20288,12 +20288,16 @@ components: | ||||||
|         downloads_count: |         downloads_count: | ||||||
|           type: integer |           type: integer | ||||||
|           readOnly: true |           readOnly: true | ||||||
|  |         subscriptions_count: | ||||||
|  |           type: integer | ||||||
|  |           readOnly: true | ||||||
|       required: |       required: | ||||||
|         - actor |         - actor | ||||||
|         - artist |         - artist | ||||||
|         - attributed_to |         - attributed_to | ||||||
|         - downloads_count |         - downloads_count | ||||||
|         - rss_url |         - rss_url | ||||||
|  |         - subscriptions_count | ||||||
|         - url |         - url | ||||||
|     ChannelCreate: |     ChannelCreate: | ||||||
|       type: object |       type: object | ||||||
|  | @ -25766,7 +25770,6 @@ components: | ||||||
|         - import_details |         - import_details | ||||||
|         - metadata |         - metadata | ||||||
|         - mimetype |         - mimetype | ||||||
|         - privacy_level |  | ||||||
|         - size |         - size | ||||||
|         - uuid |         - uuid | ||||||
|     UploadForOwnerRequest: |     UploadForOwnerRequest: | ||||||
|  | @ -25804,7 +25807,6 @@ components: | ||||||
|           writeOnly: true |           writeOnly: true | ||||||
|       required: |       required: | ||||||
|         - audio_file |         - audio_file | ||||||
|         - privacy_level |  | ||||||
|     Usage: |     Usage: | ||||||
|       type: object |       type: object | ||||||
|       properties: |       properties: | ||||||
|  |  | ||||||
|  | @ -230,6 +230,7 @@ def test_channel_serializer_representation(factories, to_api_date): | ||||||
|         "rss_url": channel.get_rss_url(), |         "rss_url": channel.get_rss_url(), | ||||||
|         "url": channel.actor.url, |         "url": channel.actor.url, | ||||||
|         "downloads_count": 12, |         "downloads_count": 12, | ||||||
|  |         "subscriptions_count": 0, | ||||||
|     } |     } | ||||||
|     expected["artist"]["description"] = common_serializers.ContentSerializer( |     expected["artist"]["description"] = common_serializers.ContentSerializer( | ||||||
|         content |         content | ||||||
|  | @ -254,6 +255,7 @@ def test_channel_serializer_external_representation(factories, to_api_date): | ||||||
|         "rss_url": channel.get_rss_url(), |         "rss_url": channel.get_rss_url(), | ||||||
|         "url": channel.actor.url, |         "url": channel.actor.url, | ||||||
|         "downloads_count": 0, |         "downloads_count": 0, | ||||||
|  |         "subscriptions_count": 0, | ||||||
|     } |     } | ||||||
|     expected["artist"]["description"] = common_serializers.ContentSerializer( |     expected["artist"]["description"] = common_serializers.ContentSerializer( | ||||||
|         content |         content | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Petitminion
						Petitminion