Ignore:
Timestamp:
Feb 16, 2010, 10:02:34 AM (15 years ago)
Author:
gav
Message:

Configure cascade deletion of Site -> Section -> Asset -> SubItems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/SiteDetailedController.groovy

    r298 r360  
    33@Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_AssetManager'])
    44class SiteDetailedController extends BaseController {
     5
     6    def siteService
    57
    68    // the delete, save and update actions only accept POST requests
     
    2931    @Secured(['ROLE_AppAdmin'])
    3032    def delete = {
    31         def siteInstance = Site.get( params.id )
    32         if(siteInstance) {
    33             try {
    34                 siteInstance.delete(flush:true)
    35                 flash.message = "Site ${params.id} deleted"
    36                 redirect(action:list)
    37             }
    38             catch(org.springframework.dao.DataIntegrityViolationException e) {
    39                 flash.message = "Site ${params.id} could not be deleted"
    40                 redirect(action:show,id:params.id)
    41             }
     33        def result = siteService.delete(params)
     34
     35        if(!result.error) {
     36            flash.message = g.message(code: "default.delete.success", args: ["Site", params.id])
     37            redirect(action:list)
     38            return
    4239        }
    43         else {
    44             flash.message = "Site not found with id ${params.id}"
     40
     41        flash.errorMessage = g.message(code: result.error.code, args: result.error.args)
     42
     43        if(result.error.code == "default.not.found") {
    4544            redirect(action:list)
     45            return
    4646        }
     47
     48        redirect(action:show, id: params.id)
    4749    }
    4850
Note: See TracChangeset for help on using the changeset viewer.