Exemplo n.º 1
0
 def put (self, *args, **kwargs):
     organization = kwargs.get('organization', None)
     org = self.validate_request(organization)
     self.clean_request(organization)
     project = Project(**self.data)
     try:
         project.save(validate=True, clean=True)
         self.set_user_permission(project)
     except ValidationError, error:
         raise HTTPError(500, **{'reason':self.error_message(error)})
Exemplo n.º 2
0
 def put(self, *args, **kwargs):
     organization = kwargs.get('organization', None)
     org = self.validate_request(organization)
     self.clean_request(organization)
     project = Project(**self.data)
     try:
         project.save(validate=True, clean=True)
         self.set_user_permission(project)
     except ValidationError, error:
         raise HTTPError(500, **{'reason': self.error_message(error)})
Exemplo n.º 3
0
 def put(self, *args, **kwargs):
     self.clean_request()
     project = Project(**self.data)
     try:
         project.save(validate=True, clean=True)
         ProjectMetadata.create_project_metadata(project)
         Story.create_todo(project, self.current_user)
         self.create_role(project, creating_project=True)
         Team.create_team(project=project, user=self.current_user)
     except ValidationError, error:
         raise HTTPError(500, **{'reason':self.error_message(error)})
Exemplo n.º 4
0
 def put(self, *args, **kwargs):
     self.clean_request()
     project = Project(**self.data)
     try:
         project.save(validate=True, clean=True)
         ProjectMetadata.create_project_metadata(project)
         Story.create_todo(project, self.current_user)
         self.create_role(project, creating_project=True)
         Team.create_team(project=project, user=self.current_user)
     except ValidationError, error:
         raise HTTPError(500, **{'reason': self.error_message(error)})
Exemplo n.º 5
0
 def get(self, *args, **kwargs):
     """
     Get a list of projects by passing in:
     1) projectId - the project sequence number (returns a single project)
     2) owner and project_name - Gets the project in either 
     the user or org context
     3) No params - List all the projects for the current authenticated user
     """
     sequence = self.get_argument('projectId', None)
     owner = self.get_argument('owner', None)
     project_name = self.get_argument('project_name', None)
     response = {}
     # By Sequence number
     if sequence:
         try:
             project = Project.get_project_object(sequence)
             if self.current_user in project.members:
                 response['project'] = project.to_json()
                 response['project'].update({
                     'current_sprint' : project.get_current_sprint().to_json()
                 })
             else:
                 raise HTTPError(404, **{'reason': "Project Not found."})
         except ValidationError, error:
             raise HTTPError(404, **{'reason': self.error_message(error)})
Exemplo n.º 6
0
 def get_project_stories(self, project_id, organization):
     project = self.get_project_object(sequence=project_id,
                                       org=organization)
     if project and self.current_user in project.members:
         return Project.get_story_list(project)
     else:
         self.send_error(404)
Exemplo n.º 7
0
 def get_project_object(self, sequence=None, organization=None):
     try:
         project = Project.get_project_object(sequence=str(sequence),
                                              organization=organization)
         print project
     except ValidationError, error:
         raise HTTPError(404, **{'reason': self.error_message(error)})
Exemplo n.º 8
0
 def get_project_object(self, sequence=None, org=None):
     try:
         project = Project.get_project_object(sequence=sequence,
                                       is_active=True,
                                       organization=org)
     except ValidationError, error:
         raise HTTPError(404, **{'reason': self.error_message(error)})
Exemplo n.º 9
0
 def get_project_stories(self, project_id, organization):
     project = self.get_project_object(sequence=project_id,
                                       org=organization)
     if project and self.current_user in project.members:
         return Project.get_story_list(project)
     else:
         self.send_error(404)
Exemplo n.º 10
0
 def get_project_object(self, sequence=None, org=None):
     try:
         project = Project.get_project_object(sequence=sequence,
                                              is_active=True,
                                              organization=org)
     except ValidationError, error:
         raise HTTPError(404, **{'reason': self.error_message(error)})
Exemplo n.º 11
0
 def get_project_object(self, sequence=None, organization=None):
     try:
         project = Project.get_project_object(sequence=str(sequence),
                                       organization=organization)
         print project
     except ValidationError, error:
         raise HTTPError(404, **{'reason': self.error_message(error)})
