Esempio n. 1
0
 def test_get_project_by_name(self):
     project = projects_service.get_project_by_name(self.project.name)
     self.assertEqual(project["name"], self.project.name)
     self.assertRaises(
         ProjectNotFoundException,
         projects_service.get_project_by_name,
         "missing",
     )
Esempio n. 2
0
    def get(self):
        name = request.args.get("name", None)
        try:
            permissions.check_admin_permissions()

            if name is None:
                return projects_service.get_projects()
            else:
                return [projects_service.get_project_by_name(name)]
        except permissions.PermissionDenied:
            if name is None:
                return user_service.get_projects()
            else:
                return [user_service.get_project_by_name(name)]
Esempio n. 3
0
    def get(self):
        """
        Return all projects listed in database. 
        ---
        tags:
          - Projects
        description: Ensure that user has at least the manager level before that.
        responses:
            200:
              description: All projects listed in database
        """
        name = request.args.get("name", None)
        try:
            permissions.check_admin_permissions()

            if name is None:
                return projects_service.get_projects()
            else:
                return [projects_service.get_project_by_name(name)]
        except permissions.PermissionDenied:
            if name is None:
                return user_service.get_projects()
            else:
                return [user_service.get_project_by_name(name)]