Example #1
0
def create_human():
    name = request.get_json()['name']

    if not name:
        abort(400)

    human = Human(name=name)
    db.session.add(human)
    db.session.commit()

    return jsonify({"human": human.to_dict()})
Example #2
0
def add_history():
    patient = Human(tc=session['user_tc']).get_object()
    doctor_tc = request.form.get('doctor_select')
    doctor = Doctor(human=Human(tc=doctor_tc).get_object()).get_object()
    hospital_id = request.form.get('hospital_select')
    hospital = Hospital(id=hospital_id).get_object()
    sickness = request.form.get('sickness')
    date = request.form.get('date')
    time = request.form.get('time')
    date_time = date + " " + time

    History(date=date_time, patient=patient, doctor=doctor, hospital=hospital, sickness=sickness).save()
    return redirect(url_for(views.home_page.__name__))
Example #3
0
def createUser(login_session):
    newUser = Human(name=login_session['username'],
                    email=login_session['email'],
                    picture=login_session['picture'])
    session.add(newUser)
    session.commit()
    user = session.query(Human).filter_by(email=login_session['email']).one()
    return user.id
Example #4
0
def get_doctor_info_ajax():
    human = Human(tc=request.form.get('doctor_tc')).get_object()
    doctor = Doctor(human=human).get_object()
    day_list = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
    workdays_ = doctor.workdays
    workdays = list()
    for i, workday_ in enumerate(workdays_):
        if int(workday_) == i + 1:
            workdays.append(day_list[i + 1])
    return render_template('sub_templates/doctor_info.html', doctor=doctor, workdays=workdays)
Example #5
0
def add_human():
    name = request.form.get("doctor_name")
    surname = request.form.get("doctor_surname")
    tc = request.form.get("doctor_tc")
    password = request.form.get("doctor_password")
    email = request.form.get("doctor_email")
    authorize = request.form.get("authorize_select")
    city = request.form.get("city_select_add")
    district = request.form.get("district_select_add")
    address = Place(city=city, district=district).get_objects()[0]

    human = Human(tc=tc).get_object()
    if human is None:
        human = Human(tc=tc, password=password, authorize=authorize, name=name, surname=surname, mail=email,
                      address=address)
        human.save()

    if authorize == 'doctor':
        workdays = str()
        day_list = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
        for i, day in enumerate(day_list):
            if request.form.get(day) == "on":
                workdays += str(i + 1)
        expertise = request.form.get("doctor_expertise")
        hospital_id = request.form.get("hospital_select_add")
        hospital = Hospital(id=hospital_id).get_object()

        doctor = Doctor(human=human).get_object()
        if doctor is None:
            doctor = Doctor(human=human, workdays=workdays, expertise=expertise, hospital=hospital)
            doctor.save()
        #  else doctor is already created

    return redirect(url_for(views.admin_humans_page.__name__))
Example #6
0
def update_human(human_tc):
    name = request.form.get('modal_human_name')
    surname = request.form.get('modal_human_name')
    city = request.form.get('modal_city_select')
    district = request.form.get('modal_district_select')
    mail = request.form.get('modal_human_mail')
    authorize = request.form.get('modal_authorize_select')

    if city and district:
        address = Place(city, district).get_objects()[0]
    else:
        address = None

    Human(tc=human_tc).get_object().update(address=address, name=name, surname=surname, mail=mail, authorize=authorize)
    return redirect(url_for(views.admin_humans_page.__name__))
Example #7
0
    def game():
        print('Welcome to Tic Tac Toe')

        human = Human.choose_letter().upper()
        computer = Computer.comp_letter(human)
        board = Board.board

        while True:
            move = Human.player_move(board, human)

            if move is True:
                Computer.computer_move(board, computer, human)
                Board.print_board(board)

            if Board.is_board_full(board) is None:
                print('-> It\'s a bloody draw!')
                break

            elif Game.winner(board, computer, human) == -10:
                print(f'-> {human} (you) won this round!')
                break

            elif Game.winner(board, computer, human) == 10:
                print(f'-> {computer} (the machine) won this round!')
                break

        while True:
            play_again = input('-> Wanna play again? Yes/ No: ')

            if play_again.lower() == 'yes' or play_again.lower() == 'y':
                Board.clear_board(board)
                Game.game()

            elif play_again.lower() == 'no' or play_again.lower() == 'n':
                print('Thanks for playing my little game!')
                break