Exemplo n.º 12
0
 def get(self, *args, **kwargs):
     """
     Get a list of projects by passing in:
     1) projectId - the project sequence number (returns a single project)
     2) owner and project_name - Gets the project in either 
     the user or org context
     3) No params - List all the projects for the current authenticated user
     """
     sequence = self.get_argument('projectId', None)
     owner = self.get_argument('owner', None)
     project_name = self.get_argument('project_name', None)
     response = {}
     # By Sequence number
     if sequence:
         try:
             project = Project.get_project_object(sequence)
             if self.current_user in project.members:
                 response['project'] = project.to_json()
                 response['project'].update({
                     'current_sprint':
                     project.get_current_sprint().to_json()
                 })
             else:
                 raise HTTPError(404, **{'reason': "Project Not found."})
         except ValidationError, error:
             raise HTTPError(404, **{'reason': self.error_message(error)})
Exemplo n.º 13
0
 def delete(self, *args, **kwargs):
     sequence = self.get_argument('projectId', None)
     try:
         project = Project.get_project_object(sequence)
         project.update(set__active=False)
         self.write(project.to_json())
     except ValidationError, error:
         raise HTTPError(404, **{'reason': self.error_message(error)})
Exemplo n.º 14
0
 def delete(self, *args, **kwargs):
     sequence = self.get_argument('projectId', None)
     try:
         project = Project.get_project_object(sequence)
         project.update(set__active=False)
         self.write(project.to_json())
     except ValidationError, error:
         raise HTTPError(404, **{'reason': self.error_message(error)})
Exemplo n.º 15
0
 def get_valid_project(self, project_id, organization):
     if not project_id:
         self.send_error(404)
     try:
         project = Project.get_project_object(sequence=project_id,
                                              organization=organization)
         if self.current_user != project.admin:
             self.send_error(404)
     except ValidationError, error:
         raise HTTPError(404, **{'reason': self.error_message(error)})
Exemplo n.º 16
0
 def get_valid_project(self, project_id=None, permalink=None):
     if not project_id and not permalink:
         self.send_error(404)
     if project_id:
         try:
             project = Project.get_project_object(sequence=project_id)
             if self.current_user not in project.members:
                 self.send_error(404)
         except ValidationError, error:
             raise HTTPError(404, **{'reason': self.error_message(error)})
Exemplo n.º 17
0
 def get_valid_project(self, project_id=None, permalink=None):
     if not project_id and not permalink:
         self.send_error(404)
     if project_id:
         try:
             project = Project.get_project_object(sequence=project_id)
             if self.current_user not in project.members:
                 self.send_error(404)
         except ValidationError, error:
             raise HTTPError(404, **{'reason': self.error_message(error)})
Exemplo n.º 18
0
 def get_valid_project(self, project_id, organization):
     if not project_id:
         self.send_error(404)
     try:
         project = Project.get_project_object(sequence=project_id,
                                              organization=organization)
         if self.current_user != project.admin:
             self.send_error(404)
     except ValidationError, error:
         raise HTTPError(404, **{'reason': self.error_message(error)})
Exemplo n.º 19
0
 def get(self, *args, **kwargs):
     organization = kwargs.get('organization', None)
     org = self.validate_request(organization)
     response = None
     project_id = self.get_argument('projectId', None)
     if not project_id:
         projects = Project.objects.filter(organization=org,
                                       is_active=True)
         response = json_dumper(projects)
     elif project_id:
         try:
             project = Project.get_project_object(sequence=project_id,
                                                  organization=org)
             response = project.to_json()
         except ValidationError, error:
             raise HTTPError(404, **{'reason': self.error_message(error)})
Exemplo n.º 20
0
 def get(self, *args, **kwargs):
     organization = kwargs.get('organization', None)
     org = self.validate_request(organization)
     response = None
     sequence = self.get_argument('projectId', None)
     owner = self.get_argument('owner', None)
     project_name = self.get_argument('project_name', None)
     
     # By Sequence number
     if sequence:
         try:
             project = Project.get_project_object(sequence=sequence,
                                                  organization=org)
             if self.current_user in project.members:
                 response['project'] = project.to_json()
                 response['project'].update({
                     'current_sprint' : project.get_current_sprint().to_json()
                 })
             else:
                 raise HTTPError(404, **{'reason': "Project Not found."})
         except ValidationError, error:
             raise HTTPError(404, **{'reason': self.error_message(error)})
