utils/api: do not clobber endpoint.methods when endpoint.post exists (#84252)
gitea/passerelle/pipeline/head Build queued... Details

This commit is contained in:
Benjamin Dauvergne 2024-02-07 18:36:54 +01:00
parent 5b2f2d5b97
commit d05217cdc0
2 changed files with 4 additions and 11 deletions

View File

@ -1348,9 +1348,6 @@ class RSA13Resource(BaseResource, HTTPResource):
ip=ip,
)
# bug
platform_beneficiaire_action_detail.endpoint_info.methods.insert(0, 'get')
@endpoint(
name='platform',
pattern=r'^(?P<platform_id>[0-9]{1,10})/'
@ -1731,8 +1728,6 @@ class RSA13Resource(BaseResource, HTTPResource):
ip=ip,
)
platform_beneficiaire_affectation_detail.endpoint_info.methods.insert(0, 'get')
@endpoint(
name='platform',
pattern=r'^(?P<platform_id>[0-9]{1,10})/' r'beneficiaire/(?P<beneficiary_id>[0-9]{1,10})/' r'convo/$',
@ -2106,8 +2101,6 @@ class RSA13Resource(BaseResource, HTTPResource):
ip=ip,
)
platform_beneficiaire_evenement.endpoint_info.methods.insert(0, 'get')
@endpoint(
name='platform',
methods=['get', 'post', 'delete'],
@ -2196,9 +2189,6 @@ class RSA13Resource(BaseResource, HTTPResource):
ip=ip,
)
platform_beneficiaire_evenement_detail.endpoint_info.methods.insert(0, 'get')
platform_beneficiaire_evenement_detail.endpoint_info.methods.insert(0, 'delete')
DEFAULTS = {
'beneficiaire_csv_columns': [

View File

@ -93,7 +93,10 @@ class endpoint:
schema['application/json'] = post_json_schema
self.post = post
if post:
self.methods = ['post']
if self.methods == ['get']:
self.methods = ['post']
elif 'post' not in self.methods:
self.methods.append('post')
if post.get('description'):
self.descriptions['post'] = post.get('description')
if post.get('long_description'):