Пример #1
0
    def handle(self, *args, **options):
        Restaurant.objects.all().delete()

        with open(args[0], 'rb') as csvfile:
            reader = csv.DictReader(csvfile)

            for row in reader:
                # clean up
                for k, v in row.items():
                    if v == '?' or len(v) < MIN_FIELD_LEN:
                        # discard
                        row[k] = None
                        continue

                    if k == 'Mail' and '@' not in v:
                        row[k] = None
                        continue

                    row[k] = v.strip()

                if not row['Nom'] or not row['Adresse']:
                    continue

                resto = Restaurant.create(random.randint(1, 2**32), row['Nom'], row['Adresse'], row['Site'], row['Téléphone'], row['Mail'], row['Personne de contact'], row['Suivi'], row['Personne responsable'])

                if row['Vg']:
                    tags = parse_vg_tags(row['Vg'])
                    if tags:
                        resto.tags.add(*tags)
                        resto.save()
Пример #2
0
    def handle(self, *args, **options):
        with transaction.atomic():
            Restaurant.objects.all().delete()

            with open(args[0], 'rb') as csvfile:
                reader = csv.DictReader(csvfile)

                for fake_id, row in enumerate(reader, 1):
                    if not row['Nom du restaurant']:
                        continue

                    print row['Nom du restaurant']
                    restaurant = Restaurant.create(
                        vegoresto_id=fake_id,
                        name=row['Nom du restaurant'].decode("Utf-8"),
                        address=row['Adresse compl\xc3\xa8te'].decode("Utf-8"),
                        website=row['Site web'].decode("Utf-8"),
                        contact=row['Votre email'].decode("Utf-8"),
                    )

                    restaurant.active = True
                    review = row['Plat v\xc3\xa9g\xc3\xa9tarien/v\xc3\xa9g\xc3\xa9talien que vous avez mang\xc3\xa9']
                    if len(review) < 10:
                        restaurant.review = "Il n'y a pas eu d'informations données par la personne ayant soumis le restaurant."
                    else:
                        restaurant.review = review

                    restaurant.save()
Пример #3
0
    def handle(self, *args, **options):
        with transaction.atomic():
            Restaurant.objects.all().delete()

            with open(args[0], 'rb') as csvfile:
                reader = csv.DictReader(csvfile)

                for fake_id, row in enumerate(reader, 1):
                    if not row['Nom du restaurant']:
                        continue

                    print row['Nom du restaurant']
                    restaurant = Restaurant.create(
                        vegoresto_id=fake_id,
                        name=row['Nom du restaurant'].decode("Utf-8"),
                        address=row['Adresse compl\xc3\xa8te'].decode("Utf-8"),
                        website=row['Site web'].decode("Utf-8"),
                        contact=row['Votre email'].decode("Utf-8"),
                    )

                    restaurant.active = True
                    review = row[
                        'Plat v\xc3\xa9g\xc3\xa9tarien/v\xc3\xa9g\xc3\xa9talien que vous avez mang\xc3\xa9']
                    if len(review) < 10:
                        restaurant.review = "Il n'y a pas eu d'informations données par la personne ayant soumis le restaurant."
                    else:
                        restaurant.review = review

                    restaurant.save()
Пример #4
0
    def handle(self, *args, **options):
        Restaurant.objects.all().delete()

        with open(args[0], 'rb') as csvfile:
            reader = csv.DictReader(csvfile)

            for row in reader:
                # clean up
                for k, v in row.items():
                    if v == '?' or len(v) < MIN_FIELD_LEN:
                        # discard
                        row[k] = None
                        continue

                    if k == 'Mail' and '@' not in v:
                        row[k] = None
                        continue

                    row[k] = v.strip()

                if not row['Nom'] or not row['Adresse']:
                    continue

                resto = Restaurant.create(random.randint(1, 2**32), row['Nom'],
                                          row['Adresse'], row['Site'],
                                          row['Téléphone'], row['Mail'],
                                          row['Personne de contact'],
                                          row['Suivi'],
                                          row['Personne responsable'])

                if row['Vg']:
                    tags = parse_vg_tags(row['Vg'])
                    if tags:
                        resto.tags.add(*tags)
                        resto.save()
Пример #5
0
    def handle(self, *args, **options):

        s = urllib2.urlopen(source_url)
        xml_content = s.read()
        soup = BeautifulSoup(xml_content)

        with transaction.atomic():
            # hide everything, then we'll set restaurant with a
            # review as active later
            Restaurant.objects.update(active=False)

            for resto_data in soup.root.findAll('item'):
                vegoresto_id = int(resto_data.id.text)
                resto_set = Restaurant.objects.filter(
                    vegoresto_id=vegoresto_id)
                name = resto_data.titre.text
                print 'importing {0}'.format(name.encode('utf-8'))

                if resto_set.exists():
                    resto = resto_set[0]
                    resto.name = unescape(unescape(name))
                    resto.address = unescape(resto_data.adresse.text)
                else:
                    resto = Restaurant.create(vegoresto_id=vegoresto_id,
                                              name=unescape(unescape(name)),
                                              address=unescape(
                                                  resto_data.adresse.text))

                resto.active = True

                resto.review = unescape(resto_data.vegetik_review.text)
                resto.approved_date = parse(
                    resto_data.vegetik_approved_date.text)
                resto.lat = float(resto_data.lat.text)
                resto.lon = float(resto_data.lon.text)
                resto.website = resto_data.site_internet.text
                resto.description = resto_data.description.text
                resto.phone = resto_data.tel_fixe.text
                resto.mail = resto_data.mel_public.text
                resto.main_image = resto_data.image.text
                resto.country_code = resto_data.pays.text.upper()
                resto.vegoresto_url = resto_data.vego_url.text
                if resto_data.vegoresto.text == '1':
                    resto.vegoresto = True

                tags = parse_vg_tags(resto_data.categories_culinaires.text)
                if resto_data.vegetik_veganfriendly.text == 'TRUE':
                    tags.add(VEGAN_FRIENDLY)
                if tags:
                    resto.tags.add(*tags)

                resto.save()
