예제 #1
0
    def newProject(self):
        if (self.request('main_text')): return False

        supported_features = Config.get('features')

        if (self.user):
            owner_user_id = self.user.id
            title = self.request('title')
            description = self.request('text')
            organization = self.request('organization')
            locationId = util.try_f(int, self.request('location_id'), -1)
            imageId = self.request('image')
            keywords = [word.strip() for word in self.request('keywords').split(',')] if not util.strNullOrEmpty(self.request('keywords')) else []
            resourceIds = self.request('resources').split(',')
            isOfficial = self.user.isAdmin and supported_features.get('is_official_supported')

            projectId = mProject.createProject(self.db, owner_user_id, title, description, ' '.join(keywords), locationId, imageId, isOfficial, organization)

            for resourceId in resourceIds:
                log.info("*** insert resource id %s" % resourceId)
                mProject.addResourceToProject(self.db, projectId, resourceId)

            if (projectId):
                return projectId
            else:
                log.error("*** couldn't create project")
                return False
        else:
            log.error("*** only logged in users can create projects")
            return False
예제 #2
0
    def addResource(self):
        projectId = self.request('project_id')
        projectResourceId = self.request('project_resource_id')

        if (not projectId or not projectResourceId):
            log.error("*** resource submitted missing an id")
            return False
        else:
            if (mProject.addResourceToProject(self.db, projectId, projectResourceId)):
                # TODO do we need to get the whole project here?    
                project = mProject.Project(self.db, projectId)
                res = mProjectResource.ProjectResource(self.db, projectResourceId)

                if (not mMessaging.emailResourceNotification(res.data.contact_email, projectId, project.data.title, project.data.description, res.data.title)):
                    log.error("*** couldn't email resource id %s" % projectResourceId)
            else:
                log.error("*** couldn't add resource %s to project %s" % (projectResourceId, projectId))
                return False
예제 #3
0
    def addResource(self):
        projectId = self.request('project_id')
        projectResourceId = self.request('project_resource_id')

        if (not projectId or not projectResourceId):
            log.error("*** resource submitted missing an id")
            return False
        else:
            if (mProject.addResourceToProject(self.db, projectId,
                                              projectResourceId)):
                # TODO do we need to get the whole project here?
                project = mProject.Project(self.db, projectId)
                res = mProjectResource.ProjectResource(self.db,
                                                       projectResourceId)

                if (not mMessaging.emailResourceNotification(
                        res.data.contact_email, projectId, project.data.title,
                        project.data.description, res.data.title)):
                    log.error("*** couldn't email resource id %s" %
                              projectResourceId)
            else:
                log.error("*** couldn't add resource %s to project %s" %
                          (projectResourceId, projectId))
                return False