Exemplo n.º 1
0
 def testPlaceNotImportedWhenCityDoesNotExist(self):
     row = ['Title', 'URL', 'cat1 cat2', 'Address',
            self.example_city.name + '....',
            self.example_city.region,
            self.example_city.country]
     Place.import_from_csv_row(row)
     places = list(Place.query())
     self.assertEqual(len(places), 0)
Exemplo n.º 2
0
 def form_valid(self):
     place = Place(title=self.form['title'],
                   url=self.form['url'],
                   description=self.form['description'],
                   tags=self.form['tags'])
     if self.form['longitude'] and self.form['latitude']:
         place.location = GeoPt(self.form['longitude'], self.form['latitude'])
     if self.form['tags']:
         place.tags = self.form['tags']
     place.put()
Exemplo n.º 3
0
 def testImportPlaceFromCSVRow(self):
     row = ['Title', 'URL', 'cat1 cat2', 'Address',
            self.example_city.name,
            self.example_city.region,
            self.example_city.country]
     Place.import_from_csv_row(row)
     place = list(Place.query())[0]
     self.assertEqual(place.title, 'Title')
     self.assertEqual(place.url, 'URL')
     self.assertEqual(place.categories, ['cat1', 'cat2'])
     self.assertEqual(place.address, 'Address')
     self.assertEqual(place.city, self.example_city.key)
Exemplo n.º 4
0
    def setUp(self):
        super().setUp()

        self.cli = make_cli(self.app)
        self.cli_runner = CliRunner()

        self.db.drop_all()
        self.db.create_all()

        u1 = User(username="******")

        # sources
        dt = Bibl(abbr="DT01", bibl="DT de test")

        # resp statements
        r3 = Responsibility(user=u1, bibl=dt, num_start_page=1)
        self.db.session.add(r3)
        self.db.session.add(u1)
        self.db.session.add(dt)

        self.db.session.commit()

        # places
        places = []
        for i in range(1, 1000):
            p = Place(id="DT01-%s" % (str(i).zfill(10)), country="fr", dpt="99", label="Metz")
            p.responsibility_id = r3.id
            places.append(p)
            self.db.session.add(p)

        self.db.session.flush()

        # attach the citable elements to the palce
        for desc, responsibility in [
            ("Ferme en partie détruite par le feu", r3),
        ]:
            p_desc = PlaceDescription()
            p_desc.content = desc
            p_desc.place = places[0]
            p_desc.responsibility = responsibility
            self.db.session.add(p_desc)

        for comment, responsibility in [
            ("L'incendie de 1857 qui frappa Laon fit s'éffondrer le toit de la ferme", r3),
        ]:
            p_comm = PlaceComment()
            p_comm.content = comment
            p_comm.place = places[0]
            p_comm.responsibility = responsibility
            self.db.session.add(p_comm)

        self.db.session.commit()
Exemplo n.º 5
0
def create_places():
    place1 = Place(name='Coffee Cafe')
    db.session.add(place1)
    place2 = Place(name='Jamacian Me Crazy')
    db.session.add(place2)
    place3 = Place(name='Wack Arnolds')
    db.session.add(place3)
    place4 = Place(name='Jack n Crack')
    db.session.add(place4)
    place5 = Place(name='Egg Morning')
    db.session.add(place5)
    db.session.commit()
    print "just created the restaurant table"
