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 786 B

5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930
  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 (
  6. "code.gitea.io/gitea/modules/log"
  7. )
  8. // GetUserDataSetPermission returns the user permissions to the data_set
  9. func GetUserDataSetPermission(dataSet *Dataset, user *User) (isPermit bool, err error) {
  10. isPermit = false
  11. switch dataSet.Status {
  12. case DatasetStatusDeleted:
  13. log.Error("the data_set has been deleted")
  14. case DatasetStatusPrivate:
  15. if !user.IsAdmin && user.ID != dataSet.UserID {
  16. log.Error("the user is not admin nor the owner of the data_set")
  17. }
  18. case DatasetStatusPublic:
  19. isPermit = true
  20. default:
  21. log.Error("the status of data_set is wrong")
  22. }
  23. return isPermit, nil
  24. }