You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dataset_permission.go 834 B

5 years ago
1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package models
  5. import "code.gitea.io/gitea/modules/log"
  6. // GetUserDataSetPermission returns the user permissions to the data_set
  7. func GetUserDataSetPermission(dataSet *Dataset, user *User) (isPermit bool, err error) {
  8. isPermit = false
  9. if user != nil {
  10. switch dataSet.Status {
  11. case DatasetStatusDeleted:
  12. log.Error("the data_set has been deleted")
  13. case DatasetStatusPrivate:
  14. if !user.IsAdmin && user.ID != dataSet.UserID {
  15. log.Error("the user is not admin nor the owner of the data_set")
  16. }
  17. isPermit = true
  18. case DatasetStatusPublic:
  19. isPermit = true
  20. default:
  21. log.Error("the status of data_set is wrong")
  22. }
  23. }
  24. return isPermit, nil
  25. }