permissions.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright (C) 2014 Andrey Antukh <niwi@niwi.be>
  2. # Copyright (C) 2014 Jesús Espino <jespinog@gmail.com>
  3. # Copyright (C) 2014 David Barragán <bameda@dbarragan.com>
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. from taiga.base.api.permissions import (TaigaResourcePermission, HasProjectPerm,
  17. IsAuthenticated, IsProjectOwner, AllowAny,
  18. IsSuperUser)
  19. class TaskPermission(TaigaResourcePermission):
  20. enought_perms = IsProjectOwner() | IsSuperUser()
  21. global_perms = None
  22. retrieve_perms = HasProjectPerm('view_tasks')
  23. create_perms = HasProjectPerm('add_task')
  24. update_perms = HasProjectPerm('modify_task')
  25. partial_update_perms = HasProjectPerm('modify_task')
  26. destroy_perms = HasProjectPerm('delete_task')
  27. list_perms = AllowAny()
  28. csv_perms = AllowAny()
  29. bulk_create_perms = HasProjectPerm('add_task')
  30. bulk_update_order_perms = HasProjectPerm('modify_task')
  31. upvote_perms = IsAuthenticated() & HasProjectPerm('view_tasks')
  32. downvote_perms = IsAuthenticated() & HasProjectPerm('view_tasks')
  33. watch_perms = IsAuthenticated() & HasProjectPerm('view_tasks')
  34. unwatch_perms = IsAuthenticated() & HasProjectPerm('view_tasks')
  35. class TaskVotersPermission(TaigaResourcePermission):
  36. enought_perms = IsProjectOwner() | IsSuperUser()
  37. global_perms = None
  38. retrieve_perms = HasProjectPerm('view_tasks')
  39. list_perms = HasProjectPerm('view_tasks')
  40. class TaskWatchersPermission(TaigaResourcePermission):
  41. enought_perms = IsProjectOwner() | IsSuperUser()
  42. global_perms = None
  43. retrieve_perms = HasProjectPerm('view_tasks')
  44. list_perms = HasProjectPerm('view_tasks')