make format

This commit is contained in:
SebF
2024-05-03 19:30:36 +02:00
parent b2a4df5be7
commit 4f80d00485
28 changed files with 65 additions and 94 deletions

View File

@@ -1,8 +1,9 @@
from agenda_culturel.models import Category
def run():
# concert, théâtre, jeune public, danse, arts du spectacle, exposition
# conférence, nature,
# conférence, nature,
# divers
categories = [
@@ -14,12 +15,13 @@ def run():
("Exposition", "Expositions", "E"),
("Conférence", "Conférences", "C"),
("Nature", "Événements nature", "N"),
("Autre", "Autres événements", "A")
("Autre", "Autres événements", "A"),
]
if len(Category.objects.all()) <= 1:
print("On créée des catégories")
for c in categories:
cat = Category(name=c[0], alt_name = c[1] if c[1] is not None else c[0], codename=c[2])
cat = Category(
name=c[0], alt_name=c[1] if c[1] is not None else c[0], codename=c[2]
)
cat.save()

View File

@@ -1,38 +1,39 @@
from djipsum.faker import FakerModel
from agenda_culturel.models import Category, Event
from agenda_culturel.models import Event
import random
from datetime import datetime, timedelta
def run():
def run():
tags = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
tags = [w for w in tags.replace(",", "").replace(".", "").split() if len(w) >= 3]
faker = FakerModel(app='agenda_culturel', model='Event')
faker = FakerModel(app="agenda_culturel", model="Event")
def random_hour():
m = random.randint(0,59)
h = random.randint(0,23)
s = random.randint(0,59)
return f'{h}:{m}:{s}'
m = random.randint(0, 59)
h = random.randint(0, 23)
s = random.randint(0, 59)
return f"{h}:{m}:{s}"
for j in range(20):
sday = datetime.now() + timedelta(days=random.randint(0, 40))
fields = {
'title': faker.fake.text(max_nb_chars=100),
'status': Event.STATUS.PUBLISHED,
'category': faker.fake_relations(
type='fk',
field_name='category'
),
'start_day': sday.date(),
'location': faker.fake.text(max_nb_chars=100),
'description': ' '.join(faker.fake.paragraphs()),
'image': faker.fake.url(),
'image_alt': faker.fake.text(max_nb_chars=100),
'reference_urls': [faker.fake.url() for i in range(0, random.randint(0, 5))],
'tags': [tags[random.randint(0, len(tags) - 1)] for i in range(0, random.randint(0, 10))]
"title": faker.fake.text(max_nb_chars=100),
"status": Event.STATUS.PUBLISHED,
"category": faker.fake_relations(type="fk", field_name="category"),
"start_day": sday.date(),
"location": faker.fake.text(max_nb_chars=100),
"description": " ".join(faker.fake.paragraphs()),
"image": faker.fake.url(),
"image_alt": faker.fake.text(max_nb_chars=100),
"reference_urls": [
faker.fake.url() for i in range(0, random.randint(0, 5))
],
"tags": [
tags[random.randint(0, len(tags) - 1)]
for i in range(0, random.randint(0, 10))
],
}
if random.randint(0, 1) == 1:
fields["start_time"] = random_hour()
@@ -42,4 +43,3 @@ def run():
if random.randint(0, 1) == 1:
fields["end_time"] = random_hour()
faker.create(fields)