summaryrefslogtreecommitdiff
path: root/program/management
diff options
context:
space:
mode:
authorErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2013-03-10 21:18:14 (GMT)
committerErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2013-03-10 21:18:14 (GMT)
commit12950ac0f6563e3b22375e11ee5d8295dfbd4234 (patch)
treece56e10ffffeb0889499fbed004775d0ff1eb249 /program/management
parent100a5776d1e06f2738592bf40537305a61ed93ea (diff)
added support for timeslot index when adding notes.
Diffstat (limited to 'program/management')
-rw-r--r--program/management/commands/addnote.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/program/management/commands/addnote.py b/program/management/commands/addnote.py
index 4379e2f..97ae885 100644
--- a/program/management/commands/addnote.py
+++ b/program/management/commands/addnote.py
@@ -9,15 +9,17 @@ from program.models import Show, TimeSlot, Note
class Command(BaseCommand):
help = 'adds a note to a timeslot'
- args = '<show_id> <date> <status>'
+ args = '<show_id> <start_date> <status> [index]'
def handle(self, *args, **options):
if len(args) == 3:
show_id = args[0]
start_date = args[1]
status = args[2]
+ elif len(args) == 4:
+ index = args[3]
else:
- raise CommandError('you must provide the show_id, start_date, status')
+ raise CommandError('you must provide the show_id, start_date, status [index]')
try:
show = Show.objects.get(id=show_id)
@@ -35,6 +37,13 @@ class Command(BaseCommand):
timeslot = TimeSlot.objects.get(show=show, start__year=year, start__month=month, start__day=day)
except TimeSlot.DoesNotExist as dne:
raise CommandError(dne)
+ except TimeSlot.MultipleObjectsReturned as mor:
+ if not index:
+ raise CommandError('you must provide the show_id, start_date, status index')
+ try:
+ timeslot = TimeSlot.objects.filter(show=show, start__year=year, start__month=month, start__day=day).order_by('start')[index]
+ except IndexError as ie:
+ raise CommandError(ie)
try:
title = sys.stdin.readline().rstrip()