Beispiel #1
0
    def get(self):
        
        geotags_query = Geotag.all()
        geotags = []
        users = []
        tags = []
        imgUrls = []
        
        for geotag in geotags_query:
        	user = geotag.user
        	tag = geotag.tag
        	imgUrl = geotag.imgUrl
        	if (user not in users): users.append(user)
        	if (tag not in tags): tags.append(tag)
        	if (imgUrl not in imgUrls): imgUrls.append(imgUrl)
        
        users.sort()
        tags.sort()
        
        
        template_values = {
            'geotags': geotags,
            'users': users,
            'tags': tags,
            'imgUrls': imgUrls,
        	}

        path = os.path.join(os.path.dirname(__file__), 'index.html')
        self.response.out.write(template.render(path, template_values))
Beispiel #2
0
  def get(self):
    # CookieからChannel TokenIDを取得
    client_id = self.request.cookies.get('client_id', '')
    token = self.request.cookies.get('token', '')

    if not (len(client_id) and len(token)):
      # Channel TokenIDを生成
      client_id = str(uuid.uuid4())
      token = channel.create_channel(client_id, 24 * 60)

      # クッキーの有効期限として1日後の時間を取得
      after_one_day_time = (datetime.datetime.now() + datetime.timedelta(hours=33)).strftime('%a, %d-%b-%Y %H:%M:%S GMT')

      # client_idをクッキーに保存
      myCookie = 'client_id=%s; expires=%s;' % (client_id, after_one_day_time)
      self.response.headers.add_header('Set-Cookie', myCookie)

      # tokenをクッキーに保存
      myCookie = 'token=%s; expires=%s;' % (token, after_one_day_time)
      self.response.headers.add_header('Set-Cookie', myCookie)

    # 同時接続しているユーザーのClient ID一覧を取得
    users = memcache.get(USER_KEY)
    if not users:
      users = []

    # クッキーのtokenと同じユーザーが登録されているかどうか
    isAddUser = False
    for user in users:
      if user.token == token:
        isAddUser = True

    # クッキーのtokenと同じユーザーが登録されていなければ新規に作成
    if not isAddUser:
      # ユーザークラスを作成する
      user = User(client_id, token)

      # 新しいClient IDを追加する
      users.append(user)
      memcache.set(USER_KEY, users, 60*60*24)

    # データストアからワードデータの取得
    words, cursor, more = Word.query().order(-Word.word_id).fetch_page(11)

    # TODO デプロイ時はコメントアウト
    if len(words) == 0:
      current_time = (datetime.datetime.now() + datetime.timedelta(hours=9))
      words = Word(word_id=1, member_id=0, word=u"しりとらず", hiragana=u"しりとらず", image_url="http://siritoraz.appspot.com/favicon.ico", amazon_link="http://siritoraz.appspot.com", created_at=current_time.strftime("%Y/%m/%d %H:%M:%S"))
      words.put()

    template_values = {
      'words': words,
      'token': token,
      'words_cursor': cursor.urlsafe(),
      'more_words': more
    }

    template = JINJA_ENVIRONMENT.get_template('index.html')
    self.response.write(template.render(template_values))
Beispiel #3
0
	def get(self, room_name):
		rooms = Room.gql('where room_name = :1', room_name).fetch(1000)
		users = []
		for room in rooms:
			user = Users.gql('where user_id = :1', room.user_id).get()
			users.append(user.to_dict())

		self.response.out.write(json.dumps(users))
Beispiel #4
0
def edit_users():
    keys = sorted(user_pub_keys)
    query = db.User.query(
        db.User.pub_key >= keys[0],
        db.User.pub_key <= keys[-1])
    users = query.order(db.User.pub_key).fetch(keys_only=True)
    if not users:
        for key in keys:
            users.append(db.User.create(key, description=key, use_hash=False).key)
    return users
Beispiel #5
0
 def get(self):
     q=UsersList.all()
     users = []
     for user in q.run():
         users.append(user)
     template_values=login_status(self.request.uri)
     template_values.update({
         'users' : users})
     template = jinja_environment.get_template('display_users_list.html')
     self.response.out.write(template.render(template_values))
