Ejemplo n.º 1
0
 def rawPost(self, ballotID, voteID):
     vote = self.getVote(ballotID, voteID)
     id = self.request.get('release.id', default_value=None)
     mbid = self.request.get('release.mbid', default_value=None)
     if id:
         vote.release = db.Key.from_path(Release.kind(), int(id))
     elif mbid:
         vote.release = Release.get(mbid)
     else:
         id = self.request.get('artist.id', default_value=None)
         mbid = self.request.get('artist.mbid', default_value=None)
         if id:
             artist = db.Key.from_path(Artist.kind(), int(id))
         elif mbid:
             artist = Artist.get(mbid)
         else:
             artist = Artist(name=self.request.get('artist'),
                             sortname=self.request.get('sortname'))
             artisturl = self.request.get('artisturl', default_value=None)
             if artisturl:
                 artist.url = artisturl
             artist.put()
         release = Release(artist=artist, title=self.request.get('title'))
         releaseurl = self.request.get('releaseurl', default_value=None)
         if releaseurl:
             release.url = releaseurl
         release.put()
         vote.release = release
     vote.put()
     next = Vote.gql('WHERE release = :1 ORDER BY artist', None).get()
     if next:
         key = next.key()
         self.redirect('../%d/%d' % (key.parent().id(), key.id()))
     else:
         self.redirect('../..')