Changeset 26 for trunk/grails-app
- Timestamp:
- Apr 5, 2011, 12:10:29 PM (11 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BaseFilters.groovy
r25 r26 95 95 // If a user is already logged in, let him continue 96 96 if( session.user && session.user != null ) { 97 // If we don't refresh the user object, an old hiber ante session could still be attached to the object97 // If we don't refresh the user object, an old hibernate session could still be attached to the object 98 98 // raising errors later on (Lazy loading errors) 99 session.user.refresh(); 100 101 return true; 99 try { 100 session.user.refresh(); 101 return true; 102 } catch( Exception ex ) { 103 // If an exception occurs, the user is not correctly refreshed. Send the user back to gscf 104 session.user = null; 105 log.info( "User refresh failed" ); 106 } 102 107 } 103 108 -
trunk/grails-app/controllers/nl/tno/metagenomics/RunController.groovy
r24 r26 12 12 13 13 def index = { 14 [runs: Run.list() ]14 [runs: Run.list(), user: session.user] 15 15 } 16 16 … … 129 129 130 130 // Don't remove runs for which data exists 131 if( run. sequenceData?.size() ) {132 flash.message = "Run could not be deleted because samples are associated with it.";131 if( run.assaySamples*.sequenceData.flatten().size() ) { 132 flash.message = "Run could not be deleted because samples with data are associated with it."; 133 133 redirect( controller: "assay", action: "show", id: params.assayId ) 134 134 } … … 147 147 148 148 // Remove all associations 149 run.assays.each { 149 def a = [] + run.assays 150 a.each { 150 151 run.removeFromAssays( it ); 151 152 } … … 156 157 157 158 redirect( controller: "assay", action: "show", id: params.assayId ) 159 } 160 161 def deleteRun = { 162 Run run = getRun( params.id ); 163 164 if( !run ) { 165 redirect(controller: 'run', action: 'index') 166 return 167 } 168 169 // Don't remove runs for which data exists 170 if( run.assaySamples*.sequenceData.flatten().size() ) { 171 flash.message = "Run could not be deleted because samples with data are associated with it."; 172 redirect(controller: 'run', action: 'index') 173 } 174 175 // Check whether the user has sufficient privileges to remove the run from all assays 176 def hasPrivileges = true; 177 run.assays.each { 178 if( !it.study.canWrite( session.user ) ) 179 hasPrivileges = false 180 } 181 182 if( !hasPrivileges ) { 183 flash.message = "Run could not be deleted because you don't have sufficient privileges to remove the run from all assays."; 184 redirect(controller: 'run', action: 'index') 185 } 186 187 // Remove all associations 188 def a = [] + run.assays 189 a.each { 190 run.removeFromAssays( it ); 191 } 192 193 def name = run.name 194 run.delete(); 195 flash.message = "Run " + name + " has been deleted from the system." 196 197 redirect(controller: 'run', action: 'index') 158 198 } 159 199 -
trunk/grails-app/domain/nl/tno/metagenomics/Run.groovy
r9 r26 1 1 package nl.tno.metagenomics 2 2 3 import nl.tno.metagenomics.auth.User 3 4 import org.codehaus.groovy.grails.commons.ConfigurationHolder 4 5 … … 112 113 return list.unique().toList(); 113 114 } 115 116 /** 117 * Returns true if this run can be deleted 118 * 119 * @return 120 */ 121 public boolean deletable( User u ) { 122 // Don't remove runs for which data exists 123 if( this.assaySamples*.sequenceData.flatten().size() ) { 124 return false; 125 } 126 127 // Check whether the user has sufficient privileges to remove the run from all assays 128 def hasPrivileges = true; 129 assays.each { 130 if( !it.study.canWrite( u ) ) 131 hasPrivileges = false 132 } 133 134 return hasPrivileges 135 } 114 136 } -
trunk/grails-app/views/assay/index.gsp
r14 r26 22 22 <th># samples</th> 23 23 <th>avg sequences / sample</th> 24 <th class="nonsortable"></th> 24 25 </tr> 25 26 </thead> … … 42 43 </g:else> 43 44 </td> 45 <td><g:link controller="assay" action="show" id="${assay.id}"><img src="${fam.icon( name: 'application_form_magnify' )}" alt="view" title="view" /></g:link></td> 46 44 47 </tr> 45 48 </g:each> -
trunk/grails-app/views/run/index.gsp
r25 r26 29 29 <thead> 30 30 <tr> 31 <th class="nonsortable"><input type="checkbox" id="checkAll" onClick="checkAllPaginated(this);" /></th> 32 <th>Run</th> 33 <th># samples</th> 34 <th># sequences</th> 31 <th width="5" class="nonsortable"><input type="checkbox" id="checkAll" onClick="checkAllPaginated(this);" /></th> 32 <th width="49%" >Run</th> 33 <th width="15%"># samples</th> 34 <th width="15%"># sequences</th> 35 <th width="5" class="nonsortable"></th> 36 <th width="5" class="nonsortable"></th> 35 37 </tr> 36 38 </thead> … … 42 44 <td>${run.assaySamples?.size()}</td> 43 45 <td>${run.numSequences()}</td> 46 <td><g:link controller="run" action="show" id="${run.id}"><img src="${fam.icon( name: 'application_form_magnify' )}" alt="view" title="view" /></g:link></td> 47 <td> 48 <g:if test="${run.deletable(user)}"> 49 <g:link controller="run" action="deleteRun" id="${run.id}"><img src="${fam.icon( name: 'delete' )}" alt="delete" title="delete" /></g:link> 50 </g:if> 51 <g:else> 52 <img src="${fam.icon( name: 'delete' )}" class="disabled" alt="Run can not be deleted because data is associated with it." title="Run can not be deleted because data is associated with it." /> 53 </g:else> 54 </td> 44 55 </tr> 45 56 </g:each>
Note: See TracChangeset
for help on using the changeset viewer.