Commit 21642e3e authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Fixed problems with swagger validation of edit actions model.

parent 505f9eae
Pipeline #64184 passed with stages
in 25 minutes and 38 seconds
......@@ -678,10 +678,24 @@ class EditUserMetadataDialogUnstyled extends React.Component {
const { query, api } = this.props
const { actions } = this.state
// remove null values to allow swagger validation
const actionsCopy = {...this.state.actions}
Object.keys(actionsCopy).forEach(key => {
if (Array.isArray(actionsCopy[key])) {
actionsCopy[key] = actionsCopy[key].map(action => {
const actionCopy = {...action}
if (!actionCopy.value) {
delete actionCopy.value
}
return actionCopy
})
}
})
const editRequest = {
query: query,
verify: verify,
actions: actions
actions: actionsCopy
}
return api.edit(editRequest).then(data => {
......@@ -689,8 +703,8 @@ class EditUserMetadataDialogUnstyled extends React.Component {
return
}
const newActions = {...this.state.actions}
let verified = true
const newActions = {...this.state.actions}
if (data.actions) {
Object.keys(newActions).forEach(key => {
if (Array.isArray(newActions[key])) {
......
......@@ -330,13 +330,8 @@ def repo_edit_action_field(quantity):
fields.Nested(repo_edit_action_model, skip_none=True), description=quantity.description)
class NullableString(fields.String):
__schema_type__ = ['string', 'null']
__schema_example__ = 'nullable string'
repo_edit_action_model = api.model('RepoEditAction', {
'value': NullableString(description='The value/values that is set as a string.'),
'value': fields.String(description='The value/values that is set as a string.'),
'success': fields.Boolean(description='If this can/could be done. Only in API response.'),
'message': fields.String(descriptin='A message that details the action result. Only in API response.')
})
......@@ -458,13 +453,12 @@ class EditRepoCalcsResource(Resource):
action['success'] = True
action['message'] = None
action_value = action.get('value')
action_value = action_value if action_value is None else action_value.strip()
if action_value is None:
continue
action_value = action_value.strip()
mongo_value = None
if action_value == '':
elif action_value == '':
mongo_value = None
elif flask_verify == datamodel.User:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment