Closed_at fill command

This commit is contained in:
Kuroshini 2019-10-16 14:11:07 +03:00
parent 995d55302a
commit 7bba5237dc
2 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,14 @@
from django.core.management.base import BaseCommand
from timetable.models import Timetable
class Command(BaseCommand):
help = '''Add closed_at, opening_at Timetable fields'''
def handle(self, *args, **options):
for tt in Timetable.objects.all():
end = tt.dinner_end or tt.lunch_end
start = tt.lunch_start or tt.dinner_start
if end or start:
tt.closed_at = end
tt.opening_at = start
tt.save()

View File

@ -66,6 +66,7 @@ card = {
"fields": {
"Schedules": {
# нет аналогов для weekday, opening_at, closed_at
# upd: запустить команду add_closed_at_timetable. она заполнит opening_at, closed_at
"lunch_start": "lunch_start",
"lunch_end": "lunch_end",
"diner_start": "diner_start",