Changeset 4697 for MILK


Ignore:
Timestamp:
22/12/08 12:18:38 (11 years ago)
Author:
cbyrom
Message:

Add delete function to atom editor to delete granule atoms - together
with warning messages beforehand and result pop up messages afterwards.
Adjust granulite to expose the delete functions publicly.

Location:
MILK/trunk/milk_server/milk_server
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • MILK/trunk/milk_server/milk_server/config/routing.py

    r4596 r4697  
    2121    # atom editor specific routing 
    2222    map.connect('upload/:uri', controller = 'atom_editor/editatom', action='upload', uri = None) 
     23    map.connect('deleteAtom/:uri', controller = 'atom_editor/editatom', action='delete') 
    2324    map.connect('editAtom/:uri', controller = 'atom_editor/editatom', action='edit') 
    2425    map.connect('saveAtom/:uri/:saveLevel', controller = 'atom_editor/editatom', \ 
  • MILK/trunk/milk_server/milk_server/controllers/atom_editor/editatom.py

    r4679 r4697  
    218218                        c.atom = None 
    219219                        uri = None 
    220                      
    221220                             
    222221                # now do redirection - NB, this ensures that current atom contents are 
     
    421420        self.addRelatedLinksDropDowns() 
    422421 
     422 
     423    def delete(self, uri): 
     424        ''' 
     425        Delete the atom associated with the specified uri - and return 
     426        user to the atom home page.  NB, only granule atoms can be deleted 
     427        at the moment. 
     428        ''' 
     429        if uri: 
     430            try: 
     431                logging.info("Deleting atom, '%s'" %uri) 
     432                self.prepareDataModel(uri) 
     433                eXistClient = self.__getExistClient('local') 
     434                gran = granulite(None, granuleAtom = c.atom, \ 
     435                                 eXistClient = eXistClient, \ 
     436                                 deleteMode = True) 
     437     
     438                gran.deleteGranuleAndDEReferences() 
     439                raise Exception('blah') 
     440                c.deleteResult = "Atom deleted successfully." 
     441                logging.info("- atom deleted") 
     442            except Exception, e: 
     443                logging.error("Problem occured whilst deleting atom: '%s'" %e.message) 
     444                c.deleteResult = "Warning: a problem occured whilst deleting the atom - this " + \ 
     445                    "may have left the system in an unstable state - please check if the atom, or " + \ 
     446                    "references to the atom still exist" 
     447 
     448        return render("genshi", "atom_editor/atom_home") 
     449         
    423450     
    424451    def edit(self, uri): 
     
    682709            logging.info("Validating input") 
    683710            try: 
    684                 inputs = request.params 
     711                inputs = self.__getTidyInputs() 
    685712                validator = CreateAtomFormSchema() 
    686713                validator.to_python(inputs) 
     
    718745 
    719746        try: 
    720             return savePageAndRender(self.pathInfo, 'atom_editor/atom_creator') 
     747            return savePageAndRender(self.pathInfo, 'atom_editor/atom_creator', **inputs) 
    721748 
    722749        except Exception, e: 
  • MILK/trunk/milk_server/milk_server/templates/atom_editor/atom_editor.html

    r4604 r4697  
    1414                        </script> 
    1515                </span> 
     16        <script py:if="c.atom.isGranule()" type="text/javascript"> 
     17function confirmGranuleDelete()  
     18{ 
     19        var r=confirm('Do you really want to delete this granule - and all references to it in data entities?'); 
     20        if (r==true) 
     21        { 
     22                Div_show("loading"); 
     23                return true;   
     24        } 
     25        return false; 
     26} 
     27                </script> 
    1628        <span py:if="c.atom.isDeployable() or c.atom.isGranule()"  py:strip=""> 
    1729                <script type="text/javascript"> 
     
    4355                                ${Markup(h.form(h.url_for(controller='atom_editor/editatom', action='edit', uri=c.atom.ndgURI)))} 
    4456                                        <input py:if="not c.saveLink" name="Edit" type="submit" value="Edit" /> 
     57                                ${Markup(h.end_form())} 
     58                                ${Markup(h.form(h.url_for(controller='atom_editor/editatom', action='delete', uri=c.atom.ndgURI)))} 
     59                                        <input py:if="c.atom.isGranule()" name="Delete" type="submit" value="Delete" onclick="return confirmGranuleDelete()" /> 
    4560                                ${Markup(h.end_form())} 
    4661                        <div py:replace="displayErrors()"/> 
  • MILK/trunk/milk_server/milk_server/templates/atom_editor/atom_home.html

    r4498 r4697  
    77        <head> 
    88        <title py:content="c.title">title</title> 
     9            <script py:if="c.deleteResult" type="text/javascript"> 
     10             
     11                        window.onload = alert('$c.deleteResult'); 
     12                        <?python del c.deleteResult ?> 
     13                </script> 
    914    </head> 
    1015  <body class="submit"> 
Note: See TracChangeset for help on using the changeset viewer.