def post(self): if not users.get_current_user(): self.redirect(users.create_login_url(self.request.uri)) return neededFields = ("uri", "songName", "authorName", "albumName", "albumYear") errors = {} for field in neededFields: if field not in self.request.params or self.request.params[field] == "": errors[field] = 'Please fill field "' + field + '"' if len(errors) == 0: song = Song() song.owner = users.get_current_user() song.uri = self.request.params["uri"] song.name = self.request.params["songName"] song.author = self.request.params["authorName"] song.album = self.request.params["albumName"] song.albumYear = self.request.params["albumYear"] song.status = True song.put() self.response.out.write path = os.path.join(os.path.dirname(__file__), "../templates/add.html") if "isAlbum" not in self.request.params or self.request.params["isAlbum"] != "on": params = {"uri": "", "songName": "", "authorName": "", "albumName": "", "albumYear": ""} else: params = self.request.params self.response.out.write(template.render(path, {"params": params})) else: self.response.out.write(repr(errors)) self.response.out.write(repr(self.request.params))
def post(self): if not users.get_current_user(): self._print('{"status":"0", "message":"Not logged"}') errors = False params = {} for field in ['song_name', 'author_name', 'album_name', 'album_year', 'song_uri']: if self.request.params.get(field): params[field] = self.request.params.get(field) else: errors = True if not errors: song = Song() song.owner = users.get_current_user() song.uri = params['song_uri'] song.name = params['song_name'] song.author = params['author_name'] song.album = params['album_name'] song.albumYear = params['album_year'] song.status = True; song.put() self._print('{"status":"1", "message":"Added successully"}') else: self._print('{"status":"0", "message":"Not all fields are filled"}')
def post(self): author = self.request.params.get("authorName") albumName = self.request.params.get("albumName") albumYear = self.request.params.get("albumYear") for param in self.request.params: if "songName_" == param[0:9]: self.response.out.write("<br />%s" % param[9 : len(param)]) try: name = self.request.params[param] uri = "http://www.ex.ua/get/" + param[9 : len(param)] song = Song() song.owner = users.get_current_user() song.uri = uri song.name = name song.author = author song.album = albumName song.albumYear = albumYear song.status = True song.put() except Exception, e: handleError(e)