Ejemplo n.º 1
0
    def addResource(self):
        if (self.request('main_text')): return False

        title = self.request('title')
        description = self.request('description')
        physical_address = self.request('physical_address')
        location_id = util.try_f(int, self.request('location_id'), -1)
        url = util.makeUrlAbsolute(
            self.request('url')) if self.request('url') else None
        keywords = ' '.join([
            word.strip() for word in self.request('keywords').split(',')
        ]) if not util.strNullOrEmpty(self.request('keywords')) else None
        contact_name = self.request('contact_name')
        contact_email = self.request('contact_email')
        facebook_url = util.makeUrlAbsolute(self.request(
            'facebook_url')) if self.request('facebook_url') else None
        twitter_url = util.makeUrlAbsolute(self.request(
            'twitter_url')) if self.request('twitter_url') else None
        image_id = util.try_f(int, self.request('image'))

        # TODO this is a temp fix for a form issue
        if (contact_name == 'null'):
            contact_name = None

        try:
            projectResourceId = self.db.insert(
                'project_resource',
                title=title,
                description=description,
                physical_address=physical_address,
                location_id=location_id,
                url=url,
                facebook_url=facebook_url,
                twitter_url=twitter_url,
                keywords=keywords,
                contact_name=contact_name,
                contact_email=contact_email,
                created_datetime=None,
                image_id=image_id,
                is_hidden=1,
                contact_user_id=self.user.id)

            return True
        except Exception, e:
            log.info("*** couldn't add resource to system")
            log.error(e)
            return False
Ejemplo n.º 2
0
    def addResource(self):
        if (self.request('main_text')): return False

        title = self.request('title')
        description = self.request('description')
        physical_address = self.request('physical_address')
        location_id = util.try_f(int, self.request('location_id'), -1)
        url = util.makeUrlAbsolute(self.request('url')) if self.request('url')  else None
        keywords = ' '.join([word.strip() for word in self.request('keywords').split(',')]) if not util.strNullOrEmpty(self.request('keywords')) else None
        contact_name = self.request('contact_name')
        contact_email = self.request('contact_email')
        facebook_url = util.makeUrlAbsolute(self.request('facebook_url')) if self.request('facebook_url') else None
        twitter_url = util.makeUrlAbsolute(self.request('twitter_url')) if self.request('twitter_url') else None
        image_id = util.try_f(int, self.request('image')) 
        
        # TODO this is a temp fix for a form issue
        if (contact_name == 'null'):
            contact_name = None
            
        try:
            projectResourceId = self.db.insert('project_resource', 
                                        title = title,
                                        description = description,
                                        physical_address = physical_address,
                                        location_id = location_id,
                                        url = url,
                                        facebook_url = facebook_url,
                                        twitter_url = twitter_url,
                                        keywords = keywords,
                                        contact_name = contact_name,
                                        contact_email = contact_email,
                                        created_datetime = None,
                                        image_id = image_id,
                                        is_hidden = 1,
                                        contact_user_id = self.user.id)
            
            return True
        except Exception,e:
            log.info("*** couldn't add resource to system")
            log.error(e)
            return False
Ejemplo n.º 3
0
    def addLink(self):
        if (self.request('main_text')): return False

        projectId = self.request('project_id')
        title = self.request('title')
        url = util.makeUrlAbsolute(self.request('url')) if self.request('url') else None

        if (not projectId or util.strNullOrEmpty(title) or util.strNullOrEmpty(url)):
            log.error("*** link submitted w/o id, title, or url")
            return False
        else:
            return mProject.addLinkToProject(self.db, projectId, title, url)
Ejemplo n.º 4
0
    def addLink(self):
        if (self.request('main_text')): return False

        projectId = self.request('project_id')
        title = self.request('title')
        url = util.makeUrlAbsolute(
            self.request('url')) if self.request('url') else None

        if (not projectId or util.strNullOrEmpty(title)
                or util.strNullOrEmpty(url)):
            log.error("*** link submitted w/o id, title, or url")
            return False
        else:
            return mProject.addLinkToProject(self.db, projectId, title, url)
Ejemplo n.º 5
0
    def updateResourceUrl(self):
        resourceId = util.try_f(int, self.request('resource_id'))

        if (not self.user or not self.user.isResourceOwner(resourceId)):
            log.error(
                "*** resource edit attempt without ownership, resource id %s" %
                resourceId)
            return False

        url = self.request('url')

        if (url):
            return mProjectResource.updateProjectResourceTextData(
                self.db, resourceId, 'url', util.makeUrlAbsolute(url))
        else:
            log.error("*** resource edit attempt without url, resource id %s" %
                      resourceId)
            return False
Ejemplo n.º 6
0
    def updateResourceUrl(self):
        resourceId = util.try_f(int, self.request('resource_id'))

        if (not self.user or not self.user.isResourceOwner(resourceId)): 
            log.error("*** resource edit attempt without ownership, resource id %s" % resourceId)
            return False

        url = self.request('url')
        
        if (url):
            return mProjectResource.updateProjectResourceTextData(self.db, resourceId, 'url', util.makeUrlAbsolute(url))
        else:
            log.error("*** resource edit attempt without url, resource id %s" % resourceId)
            return False