コード例 #1
0
    def endorse(self):
        projectId = self.request('project_id')

        if (not self.user or not self.user.isLeader):
            log.error(
                "*** endorsement submitted w/o logged in user or with non-project leader user account"
            )
            return False
        else:
            isEndorsed = mProject.endorse(self.db, projectId, self.user.id)

            if (isEndorsed):
                # TODO do we need to get the whole project here?
                project = mProject.Project(self.db, projectId)

                # email admin
                if (not mMessaging.emailProjectEndorsement(
                        project.data.owner_email, project.data.title, "%s %s" %
                    (self.user.firstName, self.user.lastName))):
                    log.error(
                        "*** couldn't email admin on user_id = %s endorsing project %s"
                        % (self.user.id, projectId))

                # add a message to the queue about the join
                message = 'Congratulations! Your group has now been endorsed by %s %s.' % (
                    self.user.firstName, self.user.lastName)

                if (not mProject.addMessage(self.db, projectId, message,
                                            'endorsement', self.user.id)):
                    log.error(
                        "*** new message not created for user %s on endorsing project %s"
                        % (self.user.id, projectId))

            return isEndorsed
コード例 #2
0
    def showProject(self, projectId):
        """The main project detail view controller."""
        if (projectId):
            project = mProject.Project(self.db, projectId)

            if (project.data):
                projDictionary = project.getFullDictionary()

                project_user = self.getProjectUser(projectId)
                self.template_data['project_user'] = dict(
                    data=project_user, json=json.dumps(project_user))

                project_proxy = self.getProject(projectId)
                project_proxy.json = json.dumps(projDictionary)
                project_proxy.data = projDictionary

                self.template_data['project'] = project_proxy

                import giveaminute.filters as gam_filters
                gam_filters.register_filters()
                return self.render('project')
            else:
                return self.not_found()
        else:
            return self.not_found()
コード例 #3
0
    def getProjectData(self):
        projectId = self.request('project_id')

        project = mProject.Project(self.db, projectId)

        return self.json(
            mProject.smallProject(
                project.id, project.data.title, project.data.description,
                project.data.image_id, project.data.num_members,
                project.data.owner_user_id, project.data.owner_first_name,
                project.data.owner_last_name, project.data.owner_image_id))
コード例 #4
0
    def getRelatedResources(self):
        projectId = self.request('project_id')
        resources = []

        project = mProject.Project(self.db, projectId)

        keywords = project.data.keywords.split()
        locationId = project.data.location_id

        resources = mProjectResource.searchProjectResources(
            self.db, keywords, locationId)

        obj = dict(resources=resources)

        return self.json(obj)
コード例 #5
0
    def showConversationRSS(self, projectId):
        if (projectId):
            project = mProject.Project(self.db, projectId)
            projDictionary = project.getFullDictionary()

            self.template_data['project'] = dict(
                json=json.dumps(projDictionary), data=projDictionary)

            msgs = self.template_data['project']['data']['info']['messages'][
                'items']

            for item in msgs:
                item['created'] = datetime.datetime.strptime(
                    item['created'],
                    '%Y-%m-%d %H:%M:%S').strftime('%a, %d %b %Y %H:%M:%S EST')

            return self.render('project/conversation_rss',
                               suffix='xml.rss',
                               content_type='application/rss+xml')
        else:
            return self.not_found()
コード例 #6
0
    def join(self):
        projectId = self.request('project_id')

        if (not self.user):
            log.error("*** join submitted w/o logged in user")
            return False
        elif (not projectId):
            log.error("*** join submitted w/o logged project id")
            return False

        else:
            isJoined = mProject.join(self.db, projectId, self.user.id)

            if (isJoined):
                project = mProject.Project(self.db, projectId)

                # add a message to the queue about the join
                message = 'New Member! Your project now has %s total!' % project.data.num_members

                # email admin
                if (not mMessaging.emailProjectJoin(
                        project.data.owner_email, projectId,
                        project.data.title, self.user.id,
                        mProject.userNameDisplay(
                            self.user.firstName, self.user.lastName,
                            self.user.affiliation,
                            mProject.isFullLastName(
                                self.user.groupMembershipBitmask)))):
                    log.error(
                        "*** couldn't email admin on user_id = %s joining project %s"
                        % (self.user.id, projectId))

                if (not mProject.addMessage(self.db, projectId, message,
                                            'join', self.user.id)):
                    log.error(
                        "*** new message not created for user %s on joining project %s"
                        % (self.user.id, projectId))

        return isJoined
コード例 #7
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
コード例 #8
0
    def join(self):
        projectId = self.request('project_id')
        description = self.request('message')

        if (not self.user):
            log.error("*** join submitted w/o logged in user")
            return False
        elif (not projectId):
            log.error("*** join submitted w/o logged project id")
            return False
        elif (util.strNullOrEmpty(description)):
            log.error("*** join submitted w/o idea")
            return False
        else:
            isJoined = mProject.join(self.db, projectId, self.user.id)

            if (isJoined):
                project = mProject.Project(self.db, projectId)

                # create the user's "hello there" idea and add to project
                newIdeaId = mIdea.createIdea(self.db, description,
                                             project.data.location_id, 'web',
                                             self.user.id, self.user.email)

                if (newIdeaId):
                    if (not mIdea.addIdeaToProject(self.db, newIdeaId,
                                                   projectId)):
                        log.error(
                            "*** new idea not created for user %s on joining project %s"
                            % (self.user.id, projectId))
                else:
                    log.error(
                        "*** new idea not created for user %s on joining project %s"
                        % (self.user.id, projectId))

                # automatically insert any ideas attached to invites for this user and this project
                if (not mIdea.addInvitedIdeaToProject(self.db, projectId,
                                                      self.user.id)):
                    log.error(
                        "*** couldn't add invited idea to project for user %s on joining project %s"
                        % (self.user.id, projectId))

                # add a message to the queue about the join
                message = 'New Member! Your project now has %s total!' % project.data.num_members

                # email admin
                if (not mMessaging.emailProjectJoin(
                        project.data.owner_email, projectId,
                        project.data.title, self.user.id,
                        mProject.userNameDisplay(
                            self.user.firstName, self.user.lastName,
                            self.user.affiliation,
                            mProject.isFullLastName(
                                self.user.groupMembershipBitmask)))):
                    log.error(
                        "*** couldn't email admin on user_id = %s joining project %s"
                        % (self.user.id, projectId))

                if (not mProject.addMessage(self.db, projectId, message,
                                            'join', self.user.id, newIdeaId)):
                    log.error(
                        "*** new message not created for user %s on joining project %s"
                        % (self.user.id, projectId))

        return isJoined