Ejemplo n.º 1
0
    def post(self):
        """Accepts a URL argument and saves it to the database
        """
        title = self.get_argument('title')
        url = self.get_argument('url')
        tags = self.get_argument('tags')

        # TODO The URLField should probably handle this somehow
        if not url.startswith('http'):
            url = 'http://%s' % (url)

        tag_list = None
        if tags:
            tag_list = tags.split(',')

        link_item = {
            'owner_id': self.current_user.id,
            'owner_username': self.current_user.username,
            'created_at': self.current_time,
            'updated_at': self.current_time,
            'title': title,
            'url': url,
            'tags': tag_list,
        }

        item = ListItem(**link_item)

        try:
            item.validate()
        except Exception, e:
            logging.error('Item validatiom failed')
            logging.error(e)
            return self.render_error(500)
Ejemplo n.º 2
0
    def post(self, item_id):
        """Accepts a URL argument and saves it to the database
        """
        item_data = self._load_item(self.current_user.id, item_id)
        item = ListItem(**item_data)

        title = self.get_argument('title')
        url = self.get_argument('url')
        tags = self.get_argument('tags')

        # TODO The URLField should probably handle this somehow
        if not url.startswith('http'):
            url = 'http://%s' % (url)

        tag_list = tags.split(',')

        item.updated_at = self.current_time
        item.title = title
        item.url = url
        item.tags = tag_list

        try:
            item.validate()
        except Exception, e:
            logging.error('Item validatiom failed')
            logging.error(e)
            return self.render_error(500)
Ejemplo n.º 3
0
    def post(self, item_id):
        """Accepts a URL argument and saves it to the database
        """
        item_data = self._load_item(self.current_user.id, item_id)
        item = ListItem(**item_data)

        title = self.get_argument("title")
        url = self.get_argument("url")
        tags = self.get_argument("tags")

        # TODO The URLField should probably handle this somehow
        if not url.startswith("http"):
            url = "http://%s" % (url)

        tag_list = tags.split(",")

        item.updated_at = self.current_time
        item.title = title
        item.url = url
        item.tags = tag_list

        try:
            item.validate()
        except Exception, e:
            logging.error("Item validatiom failed")
            logging.error(e)
            return self.render_error(500)
Ejemplo n.º 4
0
    def post(self):
        """Accepts a URL argument and saves it to the database
        """
        title = self.get_argument("title")
        url = self.get_argument("url")
        tags = self.get_argument("tags")

        # TODO The URLField should probably handle this somehow
        if not url.startswith("http"):
            url = "http://%s" % (url)

        tag_list = None
        if tags:
            tag_list = tags.split(",")

        link_item = {
            "owner_id": self.current_user.id,
            "owner_username": self.current_user.username,
            "created_at": self.current_time,
            "updated_at": self.current_time,
            "title": title,
            "url": url,
            "tags": tag_list,
        }

        item = ListItem(**link_item)

        try:
            item.validate()
        except Exception, e:
            logging.error("Item validatiom failed")
            logging.error(e)
            return self.render_error(500)
Ejemplo n.º 5
0
    def post(self):
        """Accepts a URL argument and saves it to the database
        """
        title = self.get_argument('title')
        url = self.get_argument('url')
        tags = self.get_argument('tags')

        # TODO The URLField should probably handle this somehow
        if not url.startswith('http'):
            url = 'http://%s' % (url)

        tag_list = tags.split(',')

        link_item = {
            'owner_id': self.current_user.id,
            'owner_username': self.current_user.username,
            'created_at': self.current_time,
            'updated_at': self.current_time,

            'title': title,
            'url': url,
            'tags': tag_list,
        }

        item = ListItem(**link_item)
        try:
            item.validate()
        except Exception, e:
            logging.error('Item validatiom failed')
            logging.error(e)
            return self.render_error(500)
Ejemplo n.º 6
0
    def post(self):
        """Accepts a URL argument and saves it to the database
        """
        url = self.get_argument('url')

        if not url.startswith('http'):
            url = 'http://%s' % (url)

        logging.info(self.current_user.to_primitive())
        link_item = {
            'owner': self.current_user.id,
            'username': self.current_user.username,
            'created_at': datetime.utcnow(),
            'updated_at': datetime.utcnow(),
            'url': url,
        }

        item = ListItem(link_item)
        item.validate()
        save_listitem(self.db_conn, item)
        return self.redirect('/list')
Ejemplo n.º 7
0
    def post(self):
        """Accepts a URL argument and saves it to the database
        """
        url = self.get_argument('url')

        if not url.startswith('http'):
            url = 'http://%s' % (url)
            
        link_item = {
            'owner': self.current_user.id,
            'username': self.current_user.username,
            'created_at': self.current_time,
            'updated_at': self.current_time,
            'url': url,
        }

        item = ListItem(**link_item)
        item.validate()
        save_listitem(self.db_conn, item)
            
        return self.redirect('/')
Ejemplo n.º 8
0
    def post(self):
        """Accepts a URL argument and saves it to the database
        """
        url = self.get_argument("url")

        if not url.startswith("http"):
            url = "http://%s" % (url)

        logging.info(self.current_user.to_primitive())
        link_item = {
            "owner": self.current_user.id,
            "username": self.current_user.username,
            "created_at": datetime.utcnow(),
            "updated_at": datetime.utcnow(),
            "url": url,
        }

        item = ListItem(link_item)
        item.validate()
        save_listitem(self.db_conn, item)
        return self.redirect("/list")