Ignore:
Timestamp:
Oct 9, 2009, 10:11:43 PM (15 years ago)
Author:
gav
Message:

Add params.message to Person create and edit views.
Code format to 4 spaces, no tabs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/AuthorityController.groovy

    r116 r150  
    33class AuthorityController extends BaseAppAdminController {
    44
    5         // the delete, save and update actions only accept POST requests
    6         static Map allowedMethods = [delete: 'POST', save: 'POST', update: 'POST']
     5    // the delete, save and update actions only accept POST requests
     6    static Map allowedMethods = [delete: 'POST', save: 'POST', update: 'POST']
    77
    8         def authenticateService
     8    def authenticateService
    99
    10         def index = {
    11                 redirect action: list, params: params
    12         }
     10    def index = {
     11        redirect action: list, params: params
     12    }
    1313
    14         /**
    15         * Display the list authority page.
    16         */
    17         def list = {
    18                 if (!params.max) {
    19                         params.max = 10
    20                 }
    21                 [authorityList: Authority.list(params)]
    22         }
     14    /**
     15    * Display the list authority page.
     16    */
     17    def list = {
     18        if (!params.max) {
     19            params.max = 10
     20        }
     21        [authorityList: Authority.list(params)]
     22    }
    2323
    24         /**
    25         * Display the show authority page.
    26         */
    27         def show = {
    28                 def authority = Authority.get(params.id)
    29                 if (!authority) {
    30                         flash.message = "Authority not found with id $params.id"
    31                         redirect action: list
    32                         return
    33                 }
     24    /**
     25    * Display the show authority page.
     26    */
     27    def show = {
     28        def authority = Authority.get(params.id)
     29        if (!authority) {
     30            flash.message = "Authority not found with id $params.id"
     31            redirect action: list
     32            return
     33        }
    3434
    35                 [authority: authority]
    36         }
     35        [authority: authority]
     36    }
    3737
    38         /**
    39         * Delete an authority.
    40         */
    41         def delete = {
    42                 def authority = Authority.get(params.id)
    43                 if (!authority) {
    44                         flash.message = "Authority not found with id $params.id"
    45                         redirect action: list
    46                         return
    47                 }
     38    /**
     39    * Delete an authority.
     40    */
     41    def delete = {
     42        def authority = Authority.get(params.id)
     43        if (!authority) {
     44            flash.message = "Authority not found with id $params.id"
     45            redirect action: list
     46            return
     47        }
    4848
    49                 authenticateService.deleteRole(authority)
     49        authenticateService.deleteRole(authority)
    5050
    51                 flash.message = "Authority $params.id deleted."
    52                 redirect action: list
    53         }
     51        flash.message = "Authority $params.id deleted."
     52        redirect action: list
     53    }
    5454
    55         /**
    56         * Display the edit authority page.
    57         */
    58         def edit = {
    59                 def authority = Authority.get(params.id)
    60                 if (!authority) {
    61                         flash.message = "Authority not found with id $params.id"
    62                         redirect action: list
    63                         return
    64                 }
     55    /**
     56    * Display the edit authority page.
     57    */
     58    def edit = {
     59        def authority = Authority.get(params.id)
     60        if (!authority) {
     61            flash.message = "Authority not found with id $params.id"
     62            redirect action: list
     63            return
     64        }
    6565
    66                 [authority: authority]
    67         }
     66        [authority: authority]
     67    }
    6868
    69         /**
    70         * Authority update action.
    71         */
    72         def update = {
     69    /**
     70    * Authority update action.
     71    */
     72    def update = {
    7373
    74                 def authority = Authority.get(params.id)
    75                 if (!authority) {
    76                         flash.message = "Authority not found with id $params.id"
    77                         redirect action: edit, id: params.id
    78                         return
    79                 }
     74        def authority = Authority.get(params.id)
     75        if (!authority) {
     76            flash.message = "Authority not found with id $params.id"
     77            redirect action: edit, id: params.id
     78            return
     79        }
    8080
    81                 long version = params.version.toLong()
    82                 if (authority.version > version) {
    83                         authority.errors.rejectValue 'version', 'authority.optimistic.locking.failure',
    84                                 'Another user has updated this Authority while you were editing.'
    85                         render view: 'edit', model: [authority: authority]
    86                         return
    87                 }
     81        long version = params.version.toLong()
     82        if (authority.version > version) {
     83            authority.errors.rejectValue 'version', 'authority.optimistic.locking.failure',
     84                'Another user has updated this Authority while you were editing.'
     85            render view: 'edit', model: [authority: authority]
     86            return
     87        }
    8888
    89                 if (authenticateService.updateRole(authority, params)) {
    90                         authenticateService.clearCachedRequestmaps()
    91                         redirect action: show, id: authority.id
    92                 }
    93                 else {
    94                         render view: 'edit', model: [authority: authority]
    95                 }
    96         }
     89        if (authenticateService.updateRole(authority, params)) {
     90            authenticateService.clearCachedRequestmaps()
     91            redirect action: show, id: authority.id
     92        }
     93        else {
     94            render view: 'edit', model: [authority: authority]
     95        }
     96    }
    9797
    98         /**
    99         * Display the create new authority page.
    100         */
    101         def create = {
    102                 [authority: new Authority()]
    103         }
     98    /**
     99    * Display the create new authority page.
     100    */
     101    def create = {
     102        [authority: new Authority()]
     103    }
    104104
    105         /**
    106         * Save a new authority.
    107         */
    108         def save = {
     105    /**
     106    * Save a new authority.
     107    */
     108    def save = {
    109109
    110                 def authority = new Authority()
    111                 authority.properties = params
    112                 if (authority.save()) {
    113                         redirect action: show, id: authority.id
    114                 }
    115                 else {
    116                         render view: 'create', model: [authority: authority]
    117                 }
    118         }
     110        def authority = new Authority()
     111        authority.properties = params
     112        if (authority.save()) {
     113            redirect action: show, id: authority.id
     114        }
     115        else {
     116            render view: 'create', model: [authority: authority]
     117        }
     118    }
    119119}
Note: See TracChangeset for help on using the changeset viewer.