def setUp(self): weekly = Rule(frequency="WEEKLY") weekly.save() daily = Rule(frequency="DAILY") daily.save() cal = Calendar(name="MyCal") cal.save() self.event1 = Event( **{ 'title': 'Weekly Event', 'start': datetime.datetime(2009, 4, 1, 8, 0), 'end': datetime.datetime(2009, 4, 1, 9, 0), 'end_recurring_period': datetime.datetime(2009, 10, 5, 0, 0), 'rule': weekly, 'calendar': cal }) self.event1.save() self.event2 = Event( **{ 'title': 'Recent Event', 'start': datetime.datetime(2008, 1, 5, 9, 0), 'end': datetime.datetime(2008, 1, 5, 10, 0), 'end_recurring_period': datetime.datetime(2009, 5, 5, 0, 0), 'rule': daily, 'calendar': cal }) self.event2.save()
def setUp(self): rule = Rule(frequency="WEEKLY") rule.save() cal = Calendar(name="MyCal") cal.save() data = { 'title': 'Recent Event', 'start': datetime.datetime(2008, 1, 5, 8, 0), 'end': datetime.datetime(2008, 1, 5, 9, 0), 'end_recurring_period': datetime.datetime(2008, 5, 5, 0, 0), 'rule': rule, 'calendar': cal } self.recurring_event = Event(**data) self.recurring_event.save()
def setUp(self): rule = Rule(frequency="WEEKLY") rule.save() cal = Calendar(name="MyCal") cal.save() data = { 'title': 'Recent Event', 'start': datetime.datetime(2008, 1, 5, 8, 0), 'end': datetime.datetime(2008, 1, 5, 9, 0), 'end_recurring_period': datetime.datetime(2008, 5, 5, 0, 0), 'rule': rule, 'calendar': cal } recurring_event = Event(**data) recurring_event.save() self.month = Month(events=Event.objects.all(), date=datetime.datetime(2008, 2, 7, 9, 0))
def setUp(self): rule = Rule(frequency = "WEEKLY") rule.save() cal = Calendar(name="MyCal") cal.save() self.recurring_data = { 'title': 'Recent Event', 'start': datetime.datetime(2008, 1, 5, 8, 0), 'end': datetime.datetime(2008, 1, 5, 9, 0), 'end_recurring_period' : datetime.datetime(2008, 5, 5, 0, 0), 'rule': rule, 'calendar': cal } self.data = { 'title': 'Recent Event', 'start': datetime.datetime(2008, 1, 5, 8, 0), 'end': datetime.datetime(2008, 1, 5, 9, 0), 'end_recurring_period' : datetime.datetime(2008, 5, 5, 0, 0), 'calendar': cal }
def setUp(self): weekly = Rule(frequency = "WEEKLY") weekly.save() daily = Rule(frequency = "DAILY") daily.save() cal = Calendar(name="MyCal") cal.save() self.event1 = Event(**{ 'title': 'Weekly Event', 'start': datetime.datetime(2009, 4, 1, 8, 0), 'end': datetime.datetime(2009, 4, 1, 9, 0), 'end_recurring_period' : datetime.datetime(2009, 10, 5, 0, 0), 'rule': weekly, 'calendar': cal }) self.event1.save() self.event2 = Event(**{ 'title': 'Recent Event', 'start': datetime.datetime(2008, 1, 5, 9, 0), 'end': datetime.datetime(2008, 1, 5, 10, 0), 'end_recurring_period' : datetime.datetime(2009, 5, 5, 0, 0), 'rule': daily, 'calendar': cal }) self.event2.save()
def handle_noargs(self, **options): import datetime from appointments.models import Calendar from appointments.models import Event from appointments.models import Rule print "checking for existing data ..." try: cal = Calendar.objects.get(name="Example Calendar") print "It looks like you already have loaded this sample data, quitting." import sys sys.exit(1) except Calendar.DoesNotExist: print "Sample data not found in db." print "Install it..." print "Create Example Calendar ..." cal = Calendar(name="Example Calendar",slug="example") cal.save() print "The Example Calendar is created." print "Do we need to install the most common rules?" try: rule = Rule.objects.get(name="Daily") except Rule.DoesNotExist: print "Need to install the basic rules" rule = Rule(frequency = "YEARLY", name = "Yearly", description = "will recur once every Year") rule.save() print "YEARLY recurrence created" rule = Rule(frequency = "MONTHLY", name = "Monthly", description = "will recur once every Month") rule.save() print "Monthly recurrence created" rule = Rule(frequency = "WEEKLY", name = "Weekly", description = "will recur once every Week") rule.save() print "Weekly recurrence created" rule = Rule(frequency = "DAILY", name = "Daily", description = "will recur once every Day") rule.save() print "Daily recurrence created" print "Rules installed." print "Create some events" rule = Rule.objects.get(frequency="WEEKLY") data = { 'title': 'Exercise', 'start': datetime.datetime(2008, 11, 3, 8, 0), 'end': datetime.datetime(2008, 11, 3, 9, 0), 'end_recurring_period' : datetime.datetime(2009, 6, 1, 0, 0), 'rule': rule, 'calendar': cal } event = Event(**data) event.save() data = { 'title': 'Exercise', 'start': datetime.datetime(2008, 11, 5, 15, 0), 'end': datetime.datetime(2008, 11, 5, 16, 30), 'end_recurring_period' : datetime.datetime(2009, 6, 1, 0, 0), 'rule': rule, 'calendar': cal } event = Event(**data) event.save() data = { 'title': 'Exercise', 'start': datetime.datetime(2008, 11, 7, 8, 0), 'end': datetime.datetime(2008, 11, 7, 9, 30), 'end_recurring_period' : datetime.datetime(2009, 6, 1, 0, 0), 'rule': rule, 'calendar': cal } event = Event(**data) event.save() rule = Rule.objects.get(frequency="MONTHLY") data = { 'title': 'Pay Mortgage', 'start': datetime.datetime(2008, 11, 1, 14, 0), 'end': datetime.datetime(2008, 11, 1, 14, 30), 'end_recurring_period' : datetime.datetime(2009, 10, 2, 0, 0), 'rule': rule, 'calendar': cal } event = Event(**data) event.save() rule = Rule.objects.get(frequency="YEARLY") data = { 'title': "Rock's Birthday Party", 'start': datetime.datetime(2008, 12, 11, 19, 0), 'end': datetime.datetime(2008, 12, 11, 23, 59), 'end_recurring_period' : datetime.datetime(2009, 12, 22, 0, 0), 'rule': rule, 'calendar': cal } event = Event(**data) event.save() data = { 'title': 'Christmas Party', 'start': datetime.datetime(2008, 12, 25, 19, 30), 'end': datetime.datetime(2008, 12, 25, 23, 59), 'end_recurring_period' : datetime.datetime(2010, 12, 31, 0, 0), 'rule': rule, 'calendar': cal } event = Event(**data) event.save() data = { 'title': 'New Pinax site goes live', 'start': datetime.datetime(2009, 1, 6, 11, 0), 'end': datetime.datetime(2009, 1, 6, 12, 00), 'end_recurring_period' : datetime.datetime(2009, 1, 7, 0, 0), 'calendar': cal } event = Event(**data) event.save()
def handle_noargs(self, **options): import datetime from appointments.models import Calendar from appointments.models import Event from appointments.models import Rule print "checking for existing data ..." try: cal = Calendar.objects.get(name="yml_cal") print "It looks like you already have loaded the sample data, quitting." import sys sys.exit(1) except Calendar.DoesNotExist: print "Sample data not found in db." print "Install it..." print "Create 2 calendars : tony_cal, yml_cal" yml_cal = Calendar(name="yml_cal", slug="yml") yml_cal.save() print "First calendar is created" tony_cal = Calendar(name="tony_cal", slug="tony") tony_cal.save() print "Second calendar is created" print "Do we need to create the most common rules?" try: rule = Rule.objects.get(name="Daily") except Rule.DoesNotExist: rule = Rule(frequency="YEARLY", name="Yearly", description="will recur once every Year") rule.save() print "YEARLY recurrence created" rule = Rule(frequency="MONTHLY", name="Monthly", description="will recur once every Month") rule.save() print "Monthly recurrence created" rule = Rule(frequency="WEEKLY", name="Weekly", description="will recur once every Week") rule.save() print "Weekly recurrence created" rule = Rule(frequency="DAILY", name="Daily", description="will recur once every Day") rule.save() print "Daily recurrence created" print "The common rules are installed." print "Create some events" rule = Rule.objects.get(frequency="WEEKLY") data = { 'title': 'Ping pong', 'start': datetime.datetime(2008, 11, 1, 8, 0), 'end': datetime.datetime(2008, 11, 1, 9, 0), 'end_recurring_period': datetime.datetime(2010, 5, 5, 0, 0), 'rule': rule, 'calendar': tony_cal } event = Event(**data) event.save() rule = Rule.objects.get(frequency="DAILY") data = { 'title': 'Home work', 'start': datetime.datetime(2008, 11, 1, 18, 0), 'end': datetime.datetime(2008, 11, 1, 19, 0), 'end_recurring_period': datetime.datetime(2010, 5, 5, 0, 0), 'rule': rule, 'calendar': tony_cal } event = Event(**data) event.save()
def handle_noargs(self, **options): import datetime from appointments.models import Calendar from appointments.models import Event from appointments.models import Rule print "checking for existing data ..." try: cal = Calendar.objects.get(name="yml_cal") print "It looks like you already have loaded the sample data, quitting." import sys sys.exit(1) except Calendar.DoesNotExist: print "Sample data not found in db." print "Install it..." print "Create 2 calendars : tony_cal, yml_cal" yml_cal = Calendar(name="yml_cal",slug="yml") yml_cal.save() print "First calendar is created" tony_cal = Calendar(name="tony_cal",slug="tony") tony_cal.save() print "Second calendar is created" print "Do we need to create the most common rules?" try: rule = Rule.objects.get(name="Daily") except Rule.DoesNotExist: rule = Rule(frequency = "YEARLY", name = "Yearly", description = "will recur once every Year") rule.save() print "YEARLY recurrence created" rule = Rule(frequency = "MONTHLY", name = "Monthly", description = "will recur once every Month") rule.save() print "Monthly recurrence created" rule = Rule(frequency = "WEEKLY", name = "Weekly", description = "will recur once every Week") rule.save() print "Weekly recurrence created" rule = Rule(frequency = "DAILY", name = "Daily", description = "will recur once every Day") rule.save() print "Daily recurrence created" print "The common rules are installed." print "Create some events" rule = Rule.objects.get(frequency="WEEKLY") data = { 'title': 'Ping pong', 'start': datetime.datetime(2008, 11, 1, 8, 0), 'end': datetime.datetime(2008, 11, 1, 9, 0), 'end_recurring_period' : datetime.datetime(2010, 5, 5, 0, 0), 'rule': rule, 'calendar': tony_cal } event = Event(**data) event.save() rule = Rule.objects.get(frequency="DAILY") data = { 'title': 'Home work', 'start': datetime.datetime(2008, 11, 1, 18, 0), 'end': datetime.datetime(2008, 11, 1, 19, 0), 'end_recurring_period' : datetime.datetime(2010, 5, 5, 0, 0), 'rule': rule, 'calendar': tony_cal } event = Event(**data) event.save()
def handle_noargs(self, **options): import datetime from appointments.models import Calendar from appointments.models import Event from appointments.models import Rule print "checking for existing data ..." try: cal = Calendar.objects.get(name="Example Calendar") print "It looks like you already have loaded this sample data, quitting." import sys sys.exit(1) except Calendar.DoesNotExist: print "Sample data not found in db." print "Install it..." print "Create Example Calendar ..." cal = Calendar(name="Example Calendar", slug="example") cal.save() print "The Example Calendar is created." print "Do we need to install the most common rules?" try: rule = Rule.objects.get(name="Daily") except Rule.DoesNotExist: print "Need to install the basic rules" rule = Rule(frequency="YEARLY", name="Yearly", description="will recur once every Year") rule.save() print "YEARLY recurrence created" rule = Rule(frequency="MONTHLY", name="Monthly", description="will recur once every Month") rule.save() print "Monthly recurrence created" rule = Rule(frequency="WEEKLY", name="Weekly", description="will recur once every Week") rule.save() print "Weekly recurrence created" rule = Rule(frequency="DAILY", name="Daily", description="will recur once every Day") rule.save() print "Daily recurrence created" print "Rules installed." print "Create some events" rule = Rule.objects.get(frequency="WEEKLY") data = { 'title': 'Exercise', 'start': datetime.datetime(2008, 11, 3, 8, 0), 'end': datetime.datetime(2008, 11, 3, 9, 0), 'end_recurring_period': datetime.datetime(2009, 6, 1, 0, 0), 'rule': rule, 'calendar': cal } event = Event(**data) event.save() data = { 'title': 'Exercise', 'start': datetime.datetime(2008, 11, 5, 15, 0), 'end': datetime.datetime(2008, 11, 5, 16, 30), 'end_recurring_period': datetime.datetime(2009, 6, 1, 0, 0), 'rule': rule, 'calendar': cal } event = Event(**data) event.save() data = { 'title': 'Exercise', 'start': datetime.datetime(2008, 11, 7, 8, 0), 'end': datetime.datetime(2008, 11, 7, 9, 30), 'end_recurring_period': datetime.datetime(2009, 6, 1, 0, 0), 'rule': rule, 'calendar': cal } event = Event(**data) event.save() rule = Rule.objects.get(frequency="MONTHLY") data = { 'title': 'Pay Mortgage', 'start': datetime.datetime(2008, 11, 1, 14, 0), 'end': datetime.datetime(2008, 11, 1, 14, 30), 'end_recurring_period': datetime.datetime(2009, 10, 2, 0, 0), 'rule': rule, 'calendar': cal } event = Event(**data) event.save() rule = Rule.objects.get(frequency="YEARLY") data = { 'title': "Rock's Birthday Party", 'start': datetime.datetime(2008, 12, 11, 19, 0), 'end': datetime.datetime(2008, 12, 11, 23, 59), 'end_recurring_period': datetime.datetime(2009, 12, 22, 0, 0), 'rule': rule, 'calendar': cal } event = Event(**data) event.save() data = { 'title': 'Christmas Party', 'start': datetime.datetime(2008, 12, 25, 19, 30), 'end': datetime.datetime(2008, 12, 25, 23, 59), 'end_recurring_period': datetime.datetime(2010, 12, 31, 0, 0), 'rule': rule, 'calendar': cal } event = Event(**data) event.save() data = { 'title': 'New Pinax site goes live', 'start': datetime.datetime(2009, 1, 6, 11, 0), 'end': datetime.datetime(2009, 1, 6, 12, 00), 'end_recurring_period': datetime.datetime(2009, 1, 7, 0, 0), 'calendar': cal } event = Event(**data) event.save()