Changeset 237 for trunk/grails-app/controllers
- Timestamp:
- Dec 22, 2009, 1:26:58 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/AppCoreController.groovy
r216 r237 1 1 import org.codehaus.groovy.grails.plugins.springsecurity.Secured 2 2 3 /** 4 * Controller class for the application core views. 5 */ 3 6 class AppCoreController extends BaseController { 4 7 5 8 def personService 6 9 def createDataService 10 def appConfigService 7 11 8 12 def index = { redirect(action:start,params:params) } … … 25 29 } 26 30 31 /** 32 * Render the start view. 33 */ 27 34 def start = { 28 35 } 29 36 37 /** 38 * Allow a person to change their session timeout setting. 39 */ 30 40 def changeSessionTimeout = { 31 41 if (request.method == 'GET') { … … 48 58 } 49 59 60 /** 61 * Allow a person to change their password. 62 */ 50 63 def changePassword = { 51 64 //def principal = authenticateService.principal() … … 83 96 } 84 97 98 /** 99 * Render the manager view for manager or admin roles. 100 */ 85 101 @Secured(['ROLE_Manager','ROLE_AppAdmin']) 86 102 def manager = { 87 103 } 88 104 105 /** 106 * Render the appAdmin view for admin roles. 107 */ 89 108 @Secured(['ROLE_AppAdmin']) 90 109 def appAdmin = { 110 111 def offerBaseDataCreation = false 112 def offerDemoDataCreation = false 113 def baseDataCreated = appConfigService.exists("baseDataCreated") 114 def demoDataCreated = appConfigService.exists("demoDataCreated") 115 def demoDataCreationDisabled = appConfigService.exists("demoDataCreationDisabled") 116 117 if(!baseDataCreated) 118 offerBaseDataCreation = true 119 120 if(baseDataCreated && !demoDataCreated && !demoDataCreationDisabled) 121 offerDemoDataCreation = true 122 123 return[baseDataCreated: baseDataCreated, 124 demoDataCreated: demoDataCreated, 125 offerDemoDataCreation: offerDemoDataCreation, 126 offerBaseDataCreation: offerBaseDataCreation, 127 demoDataCreationDisabled: demoDataCreationDisabled] 91 128 } 92 129 130 /** 131 * Allow admin to disable demo data creation. 132 */ 133 @Secured(['ROLE_AppAdmin']) 134 def disableDemoDataCreation = { 135 if(!appConfigService.set("demoDataCreationDisabled")) { 136 flash.message = "Demo data creation could not be disabled." 137 redirect(action: appAdmin) 138 return 139 } 140 141 // Success. 142 flash.message = "Demo data creation disabled." 143 redirect(action: appAdmin) 144 } 145 146 /** 147 * Allow admin to create base data. 148 */ 93 149 @Secured(['ROLE_AppAdmin']) 94 150 def createBaseData = { 95 createDataService.createBaseData() 96 redirect(action:appAdmin) 151 if(!createDataService.createBaseData()) { 152 flash.message = "Base data could not be created." 153 redirect(action: appAdmin) 154 return 155 } 156 157 // Success. 158 flash.message = "Base data created." 159 redirect(action: appAdmin) 97 160 } 98 161 162 /** 163 * Allow admin to create demo data. 164 */ 99 165 @Secured(['ROLE_AppAdmin']) 100 166 def createDemoData = { 101 createDataService.createDemoData() 102 redirect(action:appAdmin) 167 if(!createDataService.createDemoData()) { 168 flash.message = "Demo data could not be created." 169 redirect(action: appAdmin) 170 return 171 } 172 173 // Success. 174 flash.message = "Demo data created." 175 redirect(action: appAdmin) 103 176 } 104 177 105 } 178 } // end of class.
Note: See TracChangeset
for help on using the changeset viewer.