Ignore:
Timestamp:
27/04/09 17:27:19 (11 years ago)
Author:
cbyrom
Message:

Add delete functionality to front tier of oai editor. Include
message to confirm the data has been completed, as a pop up, when
the operation is done. Update tests and simplify model + dal layer.

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

Legend:

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

    r5232 r5233  
    136136 
    137137         
     138    def deleteProviderInfo(self, providerName): 
     139        ''' 
     140        Delete the provider info for the specified provider name 
     141        @param providerName: name of the provider whose data is to be deleted 
     142        ''' 
     143        logging.debug("Deleting provider info for provider, '%s'" %providerName) 
     144        self._setUpController(providerName = providerName) 
     145 
     146        pi = g.dao.deleteProviderInfo(providerName) 
     147 
     148        session[const.POP_UP_MESSAGE_SESSION_KEY] = "Data for provider with name, %s, successfully deleted" %providerName 
     149        session.save() 
     150 
     151        # now, return to the view page 
     152        h.redirect_to('home') 
     153 
     154         
    138155    def saveProviderInfo(self, providerName): 
    139156        ''' 
     
    141158        @param providerName: name of the provider whose data is to be saved 
    142159        ''' 
    143         logging.debug("Saving provider info") 
     160        logging.debug("Saving provider info for provider, '%s'" %providerName) 
    144161        self._setUpController(providerName = providerName) 
    145162        self.__getInputs() 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/controllers/home.py

    r5226 r5233  
    1616        c.title = EDITOR_HOME_TITLE 
    1717        self._setUpController() 
     18         
     19        if session.get(POP_UP_MESSAGE_SESSION_KEY): 
     20            c.popupMessage = session.get(POP_UP_MESSAGE_SESSION_KEY) 
     21            del session[POP_UP_MESSAGE_SESSION_KEY] 
     22            session.save() 
     23         
    1824        return self._renderTemplate('genshi', 'home') 
    1925 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/controllers/view.py

    r5229 r5233  
    2929        if c.user.isAdmin: 
    3030            c.createLink = h.url_for('createProviderInfo') 
     31            # NB, these links are provider dependent and we can display several 
     32            # provider's data in a page - so finish constructing the links in the 
     33            # templates 
    3134            c.editLink = h.url_for('editProviderInfo', providerName = '') 
    3235            c.deleteLink = h.url_for('deleteProviderInfo', providerName = '') 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/dal/editorfileclient.py

    r5226 r5233  
    208208 
    209209         
    210     def deleteProviderInfo(self, providerInfo): 
     210    def deleteProviderInfo(self, providerName): 
    211211        ''' 
    212212        Delete the input providerInfo from the backend data file 
    213         @param providerInfo: ProviderInfo object to delete 
     213        @param providerName: Name of provider to delete 
    214214        @return True if successful, False otherwise 
    215215        ''' 
     
    217217        self.pic, fileName = self.__getProviderInfoData() 
    218218         
    219         self.pic.removeProviderInfo(providerInfo) 
     219        self.pic.removeProviderInfo(providerName) 
    220220        self.pic = self.__createOrUpdatePICollection(self.pic) 
    221221        logging.info("Delete complete successfully") 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/dal/interfaceeditordbclient.py

    r5226 r5233  
    2929         
    3030        
    31     def deleteProviderInfo(self, providerInfo): 
     31    def deleteProviderInfo(self, providerName): 
    3232        ''' 
    33         Delete the input ProviderInfo data 
    34         @param providerInfo: ProviderInfo object to delete 
     33        Delete the input providerInfo from the backend data file 
     34        @param providerName: Name of provider to delete 
    3535        @return True if successful, False otherwise 
    3636        ''' 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/dal/providerinfodao.py

    r5226 r5233  
    8080 
    8181         
    82     def deleteProviderInfo(self, providerInfo): 
     82    def deleteProviderInfo(self, providerName): 
    8383        ''' 
    84         Delete the input ProviderInfo data 
    85         @param providerInfo: ProviderInfo object to delete 
     84        Delete the input providerInfo from the backend data file 
     85        @param providerName: Name of provider to delete 
    8686        @return True if successful, False otherwise 
    8787        ''' 
    88         return self.client.deleteProviderInfo(providerInfo) 
     88        return self.client.deleteProviderInfo(providerName) 
    8989         
    9090         
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/lib/constants.py

    r5229 r5233  
    1919CHECKBOX_SUFFIX = "checked" 
    2020 
     21# key to use in session when displaying text via a javascript pop up 
     22POP_UP_MESSAGE_SESSION_KEY = "popUpSessionKey" 
     23 
    2124# name to use in hidden field for storing record ID 
    2225MAIN_ID_FLAG = "main_id" 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/model/providerinfocollection.py

    r5232 r5233  
    160160     
    161161     
    162     def removeProviderInfo(self, providerInfo): 
     162    def removeProviderInfo(self, providerName): 
    163163        ''' 
    164164        Remove a change request from the collection 
    165         @param providerInfo: a ProviderInfo to remove from the collection 
    166         ''' 
    167         logging.debug("Removing provider info record, '%s', from collection" %providerInfo) 
     165        @param providerName: Name of provider to delete 
     166        ''' 
     167        logging.debug("Removing provider '%s' from collection" %providerName) 
    168168 
    169169        pis = [] 
    170170        for pi in self.providerInfos: 
    171171            # NB, just skip the pi to be removed 
    172             if pi.name == providerInfo.name: 
     172            if pi.name == providerName: 
    173173                logging.debug("- removing existing provider info") 
    174174            else: 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/templates/home.html

    r5226 r5233  
    77        <title py:content="c.title">title</title> 
    88        <?python import oai_info_editor.lib.constants as constants        ?> 
     9            <script py:if="c.popupMessage" type="text/javascript"> 
     10                        window.onload = alert('$c.popupMessage'); 
     11                        <?python del c.popupMessage ?> 
     12                </script> 
    913    </head> 
    1014  <body> 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/templates/view_provider_infos.html

    r5226 r5233  
    77        <head> 
    88        <title py:content="c.title">title</title> 
    9             <script py:if="c.popupMessage" type="text/javascript"> 
    10                         window.onload = alert('$c.popupMessage'); 
    11                         <?python del c.popupMessage ?> 
    12                 </script> 
    139    </head> 
    1410  <body> 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/tests/dal/testeditorfileclient.py

    r5232 r5233  
    122122        self.assertEquals(1, len(self.client.pic.providerInfos)) 
    123123        self.assertEquals('1', self.client.pic.version) 
    124         self.client.deleteProviderInfo(pi) 
     124        self.client.deleteProviderInfo(pi.name) 
    125125        self.files.append(self.client.pic.backupFile) 
    126126        self.assertEquals(0, len(self.client.pic.providerInfos)) 
Note: See TracChangeset for help on using the changeset viewer.