Beispiel #1
0
def createEventInterface():
    '''
    Initilizes a command prompt interface to create a new event. Includes:
    - start time
    - end time
    - title (opt)
    - location (opt)
    - details (opt)
    '''

    check = True
    if helpers.promptYesOrNo("Are you sure you want to create a new event?"):
        try:
            while check:
                st = helpers.promptQuestion("Input start time (Q to quit): ")
                if st and helpers.validateDateTime(st):
                    check = False
                else:
                    print '%s is not a valid date time' % st
            check = True

            while check:
                et = helpers.promptQuestion('Input end time (Q to quit): ')
                if et and helpers.validateDateTime(et):
                    check = False
                else:
                    print '%s is not a valid date time' % et

            check = True

            title = helpers.promptQuestion('Input event title (Optional, leave '
                'blank. Q to quit): ')
            loc = helpers.promptQuestion('Input location (Optional, leave '
                'blank. Q to quit): ')
            desc = helpers.promptQuestion('Input description: (Optional, leave '
                'blank. Q to quit): ')

        except helpers.QuitException:
            print 'Quitting creating event.'
            return

        st = helpers.formatDateTime(st)
        et = helpers.formatDateTime(et)

        tup = (st, et, title, loc, desc)
        return tup
    else:
        print 'Cancelling creating an event'
        return None
Beispiel #2
0
 def testValidateDateTimeException(self):
     for dt in self.bad_date_time:
         self.assertFalse(helpers.validateDateTime(dt))
Beispiel #3
0
 def testValidateDateTime(self):
     for dt in self.date_time:
         self.assertTrue(helpers.validateDateTime(dt[0]))