Beispiel #1
0
    def post(self):
        """Renders a JSON list of link data
        """
        ### Stream offset
        updated_offset = self.get_stream_offset()

        ### Load the owner_id's list of items, sorted by `updated_at`.
        items_qs = load_listitems(self.db_conn,
                                  owner_id=self.current_user.id,
                                  updated_after=updated_offset)
        items_qs.sort('updated_at', direction=pymongo.DESCENDING)
        num_items = items_qs.count()

        ### Page list
        (page, count, skip) = self.get_paging_arguments()

        items_qs.skip(skip)
        items_qs.limit(count)

        ### Generate safe list out of loaded items
        items = [ListItem.make_ownersafe(i) for i in items_qs]

        data = {
            'num_items': num_items,
            'items': items,
        }

        self.add_to_payload('data', data)

        return self.render(status_code=200)
Beispiel #2
0
    def post(self):
        """Renders a JSON list of link data
        """
        ### Stream offset
        updated_offset = self.get_stream_offset()

        ### Load the owner_id's list of items, sorted by `updated_at`.
        items_qs = load_listitems(self.db_conn, owner_id=self.current_user.id, updated_after=updated_offset)
        items_qs.sort("updated_at", direction=pymongo.DESCENDING)
        num_items = items_qs.count()

        ### Page list
        (page, count, skip) = self.get_paging_arguments()

        items_qs.skip(skip)
        items_qs.limit(count)

        ### Generate safe list out of loaded items
        items = [ListItem.make_ownersafe(i) for i in items_qs]

        data = {"num_items": num_items, "items": items}

        self.add_to_payload("data", data)

        return self.render(status_code=200)
Beispiel #3
0
    def prepare_items(self, query_set, sort_field='updated_at'):
        query_set.sort(sort_field, direction=pymongo.DESCENDING)

        items = []
        for i in query_set:
            item_id = i['_id']
            item = ListItem.make_ownersafe(i)

            updated = millis_to_datetime(item['updated_at'])
            formatted_date = prettydate(updated)
            item['formatted_date'] = formatted_date

            item['id'] = item_id
            items.append(item)

        return items
Beispiel #4
0
    def get(self):
        """Renders a template with our links listed
        """
        items_qs = load_listitems(self.db_conn, self.current_user.id)
        items_qs.sort('updated_at', direction=pymongo.DESCENDING)
        num_items = items_qs.count()
        
        items = [ListItem.make_ownersafe(i) for i in items_qs]

        data = {
            'num_items': num_items,
            'items': items,
        }

        self.set_body(json.dumps(data))
        return self.render(status_code=200)
Beispiel #5
0
    def prepare_items(self, query_set, sort_field="updated_at"):
        query_set.sort(sort_field, direction=pymongo.DESCENDING)

        items = []
        for i in query_set:
            item_id = i["_id"]
            item = ListItem.make_ownersafe(i)

            updated = millis_to_datetime(item["updated_at"])
            formatted_date = prettydate(updated)
            item["formatted_date"] = formatted_date

            item["id"] = item_id
            items.append(item)

        return items
Beispiel #6
0
    def get(self):
        """Renders a template with our links listed
        """
        items_qs = load_listitems(self.db_conn, self.current_user.id)
        items_qs.sort('updated_at', direction=pymongo.DESCENDING)
        num_items = items_qs.count()
        
        items = [ListItem.make_ownersafe(i) for i in items_qs]

        data = {
            'num_items': num_items,
            'items': items,
        }

        self.set_body(json.dumps(data))
        return self.render(status_code=200)