blob: 41d53b664ab64fdd707a76209e998e1c40dca5dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import datetime
from django.utils import timezone
from web.models import Event
start_date = timezone.now() # This should always be the first of a month or the day after the last event's end date
end_date = None
event_duration = 7
events_to_create = 100
participants = 5
current_month = start_date.strftime('%B')
current_month_count = 1 # change this to +1 of whatever the last band practice is
for i in range(events_to_create):
if start_date.strftime('%B') != current_month:
current_month = start_date.strftime('%B')
current_month_count = 1
end_date = start_date + datetime.timedelta(days=event_duration)
name = f'[BP] {current_month} {current_month_count}'
e = Event(
start_date=start_date,
end_date=end_date,
name=name,
participants=participants
)
e.save()
start_date = end_date + datetime.timedelta(days=1)
current_month_count += 1
|