Changeset 5251 for TI01-discovery


Ignore:
Timestamp:
05/05/09 15:51:16 (10 years ago)
Author:
cbyrom
Message:

Add new field to provider info - email - to allow mailing of results
of document ingest results - since this needs to be done asynchronously

  • since it can take a considerable amount of time. Adjust controllers

and templates for this new field and add new tests.

Location:
TI01-discovery/trunk/OAIInfoEditor/oai_info_editor
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/controllers/edit.py

    r5245 r5251  
    4141 
    4242        self.providerName = urllib.unquote(self.inputs.get(PI.NAME_ATT_NAME)) 
    43          
     43        self.providerEmail = urllib.unquote(self.inputs.get(PI.EMAIL_ADDRESS_NAME)) 
    4444        # NB, we always need the provider name specified - this is effectively the 
    4545        # primary key for the data 
     
    140140            return self.editProviderInfo(providerName) 
    141141 
    142         pi = PI.createProviderInfoWithData(self.providerName, self.repositoryInfos) 
     142        pi = PI.createProviderInfoWithData(self.providerName, self.repositoryInfos,  
     143                                           providerEmail = self.providerEmail) 
    143144        pi.oldName = providerName 
    144145 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/model/providerinfo.py

    r5242 r5251  
    1515PI_ROOT_EL_NAME = "providerInfo" 
    1616NAME_ATT_NAME = "name" 
     17EMAIL_ADDRESS_NAME = "email" 
    1718 
    1819 
    19 def createProviderInfoWithData(providerName, repositoryInfos): 
     20def createProviderInfoWithData(providerName, repositoryInfos, providerEmail = None): 
    2021    ''' 
    2122    Factory method to create ProviderInfo object with set values 
    2223    @param providerName: Name of the provider - NB, this should equal their login ID 
    2324    @param repositoryInfos:  RepositoryInfo objects with data on the providers repositories 
     25    @keyword providerEmail: email address for provider 
     26    @return ProviderInfo with specified data  
    2427    ''' 
    25     cr = ProviderInfo() 
    26     cr.setData(providerName, repositoryInfos) 
    27     return cr 
     28    pi = ProviderInfo() 
     29    pi.setData(providerName, repositoryInfos, providerEmail = providerEmail) 
     30    return pi 
    2831 
    2932 
     
    3336    # NB, 'oldName' is used when the provider name is being updated - so the 
    3437    # old record can be effectively updated 
    35     __slots__ = [NAME_ATT_NAME, 'repositoryInfos', 'oldName'] 
     38    __slots__ = [NAME_ATT_NAME, EMAIL_ADDRESS_NAME, 'repositoryInfos', 'oldName'] 
    3639 
    3740    def __init__(self, et = None): 
     
    5053 
    5154 
    52     def setData(self, providerName, repositoryInfos): 
     55    def setData(self, providerName, repositoryInfos, providerEmail = None): 
    5356        ''' 
    5457        Simple method to set data on object 
    5558        @param providerName: Name of the provider - NB, this should equal their login ID 
    5659        @param repositoryInfos:  RepositoryInfo objects with data on the providers repositories 
     60        @keyword providerEmail: email address for provider. Default = None 
    5761        ''' 
    5862        logging.debug("Setting data on ProviderInfo document object") 
     
    6064        self.oldName = self.name 
    6165        self.repositoryInfos = repositoryInfos 
     66        self.email = providerEmail 
    6267        logging.debug("ProviderInfo data set") 
    6368 
     
    7479 
    7580        self.name = et.attrib.get(NAME_ATT_NAME) 
     81        self.email = et.findtext(EMAIL_ADDRESS_NAME) or '' 
    7682        self.oldName = self.name 
    7783         
     
    96102        root = ET.Element(PI_ROOT_EL_NAME) 
    97103        root.attrib[NAME_ATT_NAME] = self.name 
     104 
     105        if self.email: 
     106            emailElement = ET.SubElement(root, EMAIL_ADDRESS_NAME) 
     107            emailElement.text = self.email 
    98108         
    99109        if self.repositoryInfos: 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/templates/provider_info.html

    r5242 r5251  
    2929                                <th width="3%" /> 
    3030                                <th width="3%" /> 
    31                         <th align="left">Provider Name</th> 
     31                        <th align="left" width="60%">Provider Name</th> 
     32                        <th align="left">Provider Email</th> 
    3233                </tr> 
    3334                <div py:replace="ProviderInfoRecord(records, isEditable, editLink, harvestLink)" /> 
     
    5253        adminEdit = True 
    5354                ?> 
    54                 <div py:replace="EditTextField(PI.NAME_ATT_NAME, record.name, adminEdit, constants.TEXT_FIELD, width='20%')"/> 
     55                <div py:replace="EditTextField(PI.NAME_ATT_NAME, record.name, adminEdit, constants.TEXT_FIELD, width='60%')"/> 
     56                <div py:replace="EditTextField(PI.EMAIL_ADDRESS_NAME, record.email, isEditable, constants.TEXT_FIELD)"/> 
    5557                <input py:if="not adminEdit" type="hidden" name="${PI.NAME_ATT_NAME}" value="${record.name}"/> 
    5658        </tr> 
     
    5860                <td /> 
    5961                <th>Repository Info</th> 
    60                 <td> 
     62                <td colspan="2"> 
    6163                <div py:replace="RepositoryInfoTable(record.repositoryInfos, isEditable, editLink, harvestLink.replace(constants.PROVIDER_REPLACEMENT, urllib.quote(record.name)))" /> 
    6264                </td> 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/tests/model/testproviderinfo.py

    r5238 r5251  
    2727        self.assertEquals(VALID_REPOSITORY_INFOS_1, pi.repositoryInfos) 
    2828 
     29    def testCreateProviderInfoWithDataWithEmail(self): 
     30        pi = createProviderInfoWithData(VALID_PROVIDER_NAME_1, VALID_REPOSITORY_INFOS_1, 
     31                                        providerEmail = VALID_PROVIDER_EMAIL) 
     32        self.assertEquals(VALID_PROVIDER_NAME_1, pi.name) 
     33        self.assertEquals(len(VALID_REPOSITORY_INFOS_1), len(pi.repositoryInfos)) 
     34        self.assertEquals(VALID_REPOSITORY_INFOS_1, pi.repositoryInfos) 
     35        self.assertEquals(VALID_PROVIDER_EMAIL, pi.email) 
     36 
    2937    def testCreateProviderInfoWithoutData(self): 
    3038        pi = createProviderInfoWithData(VALID_PROVIDER_NAME_1, []) 
     
    4250        self.assertEquals(len(VALID_REPOSITORY_INFOS_1), len(self.pi.repositoryInfos)) 
    4351        self.assertEquals(VALID_REPOSITORY_INFOS_1, self.pi.repositoryInfos) 
     52     
     53    def testSetDataWithDataWithEmail(self): 
     54        self.pi.setData(VALID_PROVIDER_NAME_1, VALID_REPOSITORY_INFOS_1, 
     55                        providerEmail = VALID_PROVIDER_EMAIL) 
     56        self.assertEquals(VALID_PROVIDER_NAME_1, self.pi.name) 
     57        self.assertEquals(len(VALID_REPOSITORY_INFOS_1), len(self.pi.repositoryInfos)) 
     58        self.assertEquals(VALID_REPOSITORY_INFOS_1, self.pi.repositoryInfos) 
     59        self.assertEquals(VALID_PROVIDER_EMAIL, self.pi.email) 
    4460         
    4561    def testFromET(self): 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/tests/testdata/test_provider_info_collection.xml

    r5226 r5251  
    33   <harvestDir>/tmp/harvest_me_now/</harvestDir> 
    44   <providerInfo name="provider1"> 
     5          <email>BOB@Bob.com</email> 
    56          <repositoryInfo> 
    67                  <harvestTime>09:00</harvestTime> 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/tests/testdata/testconstants.py

    r5239 r5251  
    110110VALID_PROVIDER_NAME_2 = "provider2" 
    111111VALID_PROVIDER_NAME_3 = "provider3" 
     112VALID_PROVIDER_EMAIL = "BOB@Bob.com" 
    112113ALL_VALID_PROVIDER_NAMES = [VALID_PROVIDER_NAME_1, VALID_PROVIDER_NAME_2, VALID_PROVIDER_NAME_3] 
    113114VALID_REPOSITORY_INFOS_1 = [REPOSITORY_INFO_0] 
    114115VALID_REPOSITORY_INFOS_2 = [REPOSITORY_INFO_1, REPOSITORY_INFO_2, REPOSITORY_INFO_3] 
    115 PROVIDER_INFO_1 = createProviderInfoWithData(VALID_PROVIDER_NAME_1, VALID_REPOSITORY_INFOS_1) 
     116PROVIDER_INFO_1 = createProviderInfoWithData(VALID_PROVIDER_NAME_1, VALID_REPOSITORY_INFOS_1, 
     117                                             providerEmail = VALID_PROVIDER_EMAIL) 
    116118PROVIDER_INFO_2 = createProviderInfoWithData(VALID_PROVIDER_NAME_2, VALID_REPOSITORY_INFOS_2) 
    117119PROVIDER_INFO_3 = createProviderInfoWithData(VALID_PROVIDER_NAME_3, []) 
     
    119121VALID_PROVIDER_INFOS = [PROVIDER_INFO_1, PROVIDER_INFO_2, PROVIDER_INFO_3] 
    120122VALID_PIC_FILENAME = "providerInfoCollection.xml" 
    121 VALID_HARVEST_DIR = "/tmp/harvest_me_now/" 
     123VALID_HARVEST_DIR = "tmp_harvest_dir" 
    122124PROVIDER_INFO_COLLECTION = createProviderInfoCollectionWithData(VALID_PIC_FILENAME, 
    123125                                                                VALID_HARVEST_DIR,  
     
    131133INVALID_USER = User('frida', []) 
    132134 
    133 VALID_HARVEST_DIR = 'tmp/' 
     135#VALID_HARVEST_DIR = 'tmp' 
Note: See TracChangeset for help on using the changeset viewer.