Пример #1
0
 def GET(self, id):
     params = web.input()
     manager = managers.consumer_manager()
     consumer = manager.get_consumer(id)
     consumer = expand_consumers(params, [consumer])[0]
     href = serialization.link.current_link_obj()
     consumer.update(href)
     return self.ok(consumer)
Пример #2
0
 def PUT(self, id):
     body = self.params()
     delta = body.get('delta')
     manager = managers.consumer_manager()
     consumer = manager.update(id, delta)
     href = serialization.link.current_link_obj()
     consumer.update(href)
     return self.ok(consumer)
Пример #3
0
    def POST(self):
        body = self.params()
        id = body.get('id')
        display_name = body.get('display_name')
        description = body.get('description')
        notes = body.get('notes')

        manager = managers.consumer_manager()
        consumer = manager.register(id, display_name, description, notes)
        consumer.update({'_href': serialization.link.child_link_obj(consumer['id'])})
        return self.created(consumer['_href'], consumer)
Пример #4
0
    def PUT(self, consumer_id, content_type):
        """
        Update the association of a profile with a consumer by content type ID.
        @param consumer_id: A consumer ID.
        @type consumer_id: str
        @param content_type: A content unit type ID.
        @type content_type: str
        @return: The updated model object:
            {consumer_id:<str>, content_type:<str>, profile:<dict>}
        @rtype: dict
        """
        body = self.params()
        profile = body.get('profile')

        manager = managers.consumer_profile_manager()
        consumer = manager.update(consumer_id, content_type, profile)

        link = serialization.link.child_link_obj(consumer_id, content_type)
        consumer.update(link)

        return self.ok(consumer)