Changeset 268 for trunk/grails-app/controllers/SectionController.groovy
- Timestamp:
- Jan 14, 2010, 10:51:03 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/SectionController.groovy
r267 r268 1 1 import org.codehaus.groovy.grails.plugins.springsecurity.Secured 2 2 3 class S ystemSectionController extends BaseAppAdminController {3 class SectionController extends BaseAppAdminController { 4 4 5 5 def index = { redirect(action:list,params:params) } … … 10 10 def list = { 11 11 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) 12 [ s ystemSectionInstanceList: SystemSection.list( params ), systemSectionInstanceTotal: SystemSection.count() ]12 [ sectionInstanceList: Section.list( params ), sectionInstanceTotal: Section.count() ] 13 13 } 14 14 15 15 def show = { 16 def s ystemSectionInstance = SystemSection.get( params.id )16 def sectionInstance = Section.get( params.id ) 17 17 18 if(!s ystemSectionInstance) {19 flash.message = "S ystemSection not found with id ${params.id}"18 if(!sectionInstance) { 19 flash.message = "Section not found with id ${params.id}" 20 20 redirect(action:list) 21 21 } 22 else { return [ s ystemSectionInstance : systemSectionInstance ] }22 else { return [ sectionInstance : sectionInstance ] } 23 23 } 24 24 25 25 def delete = { 26 def s ystemSectionInstance = SystemSection.get( params.id )27 if(s ystemSectionInstance) {26 def sectionInstance = Section.get( params.id ) 27 if(sectionInstance) { 28 28 try { 29 s ystemSectionInstance.delete(flush:true)30 flash.message = "S ystemSection ${params.id} deleted"29 sectionInstance.delete(flush:true) 30 flash.message = "Section ${params.id} deleted" 31 31 redirect(action:list) 32 32 } 33 33 catch(org.springframework.dao.DataIntegrityViolationException e) { 34 flash.message = "S ystemSection ${params.id} could not be deleted"34 flash.message = "Section ${params.id} could not be deleted" 35 35 redirect(action:show,id:params.id) 36 36 } 37 37 } 38 38 else { 39 flash.message = "S ystemSection not found with id ${params.id}"39 flash.message = "Section not found with id ${params.id}" 40 40 redirect(action:list) 41 41 } … … 43 43 44 44 def edit = { 45 def s ystemSectionInstance = SystemSection.get( params.id )45 def sectionInstance = Section.get( params.id ) 46 46 47 if(!s ystemSectionInstance) {48 flash.message = "S ystemSection not found with id ${params.id}"47 if(!sectionInstance) { 48 flash.message = "Section not found with id ${params.id}" 49 49 redirect(action:list) 50 50 } 51 51 else { 52 return [ s ystemSectionInstance : systemSectionInstance ]52 return [ sectionInstance : sectionInstance ] 53 53 } 54 54 } 55 55 56 56 def update = { 57 def s ystemSectionInstance = SystemSection.get( params.id )58 if(s ystemSectionInstance) {57 def sectionInstance = Section.get( params.id ) 58 if(sectionInstance) { 59 59 if(params.version) { 60 60 def version = params.version.toLong() 61 if(s ystemSectionInstance.version > version) {61 if(sectionInstance.version > version) { 62 62 63 s ystemSectionInstance.errors.rejectValue("version", "systemSection.optimistic.locking.failure", "Another user has updated this SystemSection while you were editing.")64 render(view:'edit',model:[s ystemSectionInstance:systemSectionInstance])63 sectionInstance.errors.rejectValue("version", "section.optimistic.locking.failure", "Another user has updated this Section while you were editing.") 64 render(view:'edit',model:[sectionInstance:sectionInstance]) 65 65 return 66 66 } 67 67 } 68 s ystemSectionInstance.properties = params69 if(!s ystemSectionInstance.hasErrors() && systemSectionInstance.save(flush: true)) {70 flash.message = "S ystemSection ${params.id} updated"71 redirect(action:show,id:s ystemSectionInstance.id)68 sectionInstance.properties = params 69 if(!sectionInstance.hasErrors() && sectionInstance.save(flush: true)) { 70 flash.message = "Section ${params.id} updated" 71 redirect(action:show,id:sectionInstance.id) 72 72 } 73 73 else { 74 render(view:'edit',model:[s ystemSectionInstance:systemSectionInstance])74 render(view:'edit',model:[sectionInstance:sectionInstance]) 75 75 } 76 76 } 77 77 else { 78 flash.message = "S ystemSection not found with id ${params.id}"78 flash.message = "Section not found with id ${params.id}" 79 79 redirect(action:list) 80 80 } … … 82 82 83 83 def create = { 84 def s ystemSectionInstance = new SystemSection()85 s ystemSectionInstance.properties = params86 return ['s ystemSectionInstance':systemSectionInstance]84 def sectionInstance = new Section() 85 sectionInstance.properties = params 86 return ['sectionInstance':sectionInstance] 87 87 } 88 88 89 89 def save = { 90 def s ystemSectionInstance = new SystemSection(params)91 if(!s ystemSectionInstance.hasErrors() && systemSectionInstance.save(flush: true)) {92 flash.message = "S ystemSection ${systemSectionInstance.id} created"93 redirect(action:show,id:s ystemSectionInstance.id)90 def sectionInstance = new Section(params) 91 if(!sectionInstance.hasErrors() && sectionInstance.save(flush: true)) { 92 flash.message = "Section ${sectionInstance.id} created" 93 redirect(action:show,id:sectionInstance.id) 94 94 } 95 95 else { 96 render(view:'create',model:[s ystemSectionInstance:systemSectionInstance])96 render(view:'create',model:[sectionInstance:sectionInstance]) 97 97 } 98 98 }
Note: See TracChangeset
for help on using the changeset viewer.