Пример #6
0
    def handle(self, *args, **options):

        s = urllib2.urlopen(source_url)
        xml_content = s.read()
        soup = BeautifulSoup(xml_content)

        with transaction.atomic():
            # hide everything, then we'll set restaurant with a
            # review as active later
            Restaurant.objects.update(active=False)

            for resto_data in soup.root.findAll('item'):
                vegoresto_id = int(resto_data.id.text)
                resto_set = Restaurant.objects.filter(vegoresto_id=vegoresto_id)
                name = resto_data.titre.text
                print 'importing {0}'.format(name.encode('utf-8'))

                if resto_set.exists():
                    resto = resto_set[0]
                    resto.name = unescape(unescape(name))
                    resto.address = unescape(resto_data.adresse.text)
                else:
                    resto = Restaurant.create(vegoresto_id=vegoresto_id,
                                              name=unescape(unescape(name)),
                                              address=unescape(resto_data.adresse.text))

                resto.active = True

                resto.review = unescape(resto_data.vegetik_review.text)
                resto.approved_date = parse(resto_data.vegetik_approved_date.text)
                resto.lat = float(resto_data.lat.text)
                resto.lon = float(resto_data.lon.text)
                resto.website = resto_data.site_internet.text
                resto.description = resto_data.description.text
                resto.phone = resto_data.tel_fixe.text
                resto.mail = resto_data.mel_public.text
                resto.main_image = resto_data.image.text
                resto.country_code = resto_data.pays.text.upper()
                resto.vegoresto_url = resto_data.vego_url.text
                if resto_data.vegoresto.text == '1':
                    resto.vegoresto = True

                resto.tags.clear()

                tags = parse_vg_tags(resto_data.categories_culinaires.text)
                if resto_data.vegetik_veganfriendly.text == 'TRUE':
                    tags.add(VEGAN_FRIENDLY)
                if tags:
                    resto.tags.add(*tags)

                resto.save()
Пример #7
0
    def handle(self, *args, **options):
        Restaurant.objects.all().delete()

        Restaurant.create(1, "Exki", "12, Chaussée D'Ixelles, 1050 Ixelles", 'www.exki.be', '02/502.72.77', status='2ème vague')
        Restaurant.create(2, "Ellis Gourmet Burger", "Place Sainte-Catherine, 4 - 1000 Bruxelles", "http://www.ellisgourmetburger.com/nl/", "02/514.23.14", status="OK (autocollant)", vg_contact="Lisa & Sophie - 28/06")
        Restaurant.create(3, "Den Teepot", "66, Rue des Chartreux 1000 Bruxelles", "http://www.bioshop.be/winkels/brussel.html", "02/511.94.02", status="OK (autocollant)", vg_contact="Lisa & Sophie - 28/06")
        Restaurant.create(4, "Toukoul", "34, Rue de Laeken 1000 Bruxelles ", "http://www.toukoul.be", "02/223.73.77", "*****@*****.**", status="repasser à 13h", vg_contact="Lisa & Sophie - 28/06")
        Restaurant.create(5, "Mr Falafel", "53, Boulevard Lemonnier - 1000 Bruxelles", None, "0493/34.64.12", None, status="OK (autocollant)", vg_contact="Lisa & Sophie - 28/06")
        Restaurant.create(6, "Le Dolma", "329, Chaussée d'Ixelles - 1050 Ixelles", "www.dolma.be", "02/649.89.81", "*****@*****.**", status="OK (autocollant)", vg_contact="Lisa & Sophie H & Isabelle - 05/07")
Пример #8
0
    def handle(self, *args, **options):
        Restaurant.objects.all().delete()

        Restaurant.create(1,
                          "Exki",
                          "12, Chaussée D'Ixelles, 1050 Ixelles",
                          'www.exki.be',
                          '02/502.72.77',
                          status='2ème vague')
        Restaurant.create(2,
                          "Ellis Gourmet Burger",
                          "Place Sainte-Catherine, 4 - 1000 Bruxelles",
                          "http://www.ellisgourmetburger.com/nl/",
                          "02/514.23.14",
                          status="OK (autocollant)",
                          vg_contact="Lisa & Sophie - 28/06")
        Restaurant.create(3,
                          "Den Teepot",
                          "66, Rue des Chartreux 1000 Bruxelles",
                          "http://www.bioshop.be/winkels/brussel.html",
                          "02/511.94.02",
                          status="OK (autocollant)",
                          vg_contact="Lisa & Sophie - 28/06")
        Restaurant.create(4,
                          "Toukoul",
                          "34, Rue de Laeken 1000 Bruxelles ",
                          "http://www.toukoul.be",
                          "02/223.73.77",
                          "*****@*****.**",
                          status="repasser à 13h",
                          vg_contact="Lisa & Sophie - 28/06")
        Restaurant.create(5,
                          "Mr Falafel",
                          "53, Boulevard Lemonnier - 1000 Bruxelles",
                          None,
                          "0493/34.64.12",
                          None,
                          status="OK (autocollant)",
                          vg_contact="Lisa & Sophie - 28/06")
        Restaurant.create(6,
                          "Le Dolma",
                          "329, Chaussée d'Ixelles - 1050 Ixelles",
                          "www.dolma.be",
                          "02/649.89.81",
                          "*****@*****.**",
                          status="OK (autocollant)",
                          vg_contact="Lisa & Sophie H & Isabelle - 05/07")