def copy_sounds_only(other): soundboard = Soundboard() soundboard.id = main.newSessionId() soundboard.session_id = None # TODO: Deep copy sounds for soundReferenceKey in other.sound_references: soundReference = SoundReference.get_by_id(soundReferenceKey.id()) soundReferenceCopy = SoundReference.copy(soundReference) db.put(soundReferenceCopy) soundboard.sound_references.append(soundReferenceCopy.key()) soundboard.name = other.name return soundboard
def post(self): soundboard_id = self.request.get('soundboard_id') if soundboard_id is None: self.redirect('/') return soundboard = Soundboard.get_by_id(long(soundboard_id)) if soundboard is None: self.redirect('/') return session_id = self.request.cookies.get('id') if session_id is None: session_id_long = main.newSessionId() self.response.headers.add_header('Set-Cookie', 'id=%d' % session_id_long) else: session_id_long = long(session_id) new_soundboard = Soundboard.copy(soundboard) new_soundboard.session_id = session_id_long db.put(new_soundboard) self.redirect('/board/%d' % new_soundboard.key().id())