Changeset 1658 for trunk/grails-app


Ignore:
Timestamp:
Mar 22, 2011, 4:33:49 PM (10 years ago)
Author:
t.w.abma@…
Message:
  • importer wizard webtest working
  • native file input HTML element didn't work inside AjaxFlow, so used hidden importfile variable
  • added check for development or test environment in configuration file
  • added webtestfiles folder to web-apps containing Excel files to test
Location:
trunk/grails-app
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/conf/Config.groovy

    r1651 r1658  
    133133// Otherwise, it should be given as an absolute path (e.g. '/home/user/sequences')
    134134// The directory should be writable by the webserver user
    135 uploads.uploadDir = (new File("/tmp")?.canWrite()) ? "/tmp" : "fileuploads"
     135if (GrailsUtil.Environment.current == Environment.TEST) {
     136    uploads.uploadDir = "webtestfiles"
     137} else
     138if (GrailsUtil.Environment.current == Environment.DEVELOPMENT) {
     139    uploads.uploadDir = (new File("/tmp")?.canWrite()) ? "/tmp" : "fileuploads"   
     140}
  • trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy

    r1656 r1658  
    66import org.codehaus.groovy.grails.plugins.web.taglib.ValidationTagLib
    77import grails.plugins.springsecurity.Secured
     8import org.codehaus.groovy.grails.commons.ConfigurationHolder
     9import grails.util.GrailsUtil
     10
    811
    912/**
     
    123126                                // that string
    124127                                flash.importer_params.importfile = params.importfile.replace('existing*', '')
    125                 flash.importer_params.importfile = new XmlSlurper().parseText(flash.importer_params.importfile[flash.importer_params.importfile.indexOf('<pre')..-1]).toString()
     128                //flash.importer_params.importfile = new XmlSlurper().parseText(flash.importer_params.importfile[flash.importer_params.importfile.indexOf('<pre')..-1]).toString()
    126129
    127130                                success()
     
    130133                        on("next") {
    131134                                flash.wizardErrors = [:]
     135
    132136                                flash.importer_params = params
    133                                 flash.importer_params.importfile = params.importfile.replace('existing*', '')
    134                 flash.importer_params.importfile = new XmlSlurper().parseText(flash.importer_params.importfile[flash.importer_params.importfile.indexOf('<pre')..-1]).toString()
     137                                flash.importer_params.importfile = params.importfile.replace('existing*', '')               
     138                //flash.importer_params.importfile = new XmlSlurper().parseText(flash.importer_params.importfile[flash.importer_params.importfile.indexOf('<pre')..-1]).toString()
    135139
    136140                                if (params.entity) {
     
    266270
    267271                                // Always delete the uploaded file in the save step to be sure it doesn't reside there anymore
    268                                 fileService.delete(flow.importer_importedfile)
     272                                if (GrailsUtil.environment != "test") fileService.delete(flow.importer_importedfile)
    269273
    270274                                // Save all entities
     
    340344         * @returns boolean true if correctly validated, otherwise false
    341345         */
    342         boolean fileImportPage(flow, flash, params) {
     346        boolean fileImportPage(flow, flash, params) {       
    343347                def importedfile = fileService.get(params['importfile'])
    344348                flow.importer_importedfile = params['importfile']
    345 
    346                 if (importedfile.exists()) {
     349       
     350        if (importedfile.exists()) {
    347351                        try {
    348352                                session.importer_workbook = importerService.getWorkbook(new FileInputStream(importedfile))
  • trunk/grails-app/views/importer/pages/_page_one.gsp

    r1536 r1658  
    2222                Choose your Excel file to import:
    2323            </td>
    24             <td width="100px">
    25                 <af:fileFieldElement name="importfile" value="${importer_params?.importfile}"/>
     24            <td width="100px">         
     25        <g:if env="test">
     26          <input type="hidden" name="importfile" value="NTC_Experiment_test4.xls"/>
     27        </g:if>
     28        <g:elseif env="development">
     29          <af:fileFieldElement name="importfile" value="${importer_params?.importfile}"/>
     30        </g:elseif>
     31
    2632            </td>
    2733        </tr>
Note: See TracChangeset for help on using the changeset viewer.