parameters: (self)
docstring: Extract picture and file linked to the picture from request, then
          creates a picture in database for the contact who sends it. An
          activity is created too.
  
          If author is not inside trusted contacts, the request is rejected.
docstring_summary: Extract picture and file linked to the picture from request, then
          creates a picture in database for the contact who sends it. An
          activity is created too.
docstring_tokens: Extract picture and file linked to the picture from request then creates a picture in database for the contact who sends it . An activity is created too .
function: def post(self):
          '''
          Extract picture and file linked to the picture from request, then
          creates a picture in database for the contact who sends it. An
          activity is created too.
  
          If author is not inside trusted contacts, the request is rejected.
          '''
  
          file = self.request.files['picture'][0]
          data = json_decode(self.get_argument("json"))
  
          if file and data:
              contact = ContactManager.getTrustedContact(
                      data.get("authorKey", ""))
  
              if contact:
                  date = date_util.get_date_from_db_date(data.get("date", ""))
  
                  picture = PictureManager.get_contact_picture(
                              contact.key, data.get("date", ""))
  
                  if not picture:
                      picture = Picture(
                          _id=data.get("_id", ""),
                          title=data.get("title", ""),
                          path=data.get("path", ""),
                          contentType=data.get("contentType", ""),
                          authorKey=data.get("authorKey", ""),
                          author=data.get("author", ""),
                          tags=contact.tags,
                          date=date,
                          isMine=False,
                          isFile=False
                      )
                      picture.save()
                      picture.put_attachment(content=file["body"],
                                             name="th_" + picture._id)
                      picture.save()
  
                      self.create_creation_activity(contact,
                              picture, "publishes", "picture")
  
                  logger.info("New picture from %s" % contact.name)
                  self.return_success("Creation succeeds", 201)
  
              else:
                  self.return_failure("Author is not trusted.", 400)
          else:
              self.return_failure("No data sent.", 405)
function_tokens: def post ( self ) : file = self . request . files [ 'picture' ] [ 0 ] data = json_decode ( self . get_argument ( "json" ) ) if file and data : contact = ContactManager . getTrustedContact ( data . get ( "authorKey" , "" ) ) if contact : date = date_util . get_date_from_db_date ( data . get ( "date" , "" ) ) picture = PictureManager . get_contact_picture ( contact . key , data . get ( "date" , "" ) ) if not picture : picture = Picture ( _id = data . get ( "_id" , "" ) , title = data . get ( "title" , "" ) , path = data . get ( "path" , "" ) , contentType = data . get ( "contentType" , "" ) , authorKey = data . get ( "authorKey" , "" ) , author = data . get ( "author" , "" ) , tags = contact . tags , date = date , isMine = False , isFile = False ) picture . save ( ) picture . put_attachment ( content = file [ "body" ] , name = "th_" + picture . _id ) picture . save ( ) self . create_creation_activity ( contact , picture , "publishes" , "picture" ) logger . info ( "New picture from %s" % contact . name ) self . return_success ( "Creation succeeds" , 201 ) else : self . return_failure ( "Author is not trusted." , 400 ) else : self . return_failure ( "No data sent." , 405 )