Merge pull request #757 from ywk253100/policy

The name can be same with others when creating and updating policies
This commit is contained in:
Wenkai Yin 2016-09-05 12:09:39 +08:00 committed by GitHub
commit 7dc7260c31

View File

@ -91,6 +91,7 @@ func (pa *RepPolicyAPI) Post() {
policy := &models.RepPolicy{}
pa.DecodeJSONReqAndValidate(policy)
/*
po, err := dao.GetRepPolicyByName(policy.Name)
if err != nil {
log.Errorf("failed to get policy %s: %v", policy.Name, err)
@ -100,6 +101,7 @@ func (pa *RepPolicyAPI) Post() {
if po != nil {
pa.CustomAbort(http.StatusConflict, "name is already used")
}
*/
project, err := dao.GetProjectByID(policy.ProjectID)
if err != nil {
@ -169,6 +171,7 @@ func (pa *RepPolicyAPI) Put() {
policy.ProjectID = originalPolicy.ProjectID
pa.Validate(policy)
/*
// check duplicate name
if policy.Name != originalPolicy.Name {
po, err := dao.GetRepPolicyByName(policy.Name)
@ -181,6 +184,7 @@ func (pa *RepPolicyAPI) Put() {
pa.CustomAbort(http.StatusConflict, "name is already used")
}
}
*/
if policy.TargetID != originalPolicy.TargetID {
//target of policy can not be modified when the policy is enabled