Exemplo n.º 6
0
    def setUp(self):
        super().setUp()
        self.db.drop_all()
        self.db.create_all()

        u1 = User(username="******")
        u2 = User(username="******")

        # sources
        dt = Bibl(abbr="DT01", bibl="DT de test")
        pouilles = Bibl(abbr="Pouillés", bibl="Exemplaire des Pouillés de test")
        pages_jaunes = Bibl(abbr="PagesJaunes", bibl="Exemplaire des Pages Jaunes de test")

        # resp statements
        r1 = Responsibility(user=u2)
        r2 = Responsibility(user=u1, bibl=pages_jaunes, num_start_page=None)
        r3 = Responsibility(user=u1, bibl=dt, num_start_page=1)
        r4 = Responsibility(user=u2, bibl=pouilles, num_start_page=10)

        # places
        p = Place(id="DT01-00001", country="fr", dpt="99", label="Laon", responsibility=r3)
        p2 = Place(id="DT01-00002", country="fr", dpt="99", label="Reims", responsibility=r1)

        # attach the citable elements to the palce
        for desc, responsibility in [
            ("Ferme", r1),
            ("Ferme réduite à l'état de ruine", r2),
            ("Ferme en partie détruite par le feu", r3),
            ("Ancienne ferme transformée en moulin", r4)
        ]:
            p_desc = PlaceDescription()
            p_desc.content = desc
            p_desc.place = p
            p_desc.responsibility = responsibility

        for comment, responsibility in [
            ("L'incendie de 1857 qui frappa Laon fit s'éffondrer le toit de la ferme", r2),
            ("Aujourd'hui reconstruite et transformée en discothèque", r4)
        ]:
            p_comm = PlaceComment()
            p_comm.content = comment
            p_comm.place = p
            p_comm.responsibility = responsibility

        oldlabel_dt = PlaceOldLabel(old_label_id='OLD-001', place=p, responsibility=r3, rich_label="Lodanium")
        old_label_pouilles = PlaceOldLabel(old_label_id='OLD-002', place=p, responsibility=r4, rich_label="Lodanivm")
        old_label_no_source = PlaceOldLabel(old_label_id='OLD-003', place=p, responsibility=r1, rich_label="Ludumunmnumd")

        self.db.session.add(p)
        self.db.session.add(p2)
        self.db.session.commit()
Exemplo n.º 7
0
 def testImportPlacesFromCSVFile(self):
     rows = [
             ['Title', 'URL', 'Categories (space-separated)', 'Address', 'City', 'Region', 'Country'],
             ['my place', 'place.com', 'cat1 cat2', '11 Rudolf Drive',
              self.example_city.name, self.example_city.region, self.example_city.country],
             ]
     csvfile = [','.join(row) for row in rows]
     Place.import_from_csv(csvfile)
     place = list(Place.query())[0]
     self.assertEqual(place.title, 'my place')
     self.assertEqual(place.url, 'place.com')
     self.assertEqual(place.categories, ['cat1', 'cat2'])
     self.assertEqual(place.address, '11 Rudolf Drive')
     self.assertEqual(place.city, self.example_city.key)
Exemplo n.º 8
0
 def test_crud(self):
     place1 = Place("USA", "United states of America")
     place1.save()
     place_found = Place.search("USA")
     self.assertEqual(place1, place_found)
     Place.delete(place1)
     place_not_found = Place.search("USA")
     self.assertIsNone(place_not_found)
Exemplo n.º 9
0
    def add_event(user_id, title, description, busytime, place):
        def string_to_timestamp(date, time):
            time_string = date + ' ' + time
            dt = datetime.strptime(time_string, '%Y-%m-%d %H:%M')
            return int(dt.timestamp())

        start = string_to_timestamp(busytime['startDate'], busytime['startTime'])
        end = string_to_timestamp(busytime['endDate'], busytime['endTime'])

        if BusyTimeService.is_time_period_available(user_id, start, end):
            busytime = BusyTime(start=start, end=end)
            place = Place(name=place['name'], address=place['address'], lat=place['lat'],
                          lng=place['lng'], thumbnail=place['thumbnail'], type=place['type'])

            new_event = Event(title=title, description=description, busytime=busytime, place=place)

            user_creating_event = User.query.get(user_id)
            new_event.users.append(user_creating_event)

            db.session.add(new_event)
            db.session.commit()

            return new_event
        else:
            return None
