Esempio n. 1
0
    def change_card_screen(self):
        card_dict = main.card_info(self.file_name.text,
                                   self.card_num_input.text)
        s = self.manager.get_screen('Add or Modify Card')
        s.card_num_input.text = self.card_num_input.text
        s.card_num_input.disabled = False
        s.card_num_input.focus = True
        s.name_input.text = card_dict['name']
        s.under_13_input.text = card_dict['under_13']
        s.under_18_input.text = card_dict['under_18']
        s.under_60_input.text = card_dict['under_60']
        s.over_59_input.text = card_dict['over_59']
        s.zip_code_input.text = card_dict['zip']
        try:
            s.last_used_date = datetime.strptime(card_dict['last_used_date'],
                                                 '%m/%d/%Y')
        except ValueError:
            s.last_used_date = main.date_today

        s.last_used_string = card_dict['last_used_date']
        s.file_name.text = self.file_name.text
        s.add_card_mode = False
        s.change_card_mode = True
        s.card_num_input.focus = True

        self.manager.transition.direction = 'up'
        self.manager.current = 'Add or Modify Card'
Esempio n. 2
0
def add_card(config, name, used_today):
    card_dict = {'card_num':config['card_num'], 'last_used_date':'N/A', 'name':name}

    if name is None:
        card_dict['name'] = click.prompt('please enter a name', type=str)

    if used_today or click.confirm('used today?'):
        card_dict['last_used_date'] = main.date_today.strftime('%m/%d/%Y')

    else:
        if click.confirm('set date?'):
            card_dict['last_used_date'] = set_date()

    for item in main.csv_layout:
        if all([item is not 'last_used_date', item is not 'name', item is not 'card_num']):
            card_dict[item] = click.prompt(
                'to what would you like to set {0} for this card?'
                .format(item), type=str)

    result = main.add_card(config['csv_file'], card_dict)

    card_dict_new = main.card_info(config['csv_file'], config['card_num'])

    if result is 0:
        click.echo('card number {0} successfully added on row {1}'
                   .format(config['card_num'], card_dict_new['row_num']))
    if result is 1:
        click.echo('card number {0} already exists on row {1}'
                   .format(config['card_num'], card_dict_new['row_num']))
    if result is 2:
        click.echo('{0} is not a valid date format'
                   .format(card_dict['last_used_date']))
Esempio n. 3
0
    def display_card_info(self, card_num):
        card_dict = main.card_info(self.file_name.text, card_num)

        self.card_num_label.text = '[b]number:[/b] ' + card_dict['card_num']
        self.name_label.text = '[b]name:[/b] ' + card_dict['name']
        self.under_13_label.text = '[b]children 12 and under:[/b] ' + card_dict[
            'under_13']
        self.under_18_label.text = '[b]children over the age of 12:[/b] ' + card_dict[
            'under_18']
        self.under_60_label.text = '[b]adults under the age of 60:[/b] ' + card_dict[
            'under_60']
        self.over_59_label.text = '[b]adults age 60 and older:[/b] ' + card_dict[
            'over_59']
        self.zip_code_label.text = '[b]zip code:[/b] ' + card_dict['zip']
        self.last_used_label.text = '[b]card last used on:[/b] ' + card_dict[
            'last_used_date']
Esempio n. 4
0
    def display_card_info(self):
        card_dict = main.card_info(self.windowTitle(), self.numLineEdit.displayText())

        self.nameLineEdit.setText(card_dict['name'])
        self.under13SpinBox.setValue(int(card_dict['under_13']) if card_dict['under_13'] != '' else 0)
        self.over12SpinBox.setValue(int(card_dict['under_18']) if card_dict['under_18'] != '' else 0)
        self.under60SpinBox.setValue(int(card_dict['under_60']) if card_dict['under_60'] != '' else 0)
        self.over59SpinBox.setValue(int(card_dict['over_59']) if card_dict['over_59'] != '' else 0)
        self.zipCodeLineEdit.setText(card_dict['zip'])

        if(card_dict['last_used_date'] == 'N/A'):
            self.lastUsedLayout.setHidden(True)

        else:
            self.lastUsedDateEdit.setDate(datetime.strptime(
            card_dict['last_used_date'], '%m/%d/%Y'))
Esempio n. 5
0
def change_card(config):
    result = None
    card_info = main.card_info(config['csv_file'], config['card_num'])

    if card_info is not 1:
        if click.confirm('change number?'):
            card_info['card_num'] = click.prompt(
                'please enter the new card number', type=str)

        if click.confirm('change name?'):
            card_info['name'] = click.prompt('please enter the new name', type=str)

        if click.confirm('change last used date?'):
            if click.confirm('change to today?'):
                card_info['last_used_date'] = main.date_today.strftime('%m/%d/%Y')
            else:
                card_info['last_used_date'] = set_date()

        for item in main.csv_layout:
            if all([item is not 'last_used_date', item is not 'name', item is not 'card_num',
                    click.confirm('change {0} for this card?'.format(item))]):
                card_info[item] = click.prompt(
                    'to what would you like to set {0} for this card?'
                    .format(item), type=str)

        result = main.change_card(config['csv_file'], config['card_num'],
                                  card_info)

        if result is 0:
            click.echo('card information changed successfully')
        elif result is 1:
            click.echo('card number {0} not found'
                       .format(config['card_num']))
        elif result is 2:
            click.echo('card number {0} already exists'
                       .format(card_info['card_num']))
        elif result is 3:
            click.echo('{0} is an invalid date'
                       .format(card_info['last_used_date']))
    else:
        click.echo('card does not exist')