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

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
12345678910111213141516171819202122232425262728293031
  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. isPermit = true
  19. case DatasetStatusPublic:
  20. isPermit = true
  21. default:
  22. log.Error("the status of data_set is wrong")
  23. }
  24. return isPermit, nil
  25. }