Exemplo n.º 10
0
def create_place():
    data = request.get_json()

    new_place = Place(
        name=data['name'],
        street_house_number=data['street_house_number'],
        postcode=data['postcode'],
        city=data['city'],
        phone_number=data['phone_number'],
        email_adress=data['email_adress'],
        website_url=data['website_url'],
        facebook_url=data['facebook_url'],
        instagram_url=data['instagram_url'],
        wifi_available=data['wifi_available'],
        toilet_available=data['toilet_available'],
        power_slots_available=data['power_slots_available'],
        alcohol_available=data['alcohol_available'],
        vegan_alternatives_available=data['vegan_alternatives_available'],
        laptops_allowed=data['laptops_allowed'],
        open_for_takeaway=data['open_for_takeaway'],
        open_for_delivery=data['open_for_delivery'],
        price_espresso=data['price_espresso'],
        price_filter_coffee=data['price_filter_coffee'],
        price_cappuccino=data['price_cappuccino'],
        wifi_network_name=data['wifi_network_name'],
        wifi_network_password=data['wifi_network_password'])
    # food_options=data['food_options'], picture_urls=data['picture_urls']
    db.session.add(new_place)
    db.session.commit()

    return jsonify({'message': 'New place created!'})
Exemplo n.º 11
0
    def setUp(self):
        db.create_all()
        db.session.add(
            Place(name='Testname',
                  address="123 Test st.",
                  city="Englewood",
                  state="Florida",
                  zip_="34224",
                  website="http://fake.com",
                  phone="123-456-7899",
                  owner="Jeff Reiher",
                  yrs_open=1))

        db.session.add(
            Menu(name="burger",
                 course="dinner",
                 description="test description",
                 price="$1.00",
                 place_id=1))

        db.session.add(
            User(username="******",
                 email="*****@*****.**",
                 password="******",
                 avatar="picofjeff.jpg"))

        db.session.commit()
Exemplo n.º 12
0
def add_place():
    name = request.json.get("name")
    address = request.json.get("address")
    description = request.json.get("description")

    if (name is None) or (address is None):
        abort(400)
    if (
        Place.query.filter_by(name=name).first() is not None
        or Place.query.filter_by(address=address).first() is not None
    ):
        abort(400)

    place = Place(name=name, address=address, description=description, rating=0)
    db.session.add(place)
    db.session.commit()

    return json.dumps(place.serialize()), 201, {"Location": url_for("get_place", id=place.id, _external=True)}
Exemplo n.º 13
0
def convert_here_places_to_native_places(here_places):
    places = []
    for here_place in here_places:
        place = Place.create_from_here_place(here_place)
        if place is None:
            continue
        places.append(place)

    return places
Exemplo n.º 14
0
def create_place(place_id):
    data = request.get_json()

    new_place = Place(name=data['name'],
                      street_house_number=data['street_house_number'],
                      postcode=data['postcode'])
    db.session.add(new_place)
    db.session.commit()

    return jsonify({'message': 'New place created!'})
Exemplo n.º 15
0
def new_place():
    states = us.states.STATES
    if request.method == "POST":
        new = Place(name=request.form["name"],
                    address=request.form["address"],
                    city=request.form["city"],
                    state=request.form["state"],
                    zip_=request.form["zip_"],
                    website=request.form["website"],
                    phone=request.form["phone"],
                    owner=request.form["owner"],
                    yrs_open=request.form["yrs_open"],
                    user_id=current_user.id)
        db.session.add(new)
        db.session.commit()
        flash("You just added a new restaurant", "success")
        return redirect(url_for("home.show_places"))
    return render_template("new_restaurant.html", states=states)
Exemplo n.º 16
0
def places():
    result = Place.query.filter_by(is_active=True).all()
    form = PlaceForm()
    if form.validate_on_submit():
        place = Place(name=form.name.data, url=form.url.data)
        db.session.add(place)
        db.session.commit()
        ctx.push()
        telegrambot.places, telegrambot.keyboard_places = telegrambot.place()
        telegrambot.sports, telegrambot.sport_text, telegrambot.sport_commands = telegrambot.create_sport_description(
        )
        ctx.pop()
        flash('New place was added')
        return render_template('places.html',
                               title='Place',
                               form=form,
                               result=result)

    return render_template('places.html',
                           title='Places',
                           form=form,
                           result=result)
