- Timestamp:
- Dec 22, 2009, 1:26:58 PM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 3 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. -
trunk/grails-app/services/CreateDataService.groovy
r222 r237 12 12 def taskService 13 13 def dateUtilService 14 def appConfigService 14 15 15 16 /******************************************* … … 41 42 */ 42 43 def createBaseData() { 44 45 if(appConfigService.exists("baseDataCreated")) { 46 log.error "Base data has already been created, will NOT recreate." 47 return false 48 } 49 43 50 log.info "Creating base data..." 51 44 52 // Person and Utils 45 53 createBaseAuthorities() … … 49 57 createBaseSupplierType() 50 58 createBaseManufacturerType() 59 51 60 // Tasks 52 61 createBaseTaskGroups() … … 56 65 createBaseTaskModificationTypes() 57 66 createBaseEntryTypes() 67 58 68 // Inventory 59 69 createBaseInventoryTypes() 60 70 createBaseInventoryMovementTypes() 61 71 createBaseMaintenancePolicies() 72 62 73 // Assets 63 74 createBaseAssetExtenededAttributeTypes() 64 75 76 // Record that data has been created. 77 appConfigService.set("baseDataCreated") 65 78 } 66 79 … … 69 82 */ 70 83 def createDemoData() { 84 85 if(!appConfigService.exists("baseDataCreated")) { 86 log.error "Demo data cannot be created until base data has been created." 87 return false 88 } 89 90 if(appConfigService.exists("demoDataCreated")) { 91 log.error "Demo data has already been created, will NOT recreate." 92 return false 93 } 94 95 if(appConfigService.exists("demoDataCreationDisabled")) { 96 log.error "Demo data creation has been disabled, will NOT create." 97 return false 98 } 99 71 100 log.info "Creating demo data..." 101 72 102 // Person and Utils 73 103 createDemoPersons() … … 76 106 createDemoSuppliers() 77 107 createDemoManufacturers() 108 78 109 // Tasks 79 110 createDemoTasks() … … 81 112 createDemoAssignedPersons() 82 113 createDemoTaskRecurringSchedules() 114 83 115 // Inventory 84 116 createDemoInventoryStores() /// @todo: Perhaps a 'createQuickStartData' method? … … 86 118 createDemoInventoryGroups() /// @todo: Perhaps a 'createQuickStartData' method? 87 119 createDemoInventoryItems() 120 88 121 // Assets 89 122 createDemoLifePlan() … … 97 130 createDemoAssets() 98 131 createDemoAssetExtenedAttributes() 132 133 // Record that data has been created. 134 appConfigService.set("demoDataCreated") 99 135 } 100 136 -
trunk/grails-app/views/appCore/appAdmin.gsp
r149 r237 23 23 </td> 24 24 <td valign="top" class="value"> 25 <g:link action="createBaseData">Base</g:link> - Create the base data required for the application to function. 25 26 <g:if test="${offerBaseDataCreation}"> 27 <g:link action="createBaseData">Base</g:link> - Create the base data required for the application to function. 28 </g:if> 29 <g:else> 30 <g:if test="${baseDataCreated}"> 31 Base data has been created. 32 </g:if> 33 </g:else> 34 26 35 <br /> 27 <g:link action="createDemoData">Demo</g:link> - Create demo data for some example sites. 36 37 <g:if test="${demoDataCreationDisabled}"> 38 Demo data creation has been disabled. 39 </g:if> 40 <g:else> 41 <g:if test="${offerDemoDataCreation}"> 42 <g:link action="createDemoData">Demo</g:link> - Create demo data for some example sites. 43 <br /> 44 <g:link action="disableDemoDataCreation">Disable</g:link> - Disable demo data creation. 45 </g:if> 46 <g:else> 47 <g:if test="${demoDataCreated}"> 48 Demo data has been created. 49 </g:if> 50 </g:else> 51 </g:else> 52 28 53 </td> 29 54 </tr>
Note: See TracChangeset
for help on using the changeset viewer.