예제 #1
0
def member_page_doug():
    # only for testing purposes
    session["PBEM"] = True

    # I removed the query that was here as you can just
    # use the function you have that returns the user_id
    # from the session.

    # use the currently logged in user id value to get the user
    users = controller.get_users(current_user.id)

    # did we get a list of users?
    if users:

        # get the single user we expect from that list
        user = users[0]

    # log the user to stdout
    logger.debug(
        f"Here is the user data returned for this user.id = {current_user.id}")
    logger.debug(user)

    # iterate over the user's games
    for game in user.games:

        # get the turns associated with the user's games
        turns = controller.get_turns(user.id, game.id)

        # append the list of turns to this user game
        game.turns = turns

    return render_template("member/member_page_doug.html", user=user)
예제 #2
0
	def __init__(self,**kwargs):
		#Inicializacion de la interfaz
		super(Interfaz, self).__init__(**kwargs)
		#Definicion de Variables
		listB = []
		aux = 1
		Checkout = PayUi()
		box = ObjectProperty(None)
		txt = ObjectProperty(None)
		grid = ObjectProperty(None)
		discount = ObjectProperty(None)
		total = ObjectProperty(None)
		save = ObjectProperty(None)
		printAct = ObjectProperty(None)
		send = ObjectProperty(None)
		money = ObjectProperty(None)
		self.discount.bind(is_open = self.addDiscount)
		products = controller.get_products()
		users = controller.get_users()
		self.save.background_color = 0,147,0,.5
		self.save.bind(on_press = self.press)
		self.save.bind(on_release = self.release)
		self.send.background_color = 162,0,170,.5
		self.send.bind(on_press = self.DisplaySale)#Interfaz de venta unida a este boton
		self.send.bind(on_release = self.releaseB)
		self.printAct.background_color = 162,0,170,.5
		self.printAct.bind(on_press = self.pressB)
		self.printAct.bind(on_release = self.releaseB)
		#Ingreso de usuarios al Spinner
		for i in users:
			listB.append(i.username)
		self.txt.text = listB[0]
		self.txt.values = listB
		#Ingreso de productos a la listA deslizante
		for fila in products:
			Q = CBoton()
			Q.background_color = 1,1,1,(aux%2+0.5)
			aux = aux+1
			Q.name = fila.name
			Q.text = fila.name[:20]
			Q.code = fila.supplier_code
			Q.precio = fila.gross_price
			Q.bind(on_press = self.addRow)
			self.grid.add_widget(Q)
			self.grid.bind(minimum_width=self.grid.setter('width'))
예제 #3
0
파일: main.py 프로젝트: Gizmoh/Ui_datos
	def __init__(self,**kwargs):
		#Inicializacion de la interfaz
		super(Interfaz, self).__init__(**kwargs)
		#Definicion de Variables
		listB = []
		aux = 1
		box = ObjectProperty(None)
		txt = ObjectProperty(None)
		grid = ObjectProperty(None)
		discount = ObjectProperty(None)
		total = ObjectProperty(None)
		save = ObjectProperty(None)
		printAct = ObjectProperty(None)
		send = ObjectProperty(None)
		money = ObjectProperty(None)
		self.discount.bind(is_open = self.addDiscount)
		products = controller.get_products()
		users = controller.get_users()
		self.save.background_color = 0,147,0,.5
		self.send.background_color = 162,0,170,.5
		self.printAct.background_color = 162,0,170,.5
		#Ingreso de usuarios al Spinner
		for i in users:
			listB.append(i[0])
		self.txt.text = listB[0]
		self.txt.values = listB
		#Ingreso de productos a la listA deslizante
		for fila in products:
			Q = CBoton()
			Q.background_color = 1,1,1,(aux%2+0.5)
			aux = aux+1
			Q.name = fila[0]
			Q.text = fila[0][:20]
			Q.code = fila[1]
			Q.precio = fila[2]
			Q.bind(on_press = self.addRow)
			self.grid.add_widget(Q)
			self.grid.bind(minimum_width=self.grid.setter('width'))
예제 #4
0
def get_users(user_id=None):
    """
    This function provides the /users/<user_id> API REST URL endpoint
    It returns a JSON string of the list of users

    :return:        JSON string containing list of users
    """
    # call the controller to get the users that match our requirements
    _users = controller.get_users(user_id=user_id)

    # convert the list of user objects to a list of dictionaries
    # so they can be serialized
    users = [{
        "id":
        user.id,
        "username":
        user.username,
        "password":
        user.password,
        "email":
        user.email,
        "account_type":
        user.account_type,
        "icon":
        user.icon,
        "games": [{
            "id": game.id,
            "creator": game.creator,
            "name": game.name,
            "active": game.active,
            "limit": game.limit,
            "allow_new": game.allow_new,
            "options": game.options,
        } for game in user.games],
    } for user in _users]
    response = make_response(jsonify(users), 200)
    response.headers["Content-Type"] = "application/json"
    return response
예제 #5
0
def round_summary(game_id, turn_id):
    # begin query to find all players last turn
    # return dict of game info
    current_game_users = controller.get_games_users_dict(game_id)

    game_name = current_game_users[0]["name"]

    # save the list of user dicts
    user_list = current_game_users[0]["users"]

    # initiate list to store max turn numbers
    user_info_list = []

    for user in user_list:
        this_user_data = {}
        # iterate over each user to their turn data
        this_user_turn = controller.get_latest_turn(game_id, user["id"])

        # load summary_data into list
        prelim_summary_data = json.loads(this_user_turn.summary_data)
        this_user_data["chosen_cards"] = prelim_summary_data["chosen_cards"]
        this_user_data["total_exhaustion"] = prelim_summary_data[
            "total_exhaustion"]

        _quick_user = controller.get_users(user["id"])
        quick_user = _quick_user[0]
        this_user_data["user_name"] = quick_user.username

        user_info_list.append(this_user_data)
    round_number = this_user_turn.current_round

    return render_template(
        "member/round_summary.html",
        turn_id=turn_id,
        user_info_list=user_info_list,
        round_number=round_number,
        game_name=game_name,
    )
예제 #6
0
def list_users(request):
    return HttpResponse(controller.get_users())