def get(self): user = users.get_current_user() url_dict = model.check_if_login(self, user) keyword = self.request.get('keyword') if keyword: stream_found = model.search_stream(keyword) else: stream_found = [] streams = model.search_stream("") stream_names = [] for stream in streams: stream_names.append(str(stream.stream_name)) template_input = { 'stream_list': stream_found, 'stream_names': stream_names } template_values = model.merge_two_dicts(template_input, url_dict) template = JINJA_ENVIRONMENT.get_template('templates/search_page.html') self.response.write(template.render(template_values))
def get(self): user = users.get_current_user() url_dict = model.check_if_login(self, user) stream_names = [] for stream in model.search_stream(""): stream_names.append(str(stream.stream_name)) template_input = { 'stream_names': stream_names } template_values = model.merge_two_dicts(template_input, url_dict) template = JINJA_ENVIRONMENT.get_template('templates/main_login_page.html') self.response.write(template.render(template_values))
def get(self): user = users.get_current_user() url_dict = model.check_if_login(self, user) stream_name = self.request.get('stream') loaded_photo = self.request.get('loaded', default_value='9') photos = model.get_photo_by_stream(stream_name) # adding fake gps information model.shuffle_stream_geo_info(stream_name) time.sleep(0.1) photos = sorted(photos, key=lambda x: x.last_update, reverse=True) current_date = datetime.datetime.utcnow().date() a_year_before = current_date + relativedelta(years=-1) more = loaded_photo < len(photos) photo_key = [] for i in range(min(loaded_photo, len(photos))): photo_key.append(photos[i].blob_key) if user: is_owner = model.get_stream_by_name(stream_name).owner == model.get_user(user.user_id()).key else: is_owner = False model.add_view_counts(stream_name) stream_names = [] for stream in model.search_stream(""): stream_names.append(str(stream.stream_name)) upload_url = blobstore.create_upload_url('/upload_image') template_input = { 'is_owner': is_owner, 'img_ids': photo_key, 'upload_url': upload_url, 'more': more, 'stream_name': stream_name, 'loaded': loaded_photo, 'stream_names': stream_names, 'current_date': current_date.strftime("%Y, %m, %d"), 'a_year_before': a_year_before.strftime("%Y, %m, %d") } template_values = model.merge_two_dicts(template_input, url_dict) template = JINJA_ENVIRONMENT.get_template('templates/view_one_page.html') self.response.write(template.render(template_values))
def get(self): user = users.get_current_user() print(user.user_id) url_dict = model.check_if_login(self, user) streams = model.get_stream_list_by_user(user.user_id()) sub_streams = model.get_subscribed_stream(user.user_id()) stream_names = [] for stream in model.search_stream(""): stream_names.append(str(stream.stream_name)) template_input = { 'streams': streams, 'sub_streams': sub_streams, 'stream_names': stream_names } template_values = model.merge_two_dicts(template_input, url_dict) template = JINJA_ENVIRONMENT.get_template('templates/manage_page.html') self.response.write(template.render(template_values))
def get(self): user = users.get_current_user() url_dict = model.check_if_login(self, user) stream_name = self.request.get('stream') photo = self.request.get('photo') streams = model.search_stream("") stream_names = [] for stream in streams: stream_names.append(str(stream.stream_name)) template_input = { 'error_message': 'stream name: ' + stream_name + ' is already occupied!', 'stream_names': stream_names } if photo: template_input['error_message'] = 'photo ' + photo template_values = model.merge_two_dicts(template_input, url_dict) template = JINJA_ENVIRONMENT.get_template('templates/error_page.html') self.response.write(template.render(template_values))
def get(self): user = users.get_current_user() url_dict = model.check_if_login(self, user) # model.update_views_in_past_hour() will run by cron.yaml every 5 min streams = model.get_all_recent_stream() sorted_streams = sorted(streams, key=lambda x: x.views_in_last_hour, reverse=True) num_of_streams = len(sorted_streams) if num_of_streams >= 3: num_of_streams = 3 sorted_streams = sorted_streams[:3] streams = model.search_stream("") stream_names = [] for stream in streams: stream_names.append(str(stream.stream_name)) if user: trending_setting = model.get_trending_setting(user.user_id()) logged_in = True else: trending_setting = "no" logged_in = False template_input = { 'logged_in': logged_in, 'trending_setting': trending_setting, 'trending_streams': sorted_streams, 'num_of_streams': num_of_streams, 'stream_names': stream_names } template_values = model.merge_two_dicts(template_input, url_dict) template = JINJA_ENVIRONMENT.get_template('templates/trending_page.html') self.response.write(template.render(template_values))