Ignore:
Timestamp:
Nov 17, 2010, 4:20:33 PM (10 years ago)
Author:
robert@…
Message:

Improved the template editor so that template fields can be removed from templates, even if the templates are in use, but only if the template fields are never filled. (see ticket #74)

Also changed the user registration so that the administrator confirmation mails will be sent to the administrators in production environment, but still to gscfproject@… in other environments.

Location:
trunk/grails-app/controllers/dbnp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/authentication/UserRegistrationController.groovy

    r1147 r1159  
    1515package dbnp.authentication
    1616import grails.plugins.springsecurity.Secured
     17import org.codehaus.groovy.grails.commons.GrailsApplication
     18import grails.util.GrailsUtil
    1719
    1820class UserRegistrationController {
     
    125127        def adminLink = createLink( controller: 'userRegistration', action: 'confirmAdmin', params: [code: adminCode.token], absolute: true )
    126128
     129                // If we are in production, send the mails to all administrators
     130                // Otherwise, send it to a default (spam) mail address
     131                def adminMail = "gscfproject@gmail.com";
     132                if ( GrailsUtil.getEnvironment().equals(GrailsApplication.ENV_PRODUCTION) ) {
     133                        def administrators = SecRole.findUsers( 'ROLE_ADMIN' );
     134                        if( administrators.size() > 0 ) {
     135                                adminMail = administrators.email.toArray();
     136                        }
     137                }
     138
    127139        // Send an email to the administrators
    128140        try {
    129141                        // Determine administrator email addresses
    130142            sendMail {
    131                 to      "gscfproject@gmail.com"
     143                to      adminMail
    132144                subject "New user (" + user.username + ") at GSCF"
    133145                html    g.render(template:"/email/registrationConfirmationAdmin", model:[username: user.username, email: user.email, link: adminLink])
  • trunk/grails-app/controllers/dbnp/studycapturing/TemplateEditorController.groovy

    r1077 r1159  
    494494                templateField.properties = params
    495495        if (!templateField.hasErrors() && templateField.save(flush: true)) {
    496                         def html = g.render( template: 'elements/available', model: [templateField: templateField, ontologies: Ontology.list(), fieldTypes: TemplateFieldType.list()] );
     496
     497                        // Select the template to use for the HTML output
     498                        def renderTemplate = 'elements/available';
     499                        if( params.renderTemplate == 'selected' ) {
     500                                renderTemplate = 'elements/selected';
     501                        }
     502
     503                        // Selected fields should have a template given
     504                        def template = null;
     505                        if( params.templateId )
     506                                template = Template.findById( params.templateId );
     507                       
     508                        def html = g.render( template: renderTemplate, model: [template: template, templateField: templateField, ontologies: Ontology.list(), fieldTypes: TemplateFieldType.list()] );
    497509                        def output = [ id: templateField.id, html: html ];
    498510                        render output as JSON;
     
    635647
    636648                // If the template is in use, field can not be removed
    637                 if( template.inUse() ) {
    638                         response.status = 500;
    639                         render 'No fields can be removed from templates that are in use.'
     649                if( templateField.isFilledInTemplate(template) ) {
     650                        response.status = 500;
     651                        render 'Fields can not be removed from a template if it has been filled somewhere.'
    640652                        return;
    641653                }
Note: See TracChangeset for help on using the changeset viewer.