def test_better_title(self):
     '''Test better title casing
     '''
     self.assertEquals(better_title('abcdef'), 'Abcdef')
     self.assertEquals(better_title('two words'), 'Two Words')
     self.assertEquals(better_title('THIS HAS A STOP WORD'),
                       'This Has a Stop Word')
     self.assertEquals(better_title('m.y. initials'), 'M.Y. Initials')
     self.assertEquals(better_title('the roman numeral string iii'),
                       'The Roman Numeral String III')
     self.assertEquals(better_title('costars pq llc'), 'COSTARS PQ LLC')
     self.assertEquals(better_title('I3456'), 'i3456')
     self.assertEquals(better_title('i3456'), 'i3456')
 def test_better_title(self):
     '''Test better title casing
     '''
     self.assertEquals(better_title('abcdef'), 'Abcdef')
     self.assertEquals(better_title('two words'), 'Two Words')
     self.assertEquals(better_title('THIS HAS A STOP WORD'), 'This Has a Stop Word')
     self.assertEquals(better_title('m.y. initials'), 'M.Y. Initials')
     self.assertEquals(
         better_title('the roman numeral string iii'),
         'The Roman Numeral String III'
     )
     self.assertEquals(better_title('costars pq llc'), 'COSTARS PQ LLC')
     self.assertEquals(better_title('I3456'), 'i3456')
     self.assertEquals(better_title('i3456'), 'i3456')
Пример #3
0
class CompanyForm(NoCSRFForm):
    '''A form to assign a company to a contract

    This is an individual new/existing company that is part of the
    :py:class:`~purchasing.conductor.forms.CompanyListForm` entries.
    For an individual entry, both the ``new_company_name`` and the
    ``new_company_controller_number`` *or* the ``company_name``
    and the ``controller_number`` must be filled out. Both cannot be
    filled out and they cannot be partially filled out.

    Attributes:
        new_company_controller_number: Controller number for a new company
        new_company_name: Name for a new company
        controller_number: Controller number for an existing company
        company_name: Name of an existing copany, uses a query select field
    '''
    new_company_controller_number = TextField(
        'New Company Controller Number',
        validators=[
            RequiredOne('controller_number'),
            RequiredNotBoth('controller_number'),
            RequiredIf('new_company_name'), validate_integer
        ])
    new_company_name = TextField(
        'New Company Name',
        validators=[
            RequiredOne('company_name'),
            RequiredNotBoth('company_name'),
            RequiredIf('new_company_controller_number'),
        ])

    controller_number = TextField(
        'Existing Company Controller Number',
        validators=[
            RequiredOne('new_company_controller_number'),
            RequiredNotBoth('new_company_controller_number'),
            RequiredIf('company_name'), validate_integer
        ])
    company_name = QuerySelectField(
        'Existing Company Name',
        query_factory=Company.all_companies_query_factory,
        get_pk=lambda i: i.id,
        get_label=lambda i: better_title(i.company_name),
        allow_blank=True,
        blank_text='-----',
        validators=[
            RequiredOne('new_company_name'),
            RequiredNotBoth('new_company_name'),
            RequiredIf('controller_number')
        ])
 def __init__(self, contract):
     self.title = better_title(contract.description)
     self.opportunity_type = ContractType.get_type(current_app.config.get('CONDUCTOR_TYPE', ''))
     self.department = Department.get_dept(current_app.config.get('CONDUCTOR_DEPARTMENT', ''))
 def __init__(self, contract):
     self.title = better_title(contract.description)
     self.opportunity_type = ContractType.get_type(
         current_app.config.get('CONDUCTOR_TYPE', ''))
     self.department = Department.get_dept(
         current_app.config.get('CONDUCTOR_DEPARTMENT', ''))