Changeset 12521 for main


Ignore:
Timestamp:
30 Jan 2015, 07:48:39 (10 years ago)
Author:
Henrik Bettermann
Message:

Use TextLineChoice? field for cutomer emails and ensure that email addresses are unique.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/customers
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/createaccount.pt

    r12039 r12521  
    1616    </tbody>
    1717  </table>
     18  <br />
    1819  <p i18n:translate="">
    1920    A customer record will be created and
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/requestpw.pt

    r12039 r12521  
    1616    </tbody>
    1717  </table>
     18  <br />
    1819  <p i18n:translate="">
    1920    Your customer record will be looked up and
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py

    r12500 r12521  
    3030
    3131from waeup.ikoba.customers.vocabularies import (
    32     contextual_reg_num_source, GenderSource, nats_vocab,
     32    contextual_reg_num_source, contextual_email_source,
     33    GenderSource, nats_vocab,
    3334    ConCatProductSource, CustomerDocumentSource,
    3435    ProductOptionSourceFactory)
     
    125126        )
    126127
    127     email = schema.ASCIILine(
     128    email = TextLineChoice(
    128129        title = _(u'Email'),
    129130        required = False,
    130131        constraint=validate_email,
     132        source = contextual_email_source,
    131133        )
    132134
     
    195197        )
    196198
    197     email = schema.ASCIILine(
     199    email = schema.TextLine(
    198200        title = _(u'Email Address'),
    199201        required = True,
     
    223225        )
    224226
    225     email = schema.ASCIILine(
    226         title = _(u'Email Address'),
    227         required = True,
     227    email = TextLineChoice(
     228        title = _(u'Email'),
     229        required = False,
    228230        constraint=validate_email,
     231        source = contextual_email_source,
    229232        )
    230233
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/sample_customer_data.csv

    r11964 r12521  
    11customer_id,firstname,lastname,reg_number,date_of_birth,,phone,sex,state
    22X666666,Aaren,Pieri,1,1990-01-02,aa@aa.ng,1234,M,requested
    3 Y777777,Claus,Finau,2,1990-01-03,aa@aa.ng,1234,m,requested
    4 ,Susann,Berson,3,1990-01-04,aa@aa.ng,1234,F,requested
    5 ,Else,Mueller,4,1990-01-05,aa@aa.ng,1234,f,approved
    6 X888888,Alfons,Meier,5,1990-01-02,aa@aa.ng,1234,m,requested
    7 X999999,Herbert,Mueller,6,1990-01-02,aa@aa.ng,1234,m,approved
    8 X111111,Fabian,Riester,7,1990-01-02,aa@aa.ng,1234,m,requested
    9 X222222,Thomas,Kinderman,8,1990-01-02,aa@aa.ng,1234,m,requested
    10 X333333,Paula,Schall,9,1990-01-02,aa@aa.ng,1234,m,approved
     3Y777777,Claus,Finau,2,1990-01-03,bb@aa.ng,1234,m,requested
     4,Susann,Berson,3,1990-01-04,cc@aa.ng,1234,F,requested
     5,Else,Mueller,4,1990-01-05,dd@aa.ng,1234,f,approved
     6X888888,Alfons,Meier,5,1990-01-02,ee@aa.ng,1234,m,requested
     7X999999,Herbert,Mueller,6,1990-01-02,ff@aa.ng,1234,m,approved
     8X111111,Fabian,Riester,7,1990-01-02,gg@aa.ng,1234,m,requested
     9X222222,Thomas,Kinderman,8,1990-01-02,hh@aa.ng,1234,m,requested
     10X333333,Paula,Schall,9,1990-01-02,ii@aa.ng,1234,m,approved
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/sample_customer_data_duplicates.csv

    r11964 r12521  
    11customer_id,firstname,lastname,reg_number,date_of_birth,email,phone,password,sex,state
    22A123456,Aaren,Pieri,1,1990-01-02#,aa@aa.ng,1234,mypw1,m,requested
    3 C123456,Aaren,Berson,2,1990-01-04,aa@aa.ng,1234,mypw1,m,approved
    4 F123456,Frank,Meyer,1,1990-01-06,aa@aa.ng,1234,,m,
    5 A123456,Uli,Schulz,3,1990-01-07,aa@aa.ng,1234,,m,
     3C123456,Aaren,Berson,2,1990-01-04,bb@aa.ng,1234,mypw1,m,approved
     4F123456,Frank,Meyer,1,1990-01-06,cc@aa.ng,1234,,m,
     5A123456,Uli,Schulz,3,1990-01-07,dd@aa.ng,1234,,m,
     6A234567,Berta,Pieri,4,1991-01-07,aa@aa.ng,1234,,m,
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py

    r12388 r12521  
    139139        customer.date_of_birth = datetime.date(1981, 2, 4)
    140140        #customer.sex = 'f'
    141         customer.email = 'anna@sample.com'
     141        customer.email = u'anna@sample.com'
    142142        customer.phone = u'+234-123-12345'
    143143        customer.notice = u'Some notice\nin lines.'
     
    279279            self.csv_file_duplicates, CUSTOMER_HEADER_FIELDS_DUPLICATES)
    280280        content = open(fail_file).read()
    281         self.assertEqual(num_warns,2)
     281        self.assertEqual(num_warns,3)
    282282        self.assertEqual(
    283283            content,
    284284            'reg_number,password,firstname,lastname,sex,phone,state,date_of_birth,customer_id,email,--ERRORS--\r\n'
    285             '1,,Frank,Meyer,m,1234,,1990-01-06,F123456,aa@aa.ng,reg_number: Invalid input\r\n'
    286             '3,,Uli,Schulz,m,1234,,1990-01-07,A123456,aa@aa.ng,This object already exists. Skipping.\r\n'
    287 
     285            '1,,Frank,Meyer,m,1234,,1990-01-06,F123456,cc@aa.ng,reg_number: Invalid input\r\n'
     286            '3,,Uli,Schulz,m,1234,,1990-01-07,A123456,dd@aa.ng,This object already exists. Skipping.\r\n'
     287            '4,,Berta,Pieri,m,1234,,1991-01-07,A234567,aa@aa.ng,email: Invalid input\r\n'
    288288            )
    289289        shutil.rmtree(os.path.dirname(fin_file))
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12517 r12521  
    127127        customer.reg_number = u'123'
    128128        customer.sex = u'm'
    129         customer.email = 'aa@aa.ng'
     129        customer.email = u'aa@aa.ng'
    130130        customer.phone = u'1234'
    131131        customer.date_of_birth = date(1981, 2, 4)
     
    210210        self.browser.getControl(name="form.reg_number").value = '123'
    211211        self.browser.getControl("Create customer record").click()
    212         self.assertTrue('Registration number exists already'
     212        self.assertTrue('Registration number does exist.'
    213213            in self.browser.contents)
    214214        self.browser.getControl(name="form.reg_number").value = '1234'
     
    220220        self.browser.getControl(name="form.reg_number").value = '123'
    221221        self.browser.getControl("Save").click()
    222         self.assertMatches('...Registration number exists...',
     222        self.assertMatches('...Registration number does exist...',
    223223                           self.browser.contents)
    224224
     
    358358        self.browser.getControl("Send message now").click()
    359359        self.assertTrue('An smtp server error occurred' in self.browser.contents)
    360         self.customer.email = 'xx@yy.zz'
     360        self.customer.email = u'xx@yy.zz'
    361361        self.browser.getControl("Send message now").click()
    362362        self.assertTrue('Your message has been sent' in self.browser.contents)
     
    420420        open('customers.csv', 'wb').write(
    421421"""firstname,lastname,reg_number,date_of_birth,email,phone,sex,password
    422 Aaren,Pieri,1,1990-01-02,aa@aa.ng,1234,m,mypwd1
    423 Claus,Finau,2,1990-01-03,aa@aa.ng,1234,m,mypwd1
    424 Brit,Berson,2,1990-01-04,aa@aa.ng,1234,m,mypwd1
     422Aaren,Pieri,1,1990-01-02,bb@aa.ng,1234,m,mypwd1
     423Claus,Finau,2,1990-01-03,cc@aa.ng,1234,m,mypwd1
     424Brit,Berson,2,1990-01-04,dd@aa.ng,1234,m,mypwd1
    425425""")
    426426        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     
    766766
    767767    def test_create_account(self):
    768         # Customer with wrong number can't be found.
    769768        self.browser.open('http://localhost/app/createaccount')
    770769        self.browser.getControl(name="form.firstname").value = 'Ruben'
    771770        self.browser.getControl(name="form.lastname").value = 'Gonzales'
     771        self.browser.getControl(name="form.email").value = 'aa@aa.ng'
     772        self.browser.getControl("Send login credentials").click()
     773        # Email address exists.
     774        self.assertTrue('Email address does exist.' in self.browser.contents)
    772775        self.browser.getControl(name="form.email").value = 'newcustomer@xx.zz'
    773776        self.browser.getControl("Send login credentials").click()
    774         self.assertTrue('Your request was successful.'
    775             in self.browser.contents)
    776         # ... and  customer can be found in the catalog via the email address
     777        self.assertTrue('Your request was successful.' in self.browser.contents)
     778        # Customer can be found in the catalog via the email address
    777779        cat = queryUtility(ICatalog, name='customers_catalog')
    778780        results = list(
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/vocabularies.py

    r12445 r12521  
    6262
    6363class RegNumNotInSource(ValidationError):
    64     """Registration number exists already
     64    """Registration number does exist.
    6565    """
    6666    # The docstring of ValidationErrors is used as error description
    6767    # by zope.formlib.
     68    pass
     69
     70class EmailNotInSource(ValidationError):
     71    """Email address does exist.
     72    """
    6873    pass
    6974
     
    121126directlyProvides(contextual_reg_num_source, IContextSourceBinder)
    122127
     128class EmailSource(RegNumberSource):
     129    field_name = 'email'
     130    validation_error = EmailNotInSource
     131
     132def contextual_email_source(context):
     133    source = EmailSource(context)
     134    return source
     135directlyProvides(contextual_email_source, IContextSourceBinder)
     136
    123137
    124138class ConCatProductSource(BasicContextualSourceFactory):
Note: See TracChangeset for help on using the changeset viewer.