Beispiel #1
0
 def _generate_default_event(self):
     event = Event(name='event', calendar=self.cal1)
     event.start = dt(2014, 4, 1, 12)
     event.end = dt(2014, 4, 1, 15)
     event.save()
     event.create_and_save_occurences()
     return event
    def handle_noargs(self, **options):
        self.stdout.write('Checking for existing data ...')
        try:
            cal = Calendar.objects.get(name='Example Calendar', color='ff0000')
            self.stdout.write('It looks like you already have loaded this sample data, quitting.')
            sys.exit(1)
        except Calendar.DoesNotExist:
            self.stdout.write('No sample data found in db.')
            self.stdout.write('Install it...')

        self.stdout.write('Create User ...')
        user1 = User.objects.create_user('user1',
                                         '*****@*****.**',
                                         'userpassword')
        user1.save()

        self.stdout.write('Create Example Calendar ...')
        cal = Calendar(name='Example Calendar', color='dddddd')
        cal.save()

        self.stdout.write('The Example Calendar is created.')

        event = Event(recurrence=None,
                      name='Example Single Event',
                      calendar=cal
                      )
        event.start = dt(2014, 5, 1, 17)
        event.end = dt(2014, 5, 1, 19)
        event.save()
        event.create_and_save_occurences()

        rec = Recurrence(frequency='DAILY',
#            start=datetime.datetime(2014, 3, 30, 13),
            count=10)
        rec.save()

        event = Event(recurrence=rec,
                      name='Example Daily Event',
                      calendar=cal)
        event.start = dt(2014, 5, 1, 13)
        event.end = dt(2014, 5, 1, 18)
        event.save()
        event.create_and_save_occurences()




        """