def post(self): req = self.request data = populate_user() if not data['logged_in']: return self.redirect('/') user_id = data['nickname'] stream_name = req.get('name') stream_tags = req.get('tags').split(',') stream_cover = req.get('cover') or DEFAULT_COVER stream_add_subscribers_email_list = req.get('email_list').split(',') stream_email_body = req.get('email_body') if not stream_name or Stream.get_by_id(stream_name): data['msg'] = 'Sorry! Stream already exists/Name empty.' template = JINJA_ENVIRONMENT.get_template('error.html') return self.response.write(template.render(data)) stream = Stream(id=stream_name, tags=stream_tags, cover_url=stream_cover).put() user = User.get_by_id(user_id) user.owned_ids.append(stream) user.put() # on successful insert, send email if (Stream.get_by_id(stream_name)): send_subscribtion_invite_email(stream_add_subscribers_email_list, stream_email_body, stream_name, self.request.url) return self.redirect('/manage')
def post(self): req = self.request data = populate_user() if not data['logged_in']: return self.redirect('/') user_id = data['nickname'] stream_name = req.get('name') stream_tags = req.get('tags').split(',') stream_cover = req.get('cover') or DEFAULT_COVER stream_add_subscribers_email_list = req.get( 'email_list').split(',') stream_email_body = req.get('email_body') if not stream_name or Stream.get_by_id(stream_name): data['msg'] = 'Sorry! Stream already exists/Name empty.' template = JINJA_ENVIRONMENT.get_template('error.html') return self.response.write(template.render(data)) stream = Stream(id=stream_name, tags=stream_tags, cover_url=stream_cover).put() user = User.get_by_id(user_id) user.owned_ids.append(stream) user.put() # on successful insert, send email if(Stream.get_by_id(stream_name)): send_subscribtion_invite_email(stream_add_subscribers_email_list, stream_email_body, stream_name, self.request.url) return self.redirect('/manage')
def post(self): stream_id = self.request.get('stream_id') template = JINJA_ENVIRONMENT.get_template('error.html') data = {} if not Stream.get_by_id(stream_id): data['msg'] = 'Stream id %s not found!' % stream_id return self.response.write(template.render(data)) if not self.request.get('files[]'): data['msg'] = 'Hey, Upload an image first!' return self.response.write(template.render(data)) results = [] for img in self.request.get_all('files[]'): results.append({'name': '', 'url': '', 'type': '', 'size': 64}) avatar = images.resize(img, 320, 320) lat = self.request.get('lat') lat = float(lat) if lat else None lng = self.request.get('lng') lng = float(lng) if lng else None image = Image(data=db.Blob(avatar), comment=self.request.get('comment'), lat=lat, lng=lng).put() Stream.append_image(stream_id, image) s = json.dumps({'files': results}, separators=(',', ':')) self.response.headers['Content-Type'] = 'application/json' return self.response.write(s)
def post(self): if not populate_user()['logged_in']: return self.redirect('/') user_id = populate_user()['nickname'] stream_id = self.request.get('stream_name') user = User.get_by_id(user_id) if not user: return self.response.out.write("Not Found!") user.subscribed_ids.append(Stream.get_by_id(stream_id).key) user.put() return self.redirect('/view?stream_name=' + stream_id)
def post(self): if not populate_user()['logged_in']: return self.redirect('/') user_id = populate_user()['nickname'] stream_id = self.request.get('stream_name') user = User.get_by_id(user_id) if not user: return self.response.out.write("Not Found!") user.subscribed_ids.append(Stream.get_by_id(stream_id).key) user.put() return self.redirect('/view?stream_name='+stream_id)
def get(self): self.response.headers['Content-Type'] = 'application/json' stream_name = self.request.get('stream_name') if not stream_name: return self.show_all_streams() stream = Stream.get_by_id(stream_name) if not stream: return self.error(404) # Increment View Count stream.view_count += 1 stream.put() View(stream_id=stream.key).put() return self.response.out.write( json.dumps(stream.to_dict(), cls=MyEncoder))
def get(self): self.response.headers['Content-Type'] = 'application/json' stream_name = self.request.get('stream_name') if not stream_name: return self.show_all_streams() stream = Stream.get_by_id(stream_name) if not stream: return self.error(404) # Increment View Count stream.view_count += 1 stream.put() View(stream_id=stream.key).put() return self.response.out.write(json.dumps(stream.to_dict(), cls=MyEncoder))
def post(self): body = json.loads(self.request.body) user_id = body['user_id'] if not user_id or not User.get_by_id(user_id): return self.redirect('/') user = User.get_by_id(user_id) stream_ids = body['stream_ids'] for stream_id in stream_ids: stream = Stream.get_by_id(stream_id) if not stream: continue stream_key = stream.key if user.is_owned(stream_id): stream_key.delete() user.owned_ids = [sub for sub in user.owned_ids if sub.id() not in stream_ids] user.put() Leaderboard.refresh()
def post(self): body = json.loads(self.request.body) user_id = body['user_id'] if not user_id or not User.get_by_id(user_id): return self.redirect('/') user = User.get_by_id(user_id) stream_ids = body['stream_ids'] for stream_id in stream_ids: stream = Stream.get_by_id(stream_id) if not stream: continue stream_key = stream.key if user.is_owned(stream_id): stream_key.delete() user.owned_ids = [ sub for sub in user.owned_ids if sub.id() not in stream_ids ] user.put() Leaderboard.refresh()