Esempio n. 1
0
 def updateOrganizationProject(self, json):
     dao = OrganizationDao.OrganizationDao()
     pdao = ProjectDao.ProjectDAO()
     OrganizationID = json['OrganizationID']
     ProjectTitle = json['ProjectTitle']
     ProjectDescription = json['ProjectDescription']
     ProjectViewCounter = json['ProjectViewCounter']
     CreationDate = json['CreationDate']
     LastUpdate = json['LastUpdate']
     ProjectType = json['ProjectType']
     Status = json['Status']
     if dao.getOrganization(OrganizationID):
         if OrganizationID and ProjectTitle and ProjectDescription and ProjectViewCounter and CreationDate and LastUpdate and ProjectType and Status:
             ProjectID = pdao.update(ProjectTitle, ProjectDescription,
                                     ProjectViewCounter, CreationDate
                                     and LastUpdate, ProjectType, Status)
             if ProjectID:
                 orgprojectid = dao.updateOrganizationProject(
                     OrganizationID, ProjectID, Status)
                 if orgprojectid:
                     return jsonify(ProjectID=ProjectID), 200
                 else:
                     return jsonify(ERROR="Invalid arguments "), 400
             else:
                 return jsonify(ERROR="coulnt update into project"), 400
         else:
             return jsonify(ERROR="Invalid Arguments"), 400
     else:
         return jsonify(ERROR="Invalid organizationID"), 400
 def getProjectById(self, ProjectID):
     dao = ProjectDao.ProjectDAO()
     row = dao.getProjectById(ProjectID)
     if not row:
         return jsonify(Error="Project Not Found"), 404
     else:
         Project = self.build_project_dict(row)
         return jsonify(Project=Project)
 def getAllProjects(self):
     dao = ProjectDao.ProjectDAO()
     Project_list = dao.getAllProjects()
     result_list = []
     for row in Project_list:
         result = self.build_project_dict(row)
         result_list.append(result)
     return jsonify(Project=result_list)
 def insertProjectJson(self, json):
     projectname = json['ProjectName']
     projectdescription = json['ProjectDescription']
     imagelogo = json['ImageLogo']
     userid = json['UserID']
     projecttypenumber = json['ProjectTypeNumber']
     status = json['Status']
     if projectname and projectdescription and imagelogo and userid and projecttypenumber and status:
         dao = ProjectDao.ProjectDAO()
         projectid = dao.insert(projectname, projectdescription, imagelogo,
                                userid, projecttypenumber, status)
         result = self.build_project_attributes(projectid, projectname,
                                                projectdescription,
                                                imagelogo, userid,
                                                projecttypenumber, status)
         return jsonify(Project=result), 201
     else:
         return jsonify(Error="Unexpected attributes in post request"), 400
 def updateProjectJson(self, projectid, json):
     dao = ProjectDao.ProjectDAO()
     if not dao.getProjectById(projectid):
         return jsonify(Error="Project not found."), 404
     else:
         projectname = json['ProjectName']
         projectdescription = json['ProjectDescription']
         imagelogo = json['ImageLogo']
         userid = json['UserID']
         projecttypenumber = json['ProjectTypeNumber']
         status = json['Status']
         if projectname and projectdescription and imagelogo and userid and projecttypenumber and status:
             dao.update(projectname, projectdescription, imagelogo, userid,
                        projecttypenumber, status)
             result = self.build_project_attributes(projectid, projectname,
                                                    projectdescription,
                                                    imagelogo, userid,
                                                    projecttypenumber,
                                                    status)
             return jsonify(Project=result), 200
Esempio n. 6
0
    def deleteorganizationProject(self, json):
        dao = OrganizationDao.OrganizationDao()
        pdao = ProjectDao.ProjectDAO()
        OrganizationID = json['OrganizationID']
        ProjectID = json['ProjectID']
        LastUpdate = json['LastUpdate']
        Status = json['Status']
        if dao.getOrganization(OrganizationID):
            if OrganizationID and LastUpdate and Status and ProjectID:
                output = pdao.delete(ProjectID)  #lastupdate
                if output:
                    orgprojectid = dao.deleteOrganizationProject(
                        OrganizationID, ProjectID)

                    if orgprojectid:
                        return jsonify(ProjectID=ProjectID), 200
                    else:
                        return jsonify(ERROR="Invalid arguments "), 400
                else:
                    return jsonify(ERROR="coulnt update into project"), 400
            else:
                return jsonify(ERROR="Invalid Arguments"), 400
        else:
            return jsonify(ERROR="Invalid organizationID"), 404