Ignore:
Timestamp:
Apr 4, 2009, 6:41:25 PM (15 years ago)
Author:
gav
Message:

Installed help-balloons plugin.
Adjust security config to allow javascript and help-balloons folders.
Add "Repeat password" to change password.
Detailed Entry views, including only allow user to edit their own entries.
Adjust Entry constraints.
Add comments to layouts/main.gsp.
Work on TaskDetailed? view to show entry durations and allow editing.
Entry duration formatting to CSS and increased base font size to 14px.

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

Legend:

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

    r91 r98  
    2727        if (request.method == 'POST') {
    2828            def personInstance = Person.get(authenticateService.userDomain().id)
    29    
    30             personInstance.pass = params.pass
    31             personInstance.password = authenticateService.encodePassword(personInstance.pass)
    3229
    33             if (!personInstance.hasErrors() && personInstance.save()) {
    34                 //userCache.removeUserFromCache(personInstance.loginName)
    35                 flash.message = "Password changed successfully."
    36                 redirect(action:options)
     30            if(params.repeatPass == params.pass) {
     31                personInstance.pass = params.pass
     32                personInstance.password = authenticateService.encodePassword(personInstance.pass)
     33
     34                if (!personInstance.hasErrors() && personInstance.save()) {
     35                    //userCache.removeUserFromCache(personInstance.loginName)
     36                    flash.message = "Password changed successfully."
     37                    redirect(action:options)
     38                }
     39                else {
     40                    render(view:'changePassword',model:[personInstance:personInstance])
     41                }
    3742            }
    3843            else {
     44                flash.message = "Passwords must match."
     45//                 personInstance.addToErrors("Passwords must match.")
    3946                render(view:'changePassword',model:[personInstance:personInstance])
    40             }                         
     47            }
     48               
    4149        } 
    4250    }
  • trunk/src/grails-app/controllers/EntryDetailedController.groovy

    r91 r98  
    2828        def entryInstance = Entry.get( params.id )
    2929        if(entryInstance) {
    30             entryInstance.delete()
    31             flash.message = "Entry ${params.id} deleted"
    32             redirect(action:list)
     30            if(entryInstance.enteredBy.loginName == authenticateService.userDomain().loginName) {
     31                entryInstance.delete()
     32                flash.message = "Entry ${params.id} deleted"
     33                redirect(action:list)
     34            }
     35            else {
     36                flash.message = "You may only delete your own entries."
     37                redirect(action:show,id:entryInstance.id)
     38            }
     39
    3340        }
    3441        else {
     
    4047    def edit = {
    4148        def entryInstance = Entry.get( params.id )
    42 
    4349        if(!entryInstance) {
    44             flash.message = "Entry not found with id ${params.id}"
    45             redirect(action:list)
     50                flash.message = "Entry not found with id ${params.id}"
     51                redirect(action:list)
    4652        }
    4753        else {
    48             return [ entryInstance : entryInstance ]
     54
     55            if(entryInstance.enteredBy.loginName == authenticateService.userDomain().loginName) {
     56                return [ entryInstance : entryInstance ]
     57            }
     58            else {
     59                flash.message = "You may only edit your own entries."
     60                redirect(action:show,id:entryInstance.id)
     61            }
     62
    4963        }
    5064    }
     
    6983
    7084    def create = {
    71         def entryInstance = new Entry()
    72         entryInstance.properties = params
    73         return ['entryInstance':entryInstance]
     85        try {
     86            def taskInstance = Task.get(params.taskInstance.id)
     87            def entryInstance = new Entry()
     88            entryInstance.task = taskInstance
     89            return ['entryInstance':entryInstance]
     90        }
     91        catch(Exception e) {
     92            flash.message = "Please select a task, then 'Add Entry'"
     93            redirect(controller:"taskDetailed", action:"list")
     94        }
    7495    }
    7596
Note: See TracChangeset for help on using the changeset viewer.