Changeset 69 for branches


Ignore:
Timestamp:
Mar 9, 2009, 10:31:40 AM (16 years ago)
Author:
gav
Message:

Add TaskPriority? and TaskType? domains, generate views and controllers.
Tweak security extensively.
Use 'extend BaseController?' to pass ROLE_USER to most controllers.
Add parentTask and subTask to Task Domain.

Location:
branches/TaskRewrite/src/grails-app
Files:
15 added
16 edited

Legend:

Unmodified
Added
Removed
  • branches/TaskRewrite/src/grails-app/conf/BootStrap.groovy

    r66 r69  
    121121        personInstance.addToPersonGroups(PersonGroup.findByName("Production"))
    122122
    123         //TaskStatus
    124         def taskStatusInstance
    125    
    126         taskStatusInstance = new TaskStatus(name:"Not Started")
    127         BootStrapSaveAndTest(taskStatusInstance)
    128 
    129         taskStatusInstance = new TaskStatus(name:"In Progress")
    130         BootStrapSaveAndTest(taskStatusInstance)
    131 
    132         taskStatusInstance = new TaskStatus(name:"Completed")
    133         BootStrapSaveAndTest(taskStatusInstance)
    134 
    135123        //TaskGroup
    136124        def taskGroupInstance
     
    144132        BootStrapSaveAndTest(taskGroupInstance)
    145133
    146         taskGroupInstance = new TaskGroup(name:"NewProject(s)",
     134        taskGroupInstance = new TaskGroup(name:"New Projects",
    147135                      description:" ")
    148136        BootStrapSaveAndTest(taskGroupInstance)
    149137
     138        //TaskStatus
     139        def taskStatusInstance
     140   
     141        taskStatusInstance = new TaskStatus(name:"Not Started")
     142        BootStrapSaveAndTest(taskStatusInstance)
     143
     144        taskStatusInstance = new TaskStatus(name:"In Progress")
     145        BootStrapSaveAndTest(taskStatusInstance)
     146
     147        taskStatusInstance = new TaskStatus(name:"Completed")
     148        BootStrapSaveAndTest(taskStatusInstance)
     149
     150        //TaskPriority
     151        def taskPriorityInstance
     152
     153        taskPriorityInstance = new TaskPriority(name:"Low")
     154        BootStrapSaveAndTest(taskPriorityInstance)
     155
     156        taskPriorityInstance = new TaskPriority(name:"Normal")
     157        BootStrapSaveAndTest(taskPriorityInstance)
     158
     159        taskPriorityInstance = new TaskPriority(name:"High")
     160        BootStrapSaveAndTest(taskPriorityInstance)
     161
     162        taskPriorityInstance = new TaskPriority(name:"Immediate")
     163        BootStrapSaveAndTest(taskPriorityInstance)
     164
     165        //TaskType
     166        def taskTypeInstance
     167
     168        taskTypeInstance = new TaskType(name:"Unscheduled Breakin")
     169        BootStrapSaveAndTest(taskTypeInstance)
     170
     171        taskTypeInstance = new TaskType(name:"Planned Maintenance")
     172        BootStrapSaveAndTest(taskTypeInstance)
     173
     174        taskTypeInstance = new TaskType(name:"Project")
     175        BootStrapSaveAndTest(taskTypeInstance)
     176
     177        taskTypeInstance = new TaskType(name:"Turnaround")
     178        BootStrapSaveAndTest(taskTypeInstance)
     179
     180        taskTypeInstance = new TaskType(name:"Production Run")
     181        BootStrapSaveAndTest(taskTypeInstance)
     182
    150183        //Task
    151184        def taskInstance
     185        def subTaskInstance
    152186
    153187        taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),
    154188                 taskStatus:TaskStatus.findByName("Not Started"),
     189                 taskPriority:TaskPriority.get(2),
     190                 taskType:TaskType.get(1),
    155191                 leadPerson:Person.get(3),
    156192                 description:"Check specific level sensor",
     
    160196        taskInstance.addToAssignedPersons(Person.get(2))
    161197
     198        subTaskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),
     199                 taskStatus:TaskStatus.findByName("Not Started"),
     200                 taskPriority:TaskPriority.get(2),
     201                 taskType:TaskType.get(1),
     202                 leadPerson:Person.get(3),
     203                 description:"Some follow up work",
     204                 comment:"Some help required")
     205        BootStrapSaveAndTest(subTaskInstance)
     206        subTaskInstance.addToAssignedPersons(Person.get(1))
     207       
     208        //Add task 2 as a subTask of task 1.
     209        taskInstance.addToSubTasks(Task.get(2))
     210        subTaskInstance.parentTask = Task.get(1)
     211
    162212        taskInstance = new Task(taskGroup:TaskGroup.findByName("Production Activites"),
    163213                 taskStatus:TaskStatus.findByName("Not Started"),
     214                 taskPriority:TaskPriority.get(2),
     215                 taskType:TaskType.get(5),
    164216                 leadPerson:Person.get(5),
    165217                 description:"Production Report",
     
    167219        BootStrapSaveAndTest(taskInstance)
    168220
    169         taskInstance = new Task(taskGroup:TaskGroup.findByName("NewProject(s)"),
    170                  taskStatus:TaskStatus.findByName("Not Started"),
     221        taskInstance = new Task(taskGroup:TaskGroup.findByName("New Projects"),
     222                 taskStatus:TaskStatus.findByName("Not Started"),
     223                 taskPriority:TaskPriority.get(2),
     224                 taskType:TaskType.get(3),
    171225                 leadPerson:Person.get(1),
    172226                 description:"Make killer CMMS app",
     
    183237        BootStrapSaveAndTest(entryTypeInstance)
    184238
    185         entryTypeInstance = new EntryType(name:"Production Report")
     239        entryTypeInstance = new EntryType(name:"Production Note")
    186240        BootStrapSaveAndTest(entryTypeInstance)
    187241
  • branches/TaskRewrite/src/grails-app/conf/SecurityConfig.groovy

    r58 r69  
    1313
    1414    //Required if we want to run "grails generate-manager"
    15     //Which recreates the controller and views, so save the views.
     15    //Which recreates the controller and views, so save the views!
    1616//     requestMapClass = 'Requestmap'
    1717
    1818    useRequestMapDomainClass = false
    1919    useControllerAnnotations = true
     20
     21    //Set true especially if used across the internet.
     22    forceHttps = 'true'
     23
     24    //Pessimistic locking, deny access to all URLs that don't
     25    //have an applicable URL-Role configuration.
     26    //This forces us to set an annotation, static rule or
     27    //extend BaseController and prevents accidentally leaving pages open.
     28    controllerAnnotationsRejectIfNoRule = true
     29   
     30    //Static rules for controllers, actions and urls.
     31    //Since we are using pessimistic locking we have to set some things
     32    //here but most security should be set in the controllers.
     33    controllerAnnotationStaticRules = [
     34    '/': ['IS_AUTHENTICATED_FULLY'],
     35    '/index.gsp': ['IS_AUTHENTICATED_FULLY'],
     36    '/css/*': ['IS_AUTHENTICATED_ANONYMOUSLY'],
     37    '/images/**': ['IS_AUTHENTICATED_ANONYMOUSLY'],
     38    '/login*': ['IS_AUTHENTICATED_ANONYMOUSLY'],
     39    '/login/**': ['IS_AUTHENTICATED_ANONYMOUSLY'],
     40    '/logout*': ['IS_AUTHENTICATED_FULLY'],
     41    '/logout/**': ['IS_AUTHENTICATED_FULLY']
     42    ]
     43
     44    //We always want to go to the home page so that bookmarks are not used.
     45    defaultTargetUrl = '/appCore/home'
     46    alwaysUseDefaultTargetUrl = true
     47
    2048}
  • branches/TaskRewrite/src/grails-app/controllers/AppCoreController.groovy

    r65 r69  
    11import org.codehaus.groovy.grails.plugins.springsecurity.Secured
    22
    3 @Secured(['ROLE_USER'])
    43class AppCoreController extends BaseController {
    54
  • branches/TaskRewrite/src/grails-app/controllers/BaseController.groovy

    r62 r69  
    11import org.codehaus.groovy.grails.plugins.springsecurity.Secured
    22
     3@Secured(['ROLE_USER'])
    34abstract class BaseController {
    45    def whatsit() {
    56    }
     7
    68}
    79
  • branches/TaskRewrite/src/grails-app/controllers/EntryController.groovy

    r66 r69  
    1 class EntryController {
     1import org.codehaus.groovy.grails.plugins.springsecurity.Secured
     2
     3class EntryController extends BaseController {
    24   
    35    def index = { redirect(action:list,params:params) }
  • branches/TaskRewrite/src/grails-app/controllers/EntryTypeController.groovy

    r66 r69  
    1 class EntryTypeController {
     1import org.codehaus.groovy.grails.plugins.springsecurity.Secured
     2
     3class EntryTypeController extends BaseController {
    24   
    35    def index = { redirect(action:list,params:params) }
  • branches/TaskRewrite/src/grails-app/controllers/ModificationController.groovy

    r66 r69  
    1 class ModificationController {
     1import org.codehaus.groovy.grails.plugins.springsecurity.Secured
     2
     3class ModificationController extends BaseController {
    24   
    35    def index = { redirect(action:list,params:params) }
  • branches/TaskRewrite/src/grails-app/controllers/ModificationTypeController.groovy

    r66 r69  
    1 class ModificationTypeController {
     1import org.codehaus.groovy.grails.plugins.springsecurity.Secured
     2
     3class ModificationTypeController extends BaseController {
    24   
    35    def index = { redirect(action:list,params:params) }
  • branches/TaskRewrite/src/grails-app/controllers/TaskController.groovy

    r66 r69  
    1 class TaskController {
     1import org.codehaus.groovy.grails.plugins.springsecurity.Secured
     2
     3class TaskController extends BaseController {
    24   
    35    def index = { redirect(action:list,params:params) }
  • branches/TaskRewrite/src/grails-app/controllers/TaskGroupController.groovy

    r66 r69  
    1 class TaskGroupController {
     1import org.codehaus.groovy.grails.plugins.springsecurity.Secured
     2
     3class TaskGroupController extends BaseController {
    24   
    35    def index = { redirect(action:list,params:params) }
  • branches/TaskRewrite/src/grails-app/controllers/TaskStatusController.groovy

    r66 r69  
    1 class TaskStatusController {
     1import org.codehaus.groovy.grails.plugins.springsecurity.Secured
     2
     3class TaskStatusController extends BaseController {
    24   
    35    def index = { redirect(action:list,params:params) }
  • branches/TaskRewrite/src/grails-app/domain/Task.groovy

    r66 r69  
    22    TaskGroup taskGroup
    33    TaskStatus taskStatus
     4    TaskPriority taskPriority
     5    TaskType taskType
     6    Task    parentTask
    47    Person leadPerson
    58    String description
     
    1114    boolean isActive = true
    1215
    13     static hasMany = [entries: Entry, modifications: Modification, assignedPersons: Person]
     16    static hasMany = [entries: Entry,
     17                        modifications: Modification,
     18                        assignedPersons: Person,
     19                        subTasks: Task]
    1420
    15     static belongsTo = [TaskGroup, TaskStatus, Person]
     21    static belongsTo = [TaskGroup, TaskStatus, Task, Person]
    1622
    1723    static constraints = {
     
    1925        description(blank:false,maxSize:50)
    2026        leadPerson()
     27        taskPriority()
    2128        taskStatus()
     29        parentTask(blank: true, nullable:true)
    2230        comment(maxSize:255)
     31       
    2332    }
    2433
  • branches/TaskRewrite/src/grails-app/views/task/create.gsp

    r66 r69  
    6060                                <td valign="top" class="value ${hasErrors(bean:taskInstance,field:'taskStatus','errors')}">
    6161                                    <g:select optionKey="id" from="${TaskStatus.list()}" name="taskStatus.id" value="${taskInstance?.taskStatus?.id}" ></g:select>
     62                                </td>
     63                            </tr>
     64                       
     65                            <tr class="prop">
     66                                <td valign="top" class="name">
     67                                    <label for="parentTask">Parent Task:</label>
     68                                </td>
     69                                <td valign="top" class="value ${hasErrors(bean:taskInstance,field:'parentTask','errors')}">
     70                                    <g:select optionKey="id" from="${Task.list()}" name="parentTask.id" value="${taskInstance?.parentTask?.id}" noSelection="['null':'']"></g:select>
    6271                                </td>
    6372                            </tr>
  • branches/TaskRewrite/src/grails-app/views/task/edit.gsp

    r66 r69  
    6767                            <tr class="prop">
    6868                                <td valign="top" class="name">
     69                                    <label for="parentTask">Parent Task:</label>
     70                                </td>
     71                                <td valign="top" class="value ${hasErrors(bean:taskInstance,field:'parentTask','errors')}">
     72                                    <g:select optionKey="id" from="${Task.list()}" name="parentTask.id" value="${taskInstance?.parentTask?.id}" noSelection="['null':'']"></g:select>
     73                                </td>
     74                            </tr>
     75                       
     76                            <tr class="prop">
     77                                <td valign="top" class="name">
    6978                                    <label for="comment">Comment:</label>
    7079                                </td>
     
    145154</ul>
    146155<g:link controller="modification" params="['task.id':taskInstance?.id]" action="create">Add Modification</g:link>
     156
     157                                </td>
     158                            </tr>
     159                       
     160                            <tr class="prop">
     161                                <td valign="top" class="name">
     162                                    <label for="subTasks">Sub Tasks:</label>
     163                                </td>
     164                                <td valign="top" class="value ${hasErrors(bean:taskInstance,field:'subTasks','errors')}">
     165                                   
     166<ul>
     167<g:each var="s" in="${taskInstance?.subTasks?}">
     168    <li><g:link controller="task" action="show" id="${s.id}">${s?.encodeAsHTML()}</g:link></li>
     169</g:each>
     170</ul>
     171<g:link controller="task" params="['task.id':taskInstance?.id]" action="create">Add Task</g:link>
    147172
    148173                                </td>
  • branches/TaskRewrite/src/grails-app/views/task/list.gsp

    r66 r69  
    3232                                <th>Task Status</th>
    3333                           
    34                                 <g:sortableColumn property="comment" title="Comment" />
    35                        
     34                                <th>Parent Task</th>
     35                           
    3636                        </tr>
    3737                    </thead>
     
    5050                            <td>${fieldValue(bean:taskInstance, field:'taskStatus')}</td>
    5151                       
    52                             <td>${fieldValue(bean:taskInstance, field:'comment')}</td>
     52                            <td>${fieldValue(bean:taskInstance, field:'parentTask')}</td>
    5353                       
    5454                        </tr>
  • branches/TaskRewrite/src/grails-app/views/task/show.gsp

    r66 r69  
    5555                           
    5656                            <td valign="top" class="value"><g:link controller="taskStatus" action="show" id="${taskInstance?.taskStatus?.id}">${taskInstance?.taskStatus?.encodeAsHTML()}</g:link></td>
     57                           
     58                        </tr>
     59                   
     60                        <tr class="prop">
     61                            <td valign="top" class="name">Parent Task:</td>
     62                           
     63                            <td valign="top" class="value"><g:link controller="task" action="show" id="${taskInstance?.parentTask?.id}">${taskInstance?.parentTask?.encodeAsHTML()}</g:link></td>
    5764                           
    5865                        </tr>
     
    120127                   
    121128                        <tr class="prop">
     129                            <td valign="top" class="name">Sub Tasks:</td>
     130                           
     131                            <td  valign="top" style="text-align:left;" class="value">
     132                                <ul>
     133                                <g:each var="s" in="${taskInstance.subTasks}">
     134                                    <li><g:link controller="task" action="show" id="${s.id}">${s?.encodeAsHTML()}</g:link></li>
     135                                </g:each>
     136                                </ul>
     137                            </td>
     138                           
     139                        </tr>
     140                   
     141                        <tr class="prop">
    122142                            <td valign="top" class="name">Target Completion Date:</td>
    123143                           
Note: See TracChangeset for help on using the changeset viewer.