mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Automatic merge from release/2.1.0 -> release/2.2.0
* commit 'f603867960fab8c2aa57a0b7f5eea8aaf12c67c9': validators: add Optional() to IValidator for use in ValidateUpdateData() mcclient: options: set details=true when --pending-delete-all is specified cloudcommon: virtualresource: show pending_deleted field when queried cloudcommon: virtualresource: optimize list with --field specified
This commit is contained in:
@@ -293,10 +293,11 @@ func query2List(manager IModelManager, ctx context.Context, userCred mcclient.To
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fieldFilter := jsonutils.GetQueryStringArray(query, "field")
|
||||
listF := listFields(manager, userCred)
|
||||
if len(fieldFilter) > 0 && userCred.IsSystemAdmin() { // only sysadmin can extend list Fields
|
||||
listF = append(listF, fieldFilter...)
|
||||
fieldFilter := jsonutils.GetQueryStringArray(query, "field")
|
||||
if len(fieldFilter) > 0 && userCred.IsSystemAdmin() {
|
||||
// only sysadmin can specify list Fields
|
||||
listF = fieldFilter
|
||||
}
|
||||
showDetails := false
|
||||
showDetailsJson, _ := query.Get("details")
|
||||
@@ -335,9 +336,6 @@ func query2List(manager IModelManager, ctx context.Context, userCred mcclient.To
|
||||
}
|
||||
jsonDict = getModelExtraDetails(item, ctx, jsonDict)
|
||||
}
|
||||
if len(fieldFilter) > 0 {
|
||||
jsonDict = jsonDict.CopyIncludes(fieldFilter...)
|
||||
}
|
||||
results = append(results, jsonDict)
|
||||
}
|
||||
return results, nil
|
||||
|
||||
@@ -176,6 +176,14 @@ func (model *SVirtualResourceBase) getMoreDetails(ctx context.Context, userCred
|
||||
log.Errorf("GetTenantCache fail %s", err)
|
||||
}
|
||||
}
|
||||
admin, _ := query.GetString("admin")
|
||||
if utils.ToBool(admin) { // admin
|
||||
pendingDelete, _ := query.GetString("pending_delete")
|
||||
pendingDeleteLower := strings.ToLower(pendingDelete)
|
||||
if pendingDeleteLower == "all" || pendingDeleteLower == "any" {
|
||||
extra.Set("pending_deleted", jsonutils.NewBool(model.PendingDeleted))
|
||||
}
|
||||
}
|
||||
return extra
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ type IValidatorBase interface {
|
||||
|
||||
type IValidator interface {
|
||||
IValidatorBase
|
||||
Optional(bool) IValidator
|
||||
getValue() interface{}
|
||||
setDefault(data *jsonutils.JSONDict) bool
|
||||
}
|
||||
|
||||
@@ -178,6 +178,7 @@ func (opts *BaseListOptions) Params() (*jsonutils.JSONDict, error) {
|
||||
}
|
||||
if BoolV(opts.PendingDeleteAll) {
|
||||
params.Set("pending_delete", jsonutils.NewString("all"))
|
||||
params.Set("details", jsonutils.JSONTrue) // required to get pending_deleted field
|
||||
}
|
||||
if opts.Admin == nil {
|
||||
requiresSystem := len(opts.Tenant) > 0 ||
|
||||
|
||||
Reference in New Issue
Block a user