Exemplo n.º 21
0
    def get(self, *args, **kwargs):
        organization = kwargs.get('organization', None)
        org = self.validate_request(organization)
        response = None
        sequence = self.get_argument('projectId', None)
        owner = self.get_argument('owner', None)
        project_name = self.get_argument('project_name', None)

        # By Sequence number
        if sequence:
            try:
                project = Project.get_project_object(sequence=sequence,
                                                     organization=org)
                if self.current_user in project.members:
                    response['project'] = project.to_json()
                    response['project'].update({
                        'current_sprint':
                        project.get_current_sprint().to_json()
                    })
                else:
                    raise HTTPError(404, **{'reason': "Project Not found."})
            except ValidationError, error:
                raise HTTPError(404, **{'reason': self.error_message(error)})
Exemplo n.º 22
0
                    raise HTTPError(404)

                if not self.current_user in project.members:
                    raise HTTPError(403)

                response['project'] = project.to_json()
                response['project'].update(
                    {'current_sprint': project.get_current_sprint().to_json()})
            except Project.DoesNotExist:
                raise HTTPError(404)

        # All projects for the current
        else:
            # Check if we are returning a list of projects for
            # the logged in user
            projects = Project.objects(
                members=self.current_user).order_by('created_on')
            response['projects'] = []
            for p in projects:
                response['projects'].append(p.to_json())
                response['projects'][-1].update(
                    {'current_sprint': p.get_current_sprint().to_json()})

        self.finish(json.dumps(response))

    def get_valid_project(self, project_id=None, permalink=None):
        if not project_id and not permalink:
            self.send_error(404)
        if project_id:
            try:
                project = Project.get_project_object(sequence=project_id)
                if self.current_user not in project.members:
Exemplo n.º 23
0
                
                if not self.current_user in project.members:
                    raise HTTPError(403)
            
                response['project'] = project.to_json()
                response['project'].update({
                    'current_sprint' : project.get_current_sprint().to_json()
                })
            except Project.DoesNotExist:
                raise HTTPError(404)

        # All projects for the current
        else:
            # Check if we are returning a list of projects for
            # the logged in user
            projects = Project.objects(members=self.current_user
                                       ).order_by('created_on')
            response['projects'] = []
            for p in projects:                
                response['projects'].append(p.to_json())
                response['projects'][-1].update({
                    'current_sprint': p.get_current_sprint().to_json()
                })
        
        self.finish(json.dumps(response))

    def get_valid_project(self, project_id=None, permalink=None):
        if not project_id and not permalink:
            self.send_error(404)
        if project_id:
            try:
                project = Project.get_project_object(sequence=project_id)
Exemplo n.º 24
0
                    raise HTTPError(404)
                
                if not self.current_user in project.members:
                    raise HTTPError(403)
            
                response['project'] = project.to_json()
                response['project'].update({
                    'current_sprint' : project.get_current_sprint().to_json()
                })
            except Project.DoesNotExist:
                raise HTTPError(404)
        else:
            # Check if we are returning a list of projects for
            # the logged in user
            projects = Project.objects(members=self.current_user,
                                       organization=org
                                       ).order_by('created_on')
            response['projects'] = []
            for p in projects:
                response['projects'].append(p.to_json())
                response['projects'][-1].update({
                    'current_sprint': p.get_current_sprint().to_json()
                })
        
        self.finish(json.dumps(response))


        if not self._headers_written:
            self.write(json.dumps(response))
    
    @authenticated
Exemplo n.º 25
0
                                              is_active=True)
                if not project:
                    raise HTTPError(404)

                if not self.current_user in project.members:
                    raise HTTPError(403)

                response['project'] = project.to_json()
                response['project'].update(
                    {'current_sprint': project.get_current_sprint().to_json()})
            except Project.DoesNotExist:
                raise HTTPError(404)
        else:
            # Check if we are returning a list of projects for
            # the logged in user
            projects = Project.objects(members=self.current_user,
                                       organization=org).order_by('created_on')
            response['projects'] = []
            for p in projects:
                response['projects'].append(p.to_json())
                response['projects'][-1].update(
                    {'current_sprint': p.get_current_sprint().to_json()})

        self.finish(json.dumps(response))

        if not self._headers_written:
            self.write(json.dumps(response))

    @authenticated
    def put(self, *args, **kwargs):
        organization = kwargs.get('organization', None)
        org = self.validate_request(organization)
Exemplo n.º 26
0
 def get_project_stories(self, project_id):
     project = self.get_valid_project(project_id=project_id)
     if project and self.current_user in project.members:
         return Project.get_story_list(project)
     else:
         self.send_error(404)
Exemplo n.º 27
0
 def get_project_stories(self, project_id):
     project = self.get_valid_project(project_id=project_id)
     if project and self.current_user in project.members:
         return Project.get_story_list(project)
     else:
         self.send_error(404)