Exemplo n.º 17
0
def load_fixtures(db):
    # INSEE REF
    ref1 = InseeRef(id="ref1",
                    type="type1",
                    insee_code="ABC",
                    level="1",
                    label="this is ref1")
    ref2 = InseeRef(id="ref2",
                    type="type2",
                    insee_code="ABC",
                    level="1",
                    label="this is ref2",
                    parent_id=ref1.id)
    ref3 = InseeRef(id="ref3",
                    type="type3",
                    insee_code="ABC",
                    level="1",
                    label="this is ref3",
                    parent_id=ref2.id)
    db.session.add(ref1)
    db.session.add(ref2)
    db.session.add(ref3)
    db.session.commit()

    # INSEE COMMUNE
    commune1 = InseeCommune(id="Commune1",
                            REG_id=ref1.id,
                            DEP_id=ref2.id,
                            AR_id=ref3.id,
                            NCCENR="NCCENR_TEST")
    commune2 = InseeCommune(id="Commune2",
                            REG_id=ref1.id,
                            DEP_id=ref2.id,
                            AR_id=ref3.id,
                            NCCENR="NCCENR_TEST")
    db.session.add(commune1)
    db.session.add(commune2)
    db.session.commit()

    # PLACE
    e1 = Place(id="id1",
               label="Commune Un",
               country="FR",
               dpt="57",
               commune_insee_code=commune1.id,
               localization_commune_insee_code=commune2.id,
               localization_certainty="low",
               desc="this is a def col",
               num_start_page=1,
               comment="this is a comment")
    db.session.add(e1)
    db.session.commit()

    e2 = Place(id="id2",
               label="Commune Deux",
               country="FR",
               dpt="88",
               commune_insee_code=commune2.id,
               localization_commune_insee_code=commune2.id,
               localization_place_id=e1.id,
               localization_certainty="high",
               desc="this is a def col",
               num_start_page=2,
               comment="this is another comment")

    db.session.add(e2)
    db.session.commit()

    e3 = Place(id="id3",
               label="Commune Trois",
               country="FR",
               dpt="03",
               commune_insee_code=None,
               localization_commune_insee_code=None,
               localization_place_id=None,
               localization_certainty=None,
               desc=None,
               num_start_page=None,
               comment=None)

    db.session.add(e3)
    db.session.commit()

    old_label1 = PlaceOldLabel(old_label_id='PLACE1_OLD_1',
                               place_id=e1.id,
                               rich_label="Cmune Un")
    old_label2 = PlaceOldLabel(old_label_id='PLACE1_OLD_2',
                               place_id=e1.id,
                               rich_label="Cmn Un")
    old_label3 = PlaceOldLabel(old_label_id='PLACE1_OLD_3',
                               place_id=e1.id,
                               rich_label="Comm Un")
    db.session.add(old_label1)
    db.session.add(old_label2)
    db.session.add(old_label3)
    db.session.commit()
Exemplo n.º 18
0
    def setUp(self):
        db.create_all()
        db.session.add(Place(name='Testname'))

        db.session.commit()
