Esempio n. 1
0
 def _validate_can_be(self, action, element):
     from flask import current_app
     from pybossa.core import project_repo
     if not isinstance(element, Task) and not isinstance(element, TaskRun):
         name = element.__class__.__name__
         msg = '%s cannot be %s by %s' % (name, action, self.__class__.__name__)
         raise WrongObjectError(msg)
Esempio n. 2
0
 def _validate_can_be(self, action, element):
     from flask import current_app
     from pybossa.core import project_repo
     if not isinstance(element, Task) and not isinstance(element, TaskRun):
         name = element.__class__.__name__
         msg = '%s cannot be %s by %s' % (name, action, self.__class__.__name__)
         raise WrongObjectError(msg)
     if isinstance(element, Task) and (action in [self.SAVE_ACTION, self.UPDATE_ACTION]):
         project = project_repo.get(element.project_id)
         ensure_task_assignment_to_project(element, project)
Esempio n. 3
0
 def _validate_can_be(self, action, result):
     if not isinstance(result, Result):
         name = result.__class__.__name__
         msg = '%s cannot be %s by %s' % (name, action,
                                          self.__class__.__name__)
         raise WrongObjectError(msg)
Esempio n. 4
0
 def _validate_can_be(self, action, user):
     if not isinstance(user, User):
         name = user.__class__.__name__
         msg = '%s cannot be %s by %s' % (name, action,
                                          self.__class__.__name__)
         raise WrongObjectError(msg)
Esempio n. 5
0
 def _validate_can_be(self, action, element):
     if not isinstance(element, Task) and not isinstance(element, TaskRun):
         name = element.__class__.__name__
         msg = '%s cannot be %s by %s' % (name, action,
                                          self.__class__.__name__)
         raise WrongObjectError(msg)
Esempio n. 6
0
 def _validate_can_be(self, action, blogpost):
     if not isinstance(blogpost, Blogpost):
         name = blogpost.__class__.__name__
         msg = '%s cannot be %s by %s' % (name, action,
                                          self.__class__.__name__)
         raise WrongObjectError(msg)
Esempio n. 7
0
 def _validate_can_be(self, action, projectcoowner):
     if not isinstance(projectcoowner, ProjectCoowner):
         name = projectcoowner.__class__.__name__
         msg = '%s cannot be %s by %s' % (name, action, self.__class__.__name__)
         raise WrongObjectError(msg)
Esempio n. 8
0
 def _validate_can_be(self, action, webhook):
     if not isinstance(webhook, Webhook):
         name = webhook.__class__.__name__
         msg = '%s cannot be %s by %s' % (name, action,
                                          self.__class__.__name__)
         raise WrongObjectError(msg)
Esempio n. 9
0
 def _validate_can_be(self, action, auditlog):
     if not isinstance(auditlog, Auditlog):
         name = auditlog.__class__.__name__
         msg = '%s cannot be %s by %s' % (name, action,
                                          self.__class__.__name__)
         raise WrongObjectError(msg)
Esempio n. 10
0
 def _validate_can_be(self, action, announcement):
     if not isinstance(announcement, Announcement):
         name = announcement.__class__.__name__
         msg = '%s cannot be %s by %s' % (name, action,
                                          self.__class__.__name__)
         raise WrongObjectError(msg)