def get(self): page_id = self.request.get('page_id') if page_id != '': page_id = int(page_id) else: page_id = 1 user_list_query = UserPrefs.all().filter('activate_flg =', True).filter('schedule_list =', datetime.datetime.now().hour) last_cursor = memcache.get('notify_cursor_%d' % page_id) if last_cursor: user_list_query.with_cursor(last_cursor) user_list = user_list_query.fetch(10) if user_list is not None: logging.info('count: %d' % len(user_list)) for user in user_list: rand = random.random() * 100 #rand = 0 logging.info('random: %f, probability: %f' % (rand, user.notify_probability)) if rand < user.notify_probability: logging.info('Add notify task.') try: #bot_id=1 bot_id = user.bot_prefs_key.key().id() taskqueue.add(url = '/task/find_device', params = {'user_id': user.key().id(), 'bot_id': bot_id}) except: logging.error('Add task failed.') else: logging.info('Boo...') cursor = user_list_query.cursor() user_list_query = UserPrefs.all().filter('activate_flg =', True).filter('schedule_list =', datetime.datetime.now().hour) user_list_query.with_cursor(cursor) user_list = user_list_query.fetch(10) logging.info('count: %d' % len(user_list)) if memcache.get('notify_cursor_%d' % (page_id+1)): memcache.delete('notify_cursor_%d' % (page_id+1)) memcache.add('notify_cursor_%d' % (page_id+1), cursor, 30) if len(user_list) <= 0: next_page_id = None else: next_page_id = page_id + 1 logging.info('recursive...') try: taskqueue.add(url = '/cron/notify', params = {'page_id': next_page_id}, method='GET') except: logging.error('Add task failed.')
def post(self): user = users.get_current_user() user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: return self.error(404) store_tweet_history = StoreTweetHistory.all().filter('google_account =', user).filter('expired_at >', datetime.datetime.now()).get() if store_tweet_history is None: user_prefs.free_quantity = user_prefs.free_quantity + 100 user_prefs.activate_flg = True user_prefs.put() store_tweet_history = StoreTweetHistory() store_tweet_history.google_account = user store_tweet_history.expired_at = datetime.datetime.now() + datetime.timedelta(days=7) store_tweet_history.put() data = {'status': True} else: data = {'status': False} json = simplejson.dumps(data, ensure_ascii=False) self.response.content_type = 'application/json' self.response.out.write(json)
def post(self): user = users.get_current_user() user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: return self.error(404) mode = self.request.get('mode') if mode == 'add': name = self.request.get('name') icon = self.request.get('icon') marker_icon = MarkerIcon() marker_icon.name = name marker_icon.icon = db.Blob(icon) marker_icon.user_prefs = user_prefs.key() marker_icon.visible = True marker_icon.put() elif mode == 'delete': id = self.request.get('id') marker_icon = MarkerIcon.get_by_id(int(id)) if marker_icon is not None: marker_icon.visible = False marker_icon.put() self.redirect('/user/icon')
def post(self): user = users.get_current_user() user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: return self.error(404) bot_id = self.request.get('bot_id') if bot_id == '_custom': custom_bot_id = self.request.get('custom_bot_id') bot = BotPrefs.all().filter('bot_id =', custom_bot_id).get() logging.info('Custom Bot ID: %s' % custom_bot_id) else: bot = BotPrefs.all().filter('bot_id =', bot_id).get() logging.info('Bot ID: %s' % bot_id) if bot is not None: user_prefs.bot_prefs_key = bot.key() user_prefs.put() data = {'status': True, 'bot_id': bot.bot_id, 'nickname': bot.nickname} else: logging.error('bot_id is invalid.') data = {'status': False, 'message': 'Bot ID is invalid.'} json = simplejson.dumps(data, ensure_ascii=False) self.response.content_type = 'application/json' self.response.out.write(json)
def post(self): user = users.get_current_user() user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: return self.error(404) receipt_data = self.request.get('receipt_data') logging.info('Row: %s' % receipt_data) store_purchase_tmp_history = StorePurchaseTmpHistory() store_purchase_tmp_history.user_prefs = user_prefs.key() store_purchase_tmp_history.platform = 'ios' store_purchase_tmp_history.receipt_data = receipt_data store_purchase_tmp_history.status = 'pending' store_purchase_tmp_history.secret_key = uuid.uuid4().hex store_purchase_tmp_history.put() try: taskqueue.add(url = '/store_api/task/verify_receipt', params = {'id': store_purchase_tmp_history.key().id()}) json = simplejson.dumps({'status': True, 'key': store_purchase_tmp_history.secret_key}, ensure_ascii=False) self.response.content_type = 'application/json' return self.response.out.write(json) except: logging.error('Add task failed.') json = simplejson.dumps({'status': False, 'key': None}, ensure_ascii=False) self.response.content_type = 'application/json' self.response.out.write(json)
def get(self): user = users.get_current_user() if user: user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: return self.redirect('/user/home') store_tweet_history = StoreTweetHistory.all().filter('google_account =', user).filter('expired_at >', datetime.datetime.now()).get() if store_tweet_history is None: can_tweet = True expired_at = None else: can_tweet = False user_timezone = timezone(user_prefs.timezone) loc_dt = user_timezone.localize(store_tweet_history.expired_at) expired_at = loc_dt.strftime('%Y-%m-%d %H:%M:%S %Z%z') template_values = { 'can_tweet': can_tweet, 'expired_at': expired_at } path = os.path.join(os.path.dirname(__file__), 'templates/store/tweet.html') self.response.out.write(template.render(path, template_values))
def post(self): user = users.get_current_user() device_token = self.request.get('device_token') if device_token != '': logging.info('device_token: %s' % device_token) device_prefs = DevicePrefs.all().filter('device_token =', device_token).get() if device_prefs is None: device_prefs = DevicePrefs() device_prefs.google_account = user device_prefs.device_token = device_token device_prefs.delete_flg = False device_prefs.put() user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: bot = BotPrefs.all().filter('bot_id =', 'test').get() user_prefs = UserPrefs() user_prefs.google_account = user user_prefs.daily_max_notify_count = 3 user_prefs.paid_quantity = 0 user_prefs.free_quantity = 100 user_prefs.timezone = 0.0 user_prefs.notify_probability = 0.0 user_prefs.delete_flg = False user_prefs.bot_prefs_key = bot.key() user_prefs.put() return self.redirect('/user/home') self.redirect('/user/home')
def post(self, map_id): user = users.get_current_user() if user is None: return self.redirect(users.create_login_url(self.request.uri)) user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: return self.redirect('/map/%s' % map_id) user_maps = UserMaps.all().filter('map_id =', map_id).filter('visible =', True).filter('user_prefs =', user_prefs.key()).get() if user_maps is None: return self.redirect('/map/%s' % map_id) mode = self.request.get('mode') if mode == 'set_home': lat = self.request.get('lat') lng = self.request.get('lng') user_maps.home_geo = db.GeoPt(lat, lon=lng) user_maps.put() elif mode == 'set_marker': name = self.request.get('name') tags = self.request.get('tags') icon = self.request.get('icon') marker_icon = None if icon != '': marker_icon = MarkerIcon.get_by_id(int(icon)) tags = tags.replace(u'、', ',').replace(' ', ',').replace(u' ', ',') lat = self.request.get('lat') lng = self.request.get('lng') user_activity = UserActivity() user_activity.name = name user_activity.tags = tags user_activity.geo = db.GeoPt(lat, lon=lng) user_activity.user_prefs = user_prefs.key() user_activity.user_maps = user_maps.key() if marker_icon is not None: user_activity.icon = marker_icon.key() user_activity.put() try: taskqueue.add(url='/task/build_tag_index', params={'map_id': map_id}) except: logging.error('Taskqueue add failed.') elif mode == 'delete': user_maps.visible = False user_maps.put() return self.redirect('/user/home') return self.redirect('/map/%s' % map_id)
def get(self): user = users.get_current_user() if user: user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is not None: return self.redirect('/user/home') template_values = { } path = os.path.join(os.path.dirname(__file__), 'templates/user/welcome.html') self.response.out.write(template.render(path, template_values))
def get(self): user = users.get_current_user() if user: user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: return self.redirect('/user/home') quantity = user_prefs.free_quantity + user_prefs.paid_quantity template_values = { 'quantity': quantity } path = os.path.join(os.path.dirname(__file__), 'templates/store/buy_success.html') self.response.out.write(template.render(path, template_values))
def get(self): user = users.get_current_user() user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: return self.redirect('/user/welcome') max_notify_list = [3, 5, 10, 15, 20] template_values = { 'user_prefs': user_prefs, 'max_notify_list': max_notify_list, 'timezones': pytz.common_timezones } path = os.path.join(os.path.dirname(__file__), 'templates/user/settings.html') self.response.out.write(template.render(path, template_values))
def post(self): user = users.get_current_user() user_prefs_query = UserPrefs().all() user_prefs_query.filter('google_account =', user) user_prefs = user_prefs_query.get() if user is not None and user_prefs is not None: nick_name = self.request.get('nick_name') user_id = self.request.get('user_id') avatar = self.request.get('avatar') is_id_available = True id_check = UserPrefs.all().filter('user_id =', user_id).get() if id_check is not None: if id_check.google_account != user: is_id_available = False avatar_result = images.resize(db.Blob(avatar), 300, 300, output_encoding=images.PNG) if is_id_available: user_prefs.user_id = user_id user_prefs.nick_name = nick_name user_prefs.avatar = db.Blob(avatar_result) user_prefs.put() data = json.dumps({'state': 'ok', 'user_id': user_prefs.user_id}, ensure_ascii=False) else: logging.info('nick name is not available.') self.response.set_status(401) data = json.dumps({'state': 'nick name is not available.'}, ensure_ascii=False) else: logging.info('unauthorized.') self.response.set_status(401) data = json.dumps({'state': 'failed'}, ensure_ascii=False) self.response.content_type = 'application/json' self.response.out.write(data)
def get(self): user = users.get_current_user() user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: return self.error(404) marker_icon_list = MarkerIcon.all().filter('user_prefs =', user_prefs.key()).filter('visible =', True).fetch(100) icon_list = [] #icon_list.append({'id':None, 'name':'Default'}) for marker_icon in marker_icon_list: icon_list.append({'id':marker_icon.key().id(), 'name':marker_icon.name}) template_values = { 'icon_list': icon_list } path = os.path.join(os.path.dirname(__file__), 'templates/user/icon.html') self.response.out.write(template.render(path, template_values))
def post(self): user = users.get_current_user() user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: return self.error(404) try: bot_id = user_prefs.bot_prefs_key.key().id() taskqueue.add(url = '/task/find_device', params = {'user_id': user_prefs.key().id(), 'bot_id': bot_id}) data = {'status': True} except: logging.error('Add task failed.') data = {'status': False} json = simplejson.dumps(data, ensure_ascii=False) self.response.content_type = 'application/json' self.response.out.write(json)
def get(self): user = users.get_current_user() user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: return self.error(404) user_maps = UserMaps.all().filter('visible =', True).filter('user_prefs =', user_prefs.key()).fetch(100) nickname = user.nickname() logout_url = users.create_logout_url('/') template_values = { 'map_list': user_maps, 'nickname': nickname, 'logout_url': logout_url } path = os.path.join(os.path.dirname(__file__), 'templates/user/home.html') self.response.out.write(template.render(path, template_values))
def get(self): id = self.request.get('id') cache_key = 'cached_avatar_image_%s' % id image = memcache.get(cache_key) if image is None: user_prefs = UserPrefs.all().filter('user_id =', id).get() if user_prefs is None: return self.error(404) image = user_prefs.avatar memcache.add(cache_key, image, 3600) logging.info('create cache.') else: logging.info('load cache.') self.response.headers['Content-Type'] = 'image/png' self.response.out.write(image)
def get(self): user = users.get_current_user() user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: return self.redirect('/user/welcome') debug_flg = self.request.get('debug') if debug_flg == 'true': debug_flg = True else: debug_flg = False quantity = user_prefs.free_quantity + user_prefs.paid_quantity try: bot_id = user_prefs.bot_prefs_key.bot_id bot_nickname = user_prefs.bot_prefs_key.nickname except: bot_id = '-' bot_nickname = 'Not found' logout_url = users.create_logout_url('/user/welcome') template_values = { 'quantity': quantity, 'user_prefs': user_prefs, 'bot_id': bot_id, 'bot_nickname': bot_nickname, 'logout_url': logout_url, 'debug_flg': debug_flg } path = os.path.join(os.path.dirname(__file__), 'templates/user/home.html') self.response.out.write(template.render(path, template_values))
def post(self): map_id = self.request.get('map_id') map_title = self.request.get('map_title') if map_title == '': map_title = map_id user = users.get_current_user() user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: user_prefs = UserPrefs() user_prefs.google_account = user user_prefs.put() user_maps = UserMaps.all().filter('visible =', True).filter('map_id =', map_id).get() if user_maps is None and map_id != '': user_maps = UserMaps() user_maps.map_id = map_id user_maps.map_title = map_title user_maps.user_prefs = user_prefs user_maps.visible = True user_maps.put() self.redirect('/map/%s' % map_id) else: template_values = { 'map_id': map_id, 'map_title': map_title, 'message': 'そのマップIDは使用できませんできした。' } path = os.path.join(os.path.dirname(__file__), 'templates/user/create.html') self.response.out.write(template.render(path, template_values))
def get(self): user = users.get_current_user() user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: return self.redirect('/user/welcome') new_bot_list = [] bot_id_list = [] bot_list = BotPrefs.all().filter('public_flg =', True).fetch(20) for row in bot_list: if row.bot_id not in bot_id_list: bot_id_list.append(row.bot_id) new_bot_list.append({'bot_id': row.bot_id, 'nickname': row.nickname}) bot_list = BotPrefs.all().filter('google_account =', user).fetch(20) for row in bot_list: if row.bot_id not in bot_id_list: bot_id_list.append(row.bot_id) new_bot_list.append({'bot_id': row.bot_id, 'nickname': row.nickname}) try: bot_id = user_prefs.bot_prefs_key.bot_id except: bot_id = '' template_values = { 'bot_list': new_bot_list, 'user_prefs': user_prefs, 'bot_id': bot_id } path = os.path.join(os.path.dirname(__file__), 'templates/user/bot.html') self.response.out.write(template.render(path, template_values))
def get(self, map_id): user_maps = UserMaps.all().filter('visible =', True).filter('map_id =', map_id).get() if user_maps is None: return self.error(404) lat = '' lng = '' if user_maps.home_geo is not None: lat = user_maps.home_geo.lat lng = user_maps.home_geo.lon marker_id = self.request.get('marker_id') user = users.get_current_user() user_activity = UserActivity.get_by_id(int(marker_id)) if user_activity is None: return self.error(404) if user_activity.user_prefs.google_account != user: return self.redirect('/map/%s' % map_id) icon_id = '' if user_activity.icon is not None: icon_id = user_activity.icon.key().id() activity_list = [] activity_list.append({'id': user_activity.key().id(), 'name': user_activity.name, 'tags': user_activity.tags, 'icon': icon_id, 'lat': user_activity.geo.lat, 'lng': user_activity.geo.lon}) if user: url = users.create_logout_url('/map/%s' % map_id) else: url = users.create_login_url('/map/%s' % map_id) icon_list = None map_owner = False if user is not None: user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is not None: user_maps = UserMaps.all().filter('map_id =', map_id).filter('user_prefs =', user_prefs.key()).get() if user_maps is not None: map_owner = True marker_icon_list = MarkerIcon.all().filter('user_prefs =', user_prefs.key()).filter('visible =', True).fetch(100) icon_list = [] for marker_icon in marker_icon_list: icon_list.append({'id': marker_icon.key().id(), 'name': marker_icon.name}) template_values = { 'map_title': user_maps.map_title, 'map_id': map_id, 'lat': lat, 'lng': lng, 'activity_list': activity_list, 'icon_list': icon_list, 'map_owner': map_owner, 'login': user and True or False, 'url': url } path = os.path.join(os.path.dirname(__file__), 'templates/map/map_edit.html') self.response.out.write(template.render(path, template_values))
def post(self): user = users.get_current_user() user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is None: return self.error(404) daily_max_notify_count = self.request.get('daily_max_notify_count') schedule_0000_0300 = self.request.get('0000_0300') schedule_0300_0600 = self.request.get('0300_0600') schedule_0600_0900 = self.request.get('0600_0900') schedule_0900_1200 = self.request.get('0900_1200') schedule_1200_1500 = self.request.get('1200_1500') schedule_1500_1800 = self.request.get('1500_1800') schedule_1800_2100 = self.request.get('1800_2100') schedule_2100_2400 = self.request.get('2100_2400') logging.info(schedule_2100_2400) current_timezone = timezone(self.request.get('timezone')) utc_timezone = timezone('UTC') #schedule = Schedule.all().filter('user_prefs_key =', user_prefs.key()).get() #if schedule is None: # schedule = Schedule() schedule_list = [] user_prefs.daily_max_notify_count = int(daily_max_notify_count) if schedule_0000_0300 == '1': user_prefs.schedule_0000_0300 = True utc = datetime.datetime(2011, 01, 01, 0, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 1, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 2, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) else: user_prefs.schedule_0000_0300 = False if schedule_0300_0600 == '1': user_prefs.schedule_0300_0600 = True utc = datetime.datetime(2011, 01, 01, 3, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 4, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 5, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) else: user_prefs.schedule_0300_0600 = False if schedule_0600_0900 == '1': user_prefs.schedule_0600_0900 = True utc = datetime.datetime(2011, 01, 01, 6, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 7, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 8, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) else: user_prefs.schedule_0600_0900 = False if schedule_0900_1200 == '1': user_prefs.schedule_0900_1200 = True utc = datetime.datetime(2011, 01, 01, 9, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 10, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 11, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) else: user_prefs.schedule_0900_1200 = False if schedule_1200_1500 == '1': user_prefs.schedule_1200_1500 = True utc = datetime.datetime(2011, 01, 01, 12, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 13, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 14, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) else: user_prefs.schedule_1200_1500 = False if schedule_1500_1800 == '1': user_prefs.schedule_1500_1800 = True utc = datetime.datetime(2011, 01, 01, 15, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 16, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 17, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) else: user_prefs.schedule_1500_1800 = False if schedule_1800_2100 == '1': user_prefs.schedule_1800_2100 = True utc = datetime.datetime(2011, 01, 01, 18, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 19, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 20, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) else: user_prefs.schedule_1800_2100 = False if schedule_2100_2400 == '1': user_prefs.schedule_2100_2400 = True utc = datetime.datetime(2011, 01, 01, 21, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 22, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) utc = datetime.datetime(2011, 01, 01, 23, 0, 0, tzinfo=current_timezone) schedule_list.append(utc.astimezone(utc_timezone).hour) else: user_prefs.schedule_2100_2400 = False user_prefs.schedule_list = schedule_list user_prefs.timezone = current_timezone.zone if len(schedule_list) > 0: user_prefs.notify_probability = (float(user_prefs.daily_max_notify_count) / (float(len(schedule_list)) * 6)) * 100 else: user_prefs.notify_probability = 0.0 user_prefs.activate_flg = True user_prefs.put() json = simplejson.dumps({'status': True}, ensure_ascii=False) self.response.content_type = 'application/json' self.response.out.write(json)
def get(self, map_id): user_maps = UserMaps.all().filter('map_id =', map_id).filter('visible =', True).get() if user_maps is None: return self.error(404) map_title = user_maps.map_title lat = '' lng = '' if user_maps.home_geo is not None: lat = user_maps.home_geo.lat lng = user_maps.home_geo.lon user_activity_list = UserActivity.all().filter('user_maps =', user_maps.key()).order('-created_at').fetch(200) activity_list = [] activity_id_list = [] available_icon_list = [] for user_activity in user_activity_list: icon_id = '' if user_activity.icon is not None: icon_id = user_activity.icon.key().id() available_icon_list.append({'id': icon_id, 'name': user_activity.icon.name}) created_at = user_activity.created_at + datetime.timedelta(hours=9) activity_list.append({'id': user_activity.key().id(), 'name': user_activity.name, 'tags': user_activity.tags, 'icon': icon_id, 'lat': user_activity.geo.lat, 'lng': user_activity.geo.lon, 'created_at': created_at.strftime('%Y-%m-%d %H:%M:%S (JST)')}) activity_id_list.append(str(user_activity.key().id())) user = users.get_current_user() if user: url = users.create_logout_url('/map/%s' % map_id) else: url = users.create_login_url('/map/%s' % map_id) icon_list = None map_owner = False if user is not None: user_prefs = UserPrefs.all().filter('google_account =', user).get() if user_prefs is not None: user_maps = UserMaps.all().filter('map_id =', map_id).filter('user_prefs =', user_prefs.key()).get() if user_maps is not None: map_owner = True marker_icon_list = MarkerIcon.all().filter('user_prefs =', user_prefs.key()).filter('visible =', True).fetch(100) icon_list = [] for marker_icon in marker_icon_list: icon_list.append({'id': marker_icon.key().id(), 'name': marker_icon.name}) mode = self.request.get('mode') template_values = { 'map_title': map_title, 'map_id': map_id, 'lat': lat, 'lng': lng, 'activity_list': activity_list, 'activity_id_list': ','.join(activity_id_list), 'icon_list': icon_list, 'available_icon_list': available_icon_list, 'map_owner': map_owner, 'login': user and True or False, 'url': url, 'mode': mode } path = os.path.join(os.path.dirname(__file__), 'templates/map/map.html') self.response.out.write(template.render(path, template_values))