Exemplo n.º 19
0
def create_places():
    place1 = Place(name='Coffee Cafe',
                   address="123 Cafe St.",
                   city="Englewood",
                   state="Florida",
                   zip_="34225",
                   website="http://cafe.com",
                   phone="(941)585-3099",
                   owner="Jeff Reiher",
                   yrs_open=1)
    db.session.add(place1)
    place2 = Place(name='Jamacian Me Crazy',
                   address="321 Smoking Blvd",
                   city="Englewood",
                   state="Florida",
                   zip_="34225",
                   website="http://smokeup.com",
                   phone="(941) 585-3099",
                   owner="Bumba Clod",
                   yrs_open=14)
    db.session.add(place2)
    place3 = Place(name='Wack Arnolds',
                   address="2020 Wackoff Ave",
                   city="Englewood",
                   state="Florida",
                   zip_="34225",
                   website="http://www.wackarnolds.com",
                   phone="(941)585-3099",
                   owner="Arnold Jackson",
                   yrs_open=7)
    db.session.add(place3)
    place4 = Place(name='Jack n Crack',
                   address="54098 Mission Rd",
                   city="Englewood",
                   state="Florida",
                   zip_="34225",
                   website="http://www.jackcrack.com",
                   phone="(941)585-3099",
                   owner="Jack MeOff",
                   yrs_open=6)
    db.session.add(place4)
    place5 = Place(name='Egg Morning',
                   address="8am Morning St.",
                   city="Englewood",
                   state="Florida",
                   zip_="34225",
                   website="http://www.eggmorning.com",
                   phone="(941)585-3099",
                   owner="Mona Eggstyle",
                   yrs_open=1)
    db.session.add(place5)
    db.session.commit()
    print "just created the restaurant table."

    ############ PLACE1 MENU ITEMS ##################################################
    #################################################################################
    menuItem1 = Menu(
        name="Veggie Burger",
        description="Juicy grilled veggie patty with tomato mayo and lettuce",
        price="$7.50",
        course="Entree",
        place_id=place1.id)
    db.session.add(menuItem1)
    menuItem2 = Menu(name="French Fries",
                     description="with garlic and parmesan",
                     price="$2.99",
                     course="Appetizer",
                     place_id=place1.id)
    db.session.add(menuItem2)
    menuItem3 = Menu(name="Chocolate Cake",
                     description="fresh baked and served with ice cream",
                     price="$3.99",
                     course="Dessert",
                     place_id=place1.id)
    db.session.add(menuItem3)
    menuItem4 = Menu(name="Sirloin Burger",
                     description="Made with grade A beef",
                     price="$7.99",
                     course="Entree",
                     place_id=place1.id)
    db.session.add(menuItem4)
    menuItem5 = Menu(name="Root Beer",
                     description="16oz of refreshing goodness",
                     price="$1.99",
                     course="Beverage",
                     place_id=place1.id)
    db.session.add(menuItem5)
    print "place 1"
    ############ PLACE2 MENU ITEMS ##################################################
    #################################################################################
    menuItem6 = Menu(name="Iced Tea",
                     description="with Lemon",
                     price="$.99",
                     course="Beverage",
                     place_id=place2.id)
    db.session.add(menuItem6)
    menuItem7 = Menu(name="Grilled Cheese Sandwich",
                     description="On texas toast with American Cheese",
                     price="$3.49",
                     course="Entree",
                     place_id=place2.id)
    db.session.add(menuItem7)
    menuItem8 = Menu(
        name="Chicken Stir Fry",
        description="With your choice of noodles vegetables and sauces",
        price="$7.99",
        course="Entree",
        place_id=place2.id)
    db.session.add(menuItem8)
    menuItem9 = Menu(
        name="Peking Duck",
        description=
        " A famous duck dish from Beijing[1] that has been prepared since the imperial era. The meat is prized for its thin, crisp skin, with authentic versions of the dish serving mostly the skin and little meat, sliced in front of the diners by the cook",
        price="$25",
        course="Entree",
        place_id=place2.id)
    db.session.add(menuItem9)
    menuItem10 = Menu(
        name="Spicy Tuna Roll",
        description=
        "Seared rare ahi, avocado, edamame, cucumber with wasabi soy sauce ",
        price="15",
        course="Entree",
        place_id=place2.id)
    db.session.add(menuItem10)
    print "place 2"

    ############ PLACE3 MENU ITEMS ##################################################
    #################################################################################
    menuItem11 = Menu(
        name="Nepali Momo ",
        description="Steamed dumplings made with vegetables, spices and meat. ",
        price="12",
        course="Entree",
        place_id=place3.id)
    db.session.add(menuItem11)
    menuItem12 = Menu(
        name="Beef Noodle Soup",
        description=
        "A Chinese noodle soup made of stewed or red braised beef, beef broth, vegetables and Chinese noodles.",
        price="14",
        course="Entree",
        place_id=place3.id)
    db.session.add(menuItem12)
    menuItem13 = Menu(
        name="Ramen",
        description=
        "a Japanese noodle soup dish. It consists of Chinese-style wheat noodles served in a meat- or (occasionally) fish-based broth, often flavored with soy sauce or miso, and uses toppings such as sliced pork, dried seaweed, kamaboko, and green onions.",
        price="12",
        course="Entree",
        place_id=place3.id)
    db.session.add(menuItem13)
    menuItem14 = Menu(
        name="Pho",
        description=
        "a Vietnamese noodle soup consisting of broth, linguine-shaped rice noodles called banh pho, a few herbs, and meat.",
        price="$8.99",
        course="Entree",
        place_id=place3.id)
    db.session.add(menuItem14)

    menuItem15 = Menu(
        name="Chinese Dumplings",
        description=
        "a common Chinese dumpling which generally consists of minced meat and finely chopped vegetables wrapped into a piece of dough skin. The skin can be either thin and elastic or thicker.",
        price="$6.99",
        course="Appetizer",
        place_id=place3.id)
    db.session.add(menuItem15)
    print "place 3"
    ############ PLACE4 MENU ITEMS ##################################################
    #################################################################################
    menuItem16 = Menu(
        name="Gyoza",
        description=
        "The most prominent differences between Japanese-style gyoza and Chinese-style jiaozi are the rich garlic flavor, which is less noticeable in the Chinese version, the light seasoning of Japanese gyoza with salt and soy sauce, and the fact that gyoza wrappers are much thinner",
        price="$9.95",
        course="Entree",
        place_id=place4.id)
    db.session.add(menuItem16)
    menuItem17 = Menu(
        name="Stinky Tofu",
        description=
        "Taiwanese dish, deep fried fermented tofu served with pickled cabbage.",
        price="$6.99",
        course="Entree",
        place_id=place4.id)
    db.session.add(menuItem17)
    menuItem18 = Menu(
        name="Veggie Burger",
        description="Juicy grilled veggie patty with tomato mayo and lettuce",
        price="$9.50",
        course="Entree",
        place_id=place4.id)
    db.session.add(menuItem18)
    menuItem19 = Menu(
        name="Cheese Burger",
        description="Juicy grilled patty with tomato mayo and lettuce",
        price="$7.50",
        course="Entree",
        place_id=place4.id)
    db.session.add(menuItem19)
    menuItem20 = Menu(name="French Fries",
                      description="with garlic and parmesan",
                      price="$2.99",
                      course="Appetizer",
                      place_id=place4.id)
    db.session.add(menuItem20)
    print "place 4"
    ############ PLACE5 MENU ITEMS ##################################################
    #################################################################################
    menuItem21 = Menu(name="Sirloin Burger",
                      description="Made with grade A beef",
                      price="$7.99",
                      course="Entree",
                      place_id=place5.id)
    db.session.add(menuItem21)
    menuItem22 = Menu(name="Grilled Cheese Sandwich",
                      description="On texas toast with American Cheese",
                      price="$3.49",
                      course="Entree",
                      place_id=place5.id)
    db.session.add(menuItem22)
    menuItem23 = Menu(
        name="Spicy Tuna Roll",
        description=
        "Seared rare ahi, avocado, edamame, cucumber with wasabi soy sauce ",
        price="15",
        course="Entree",
        place_id=place5.id)
    db.session.add(menuItem23)
    menuItem24 = Menu(
        name="Ramen",
        description=
        "a Japanese noodle soup dish. It consists of Chinese-style wheat noodles served in a meat- or (occasionally) fish-based broth, often flavored with soy sauce or miso, and uses toppings such as sliced pork, dried seaweed, kamaboko, and green onions.",
        price="12",
        course="Entree",
        place_id=place5.id)
    db.session.add(menuItem24)
    menuItem25 = Menu(
        name="Stinky Tofu",
        description=
        "Taiwanese dish, deep fried fermented tofu served with pickled cabbage.",
        price="$6.99",
        course="Entree",
        place_id=place5.id)
    db.session.add(menuItem25)
    print "place 5"

    db.session.commit()
    print "just created menu items for each restaurant."
Exemplo n.º 20
0
 def form_valid(self):
     lines = self.form['file'].splitlines()
     Place.import_from_csv(lines)
Exemplo n.º 21
0
 def get(self):
     self.render_response({'places': Place.query()})