Example #8
0
def filter_human_ajax():
    city = request.form.get('city')
    district = request.form.get('district')
    authorize = request.form.get('authorize')
    name = request.form.get('name')
    surname = request.form.get('surname')
    mail = request.form.get('mail')
    if name == '':
        name = None
    if surname == '':
        surname = None
    if authorize == '':
        authorize = None
    if city and district:
        address = Place(city, district).get_objects()[0]
    else:
        address = None

    humans = Human(name=name, surname=surname, mail=mail, authorize=authorize, address=address).get_objects()

    return render_template('sub_templates/filtered_human_table.html', humans=humans)
Example #9
0
import sys
sys.path.append("/home/kajetan/Aaaasprzedamopla")
from models import Human, Zombie, ALL_HUMANS, ALL_ZOMBIES, MAP
import settings
from itertools import product
import json
from tqdm import tqdm

import random
for _ in range(100):
    random_point = (random.random() * MAP.width, random.random() * MAP.height)
    while MAP.does_collide(random_point):
        random_point = (random.random() * MAP.width,
                        random.random() * MAP.height)
    Human(random_point)

for _ in range(30):
    random_point = (random.random() * MAP.width, random.random() * MAP.height)
    while MAP.does_collide(random_point):
        random_point = (random.random() * MAP.width,
                        random.random() * MAP.height)
    Zombie(random_point)

grid_iter = list(
    product(list(range(settings.GRID_SIZE_X)),
            list(range(settings.GRID_SIZE_Y))))

ts = list()
ts2 = list()

h = 0.5 / (24 * 60)
Example #10
0
from models import (Llama, Petting_Zoo, Human, Garter_Snake)

danny = Llama("Danny", "Alpaca", "Shift B", "Llama food", 12345)
zoo = Petting_Zoo("Big Zoo", "A place for fuzzies")
alex = Human("Alex", "Regular Human", "Shift A", "Waffles", 666)
zoo.admit(danny)
zoo.admit(alex)
ekans = Garter_Snake("Ekans", "CrazySnake", "Shift B", "mice", 32323)
zoo.admit(ekans)
zoo.roster()
Example #11
0
def add_person():
    name = request.form.get("name")
    surname = request.form.get("surname")
    tc = request.form.get("tc")
    email = request.form.get("email")
    password = request.form.get("password")
    city = request.form.get("city_select_add")
    district = request.form.get("district_select_add")
    address = Place(city=city, district=district).get_objects()[0]

    human = Human(tc=tc).get_object()
    if human is None:
        human = Human(tc=tc, password=password, name=name, surname=surname, mail=email,
                      address=address)
        human.save()




    name = request.form.get("name")
    surname = request.form.get("surname")
    tc = request.form.get("tc")
    email = request.form.get("email")
    address = request.form.get("address")
    password = request.form.get("password")
    human_for_check = Human(tc=tc).get_object()
    if human_for_check is None:
        human = Human(tc=tc, password=password, name=name, surname=surname, mail=email,
                      address=address)
        human.save()

    return redirect(url_for(views.login_page.__name__))
Example #12
0
def delete_doctor():
    tc = request.form.get("doctor_tc")
    human_for_check = Human(tc=tc).get_object()
    if human_for_check is not None:
        Doctor(human=human_for_check).delete()
    return redirect(url_for('admin_humans_page'))
Example #13
0
def del_human(human_tc):
    Human(tc=human_tc).delete()
    return redirect(url_for(views.admin_humans_page.__name__))
Example #14
0
def add_adopter(name, email):
    adopter = Human(name=name, email=email)
    session.add(adopter)
    session.commit()
Example #15
0
    parser.add_argument("--depth", type=int, default=1, help='Task depth')
    parser.add_argument("--max_mix_steps",
                        type=int,
                        default=2,
                        help='Max tries at combining ingredients')
    parser.add_argument("--num_distractors",
                        type=int,
                        default=1,
                        help='Number of distractors')
    parser.add_argument("--seed",
                        type=int,
                        default=40,
                        help='Max tries at combining ingredients')
    args = parser.parse_args()

    max_mix_steps = args.max_mix_steps if args.max_mix_steps > 0 else args.depth

    env = gym.make('wordcraft-multistep-goal-v0',
                   max_depth=args.depth,
                   max_mix_steps=max_mix_steps,
                   num_distractors=args.num_distractors,
                   seed=args.seed)
    agent = Human()

    obs = env.reset()
    while True:
        env.render()
        obs, reward, done, info = env.step(agent(obs))
        if done:
            print(f'Episode ended with reward {reward}\n')
            obs = env.reset()