Merge pull request #6165 from zhaoxiangchun/automated-cherry-pick-of-#6164-upstream-release-3.2

Automated cherry pick of #6164: bugfix mem paginate
This commit is contained in:
yunion-ci-robot
2020-05-07 16:51:45 +08:00
committed by GitHub
2 changed files with 18 additions and 0 deletions
+2
View File
@@ -741,6 +741,8 @@ func calculateListResult(data []jsonutils.JSONObject, total, limit, offset int64
// do limit
if limit > 0 && total-offset > limit {
data = data[:limit]
} else {
data = data[:total-offset]
}
}
+16
View File
@@ -251,6 +251,22 @@ func (self *SSuggestSysRule) PerformEnable(ctx context.Context, userCred mcclien
return nil, nil
}
func (self *SSuggestSysRule) AllowPerformDisable(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
return db.IsAdminAllowPerform(userCred, self, "disable")
}
func (self *SSuggestSysRule) PerformDisable(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
if self.Enabled.IsTrue() {
db.Update(self, func() error {
self.Enabled = tristate.False
return nil
})
db.OpsLog.LogEvent(self, db.ACT_DISABLE, "", userCred)
self.PostUpdate(ctx, userCred, query, data)
}
return nil, nil
}
func (self *SSuggestSysRuleManager) AllowGetPropertyRuleType(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
return true
}