File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -134,12 +134,10 @@ class Meta(EnvironmentSerializerWithMetadata.Meta):
134134class CreateEnvironmentSerializer (_BaseCreateUpdateEnvironmentSerializer ):
135135 def get_subscription (self ) -> Subscription | None :
136136 view = self .context ["view" ]
137- # handle `project` not being part of the data
138- # When request comes from yasg2(as part of schema generation)
139- project_id = view .request .data .get ("project" )
140- if not project_id :
137+ if getattr (view .request , "swagger_fake_view" , False ):
141138 return None
142139
140+ project_id = view .request .data ["project" ]
143141 project = Project .objects .select_related (
144142 "organisation" , "organisation__subscription"
145143 ).get (id = project_id )
@@ -154,7 +152,8 @@ class Meta(_BaseCreateUpdateEnvironmentSerializer.Meta):
154152 )
155153
156154 def get_subscription (self ) -> Subscription | None :
157- if self .instance is None :
155+ view = self .context ["view" ]
156+ if getattr (view .request , "swagger_fake_view" , False ):
158157 return None
159158 return getattr (self .instance .project .organisation , "subscription" , None ) # type: ignore[union-attr]
160159
You can’t perform that action at this time.
0 commit comments