permission.py 418 B

12345678910
  1. from file.models import File
  2. from folder.models import Folder
  3. from account.models import User
  4. def can_delete(user, f):
  5. if not isinstance(user, User) or (not isinstance(f, File) and not isinstance(f, Folder)):
  6. raise TypeError('File or Folder expected.')
  7. return f.father_folder and f.father_folder.check_permission(user=user) and (
  8. f.owner == user or (f.group and f.group.creator == user))