Beispiel #6
0
 def get(self):
     q=UsersList.all()
     users = []
     for user in q.run():
         users.append(user)
     template_values=login_status(self.request.uri)
     template_values.update({
         'users' : users ,
         'unregister_url' : '/authenticationmanagement/admin/unregisteruser'})
     template = jinja_environment.get_template('unregister_user.html')
     self.response.out.write(template.render(template_values))
Beispiel #7
0
 def get(self):
     result = {}
     radars = None
     
     count = self.request.get("count")
     if (count):
         count = int(count)
     else:
         count = 100
     
     page = self.request.get("page")
     if (page):
         page = int(page)
     else:
         page = 1
     
     scope = self.request.get("scope")
     if (not scope):
         scope = "all"
     
     searchQuery = self.request.get("q")
     keywords = searchQuery.split(" ")
     keyword = keywords[0]
     
     try:
         if (scope == "number"):
             radars = db.Radar().fetchByNumbers(keywords, page, count)
         elif (scope == "user"):
             users = []
             for userName in keywords:
                 user = google.appengine.api.users.User(userName)
                 if user:
                     users.append(user)
             radars = db.Radar().fetchByUsers(users, page, count);
         else:
             radars = models.Radar.all().search(keyword).order("-number").fetch(count, (page - 1) * count)
     except Exception:
         radars = None
     
     if (radars and len(radars) > 0):
         result = [radar.toDictionary() for radar in radars]
     
     # Return the result
     self.respondWithDictionaryAsJSON({"result": result})
Beispiel #8
0
def manage_connections(otherUserID = None):
	cur_user = current_user()

	if request.method == 'GET':
		connections = cur_user.get_all_connections()
		users = []
		result = "you have " + str(len(connections)) + " connections"
		for connection in connections:
			result += "<br>" + connection.name
			user = dict()
			user["name"] = connection.name
			user["email"] = connection.email
			#user["username"] = connection.username
			user["id"] = connection.get_id()
			users.append(user)
		return jsonify({"connectedUsers":users})
	elif request.method == 'POST':
		cur_user = current_user()
		otherUser = UserAccount.getuser(int(otherUserID))
		result = cur_user.send_invite(otherUser)
		if(result == 0):
			return jsonify({"Message":"Invitation successfully sent"})
		elif(result == 1):
			return jsonify({"Message":"Connection already existed"})
		elif(result == 2):
			return jsonify({"Message":"Cannot create a connection with yourself"})
	elif request.method == 'DELETE':
		cur_user = current_user()
		otherUser = UserAccount.getuser(int(otherUserID))
		if cur_user.remove_connection(otherUser):
			return jsonify({"Message":"Connection successfully deleted"})
		else:
			return jsonify({"Message":"Connection didn't existed"})
	else:
		#this should never be reached
		return jsonify({"Message":"Error: http request was invalid"})
Beispiel #9
0
	def render_page(self, user):
		if not user:
			self.redirect("/index")
			return
		if(user.userType == '1'):
			orders = db.GqlQuery("select * from Order ORDER BY placed_time DESC")
			orders = list(orders)
			books = []
			users = []
			for order in orders:
				books.append(db.get(order.book))
				users.append(db.get(order.user))
			self.render("orders.html", orders = orders, books = books, users = users, user = user)
		else:
			if user.userType == '0':
				orders = db.GqlQuery("select * from Order where user='"+ str(user.key()) + "' ORDER BY placed_time DESC")
				books = []
				users = []
				orders = list(orders)
				for order in orders:
					books.append(db.get(order.book))
				self.render("orders.html", orders = orders, books = books, user = user)
			else:
				self.redirec('/index')	
Beispiel #10
0
def get_users(group):
    users = []
    for member_id in group.members:
        users.append(UserAlias.get_by_id(member_id))
    return users
Beispiel #11
0
def addUserToOfflineMsgOffUserList(gtalk):
	users = getOfflineMsgOffUserListFromCache()
	if gtalk not in users:
		users.append(gtalk)
		setConfigValueWithCache('cache_offline_msgoff_user_list',users)
	return users
Beispiel #12
0
def addUserToOnlineUserList(gtalk):
	users = getOnlineUserListFromCache()
	if gtalk not in users:
		users.append(gtalk)
		setConfigValueWithCache('cache_online_user_list',users)
	return users