diff --git a/grails-app/controllers/rooms/PersonController.groovy b/grails-app/controllers/rooms/PersonController.groovy index be0d6fa..195bea4 100644 --- a/grails-app/controllers/rooms/PersonController.groovy +++ b/grails-app/controllers/rooms/PersonController.groovy @@ -1,99 +1,13 @@ package rooms -import grails.validation.ValidationException -import static org.springframework.http.HttpStatus.* - class PersonController { - PersonService personService - - static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"] - - def index(Integer max) { - params.max = Math.min(max ?: 10, 100) - respond personService.list(params), model:[personCount: personService.count()] - } - - def show(Long id) { - respond personService.get(id) - } - - def create() { - respond new Person(params) - } + static scaffold = Person // dynamic scaffold - def save(Person person) { - if (person == null) { - notFound() - return - } + def save(Person person) { // static scaffold - keep only the overridden pieces - try { - personService.save(person) - } catch (ValidationException e) { - respond person.errors, view:'create' - return - } - - request.withFormat { - form multipartForm { - flash.message = message(code: 'default.created.message', args: [message(code: 'person.label', default: 'Person'), person.id]) - redirect person - } - '*' { respond person, [status: CREATED] } - } - } + render text: "save Person is no longer allowed via web" - def edit(Long id) { - respond personService.get(id) } - def update(Person person) { - if (person == null) { - notFound() - return - } - - try { - personService.save(person) - } catch (ValidationException e) { - respond person.errors, view:'edit' - return - } - - request.withFormat { - form multipartForm { - flash.message = message(code: 'default.updated.message', args: [message(code: 'person.label', default: 'Person'), person.id]) - redirect person - } - '*'{ respond person, [status: OK] } - } - } - - def delete(Long id) { - if (id == null) { - notFound() - return - } - - personService.delete(id) - - request.withFormat { - form multipartForm { - flash.message = message(code: 'default.deleted.message', args: [message(code: 'person.label', default: 'Person'), id]) - redirect action:"index", method:"GET" - } - '*'{ render status: NO_CONTENT } - } - } - - protected void notFound() { - request.withFormat { - form multipartForm { - flash.message = message(code: 'default.not.found.message', args: [message(code: 'person.label', default: 'Person'), params.id]) - redirect action: "index", method: "GET" - } - '*'{ render status: NOT_FOUND } - } - } } diff --git a/grails-app/views/person/create.gsp b/grails-app/views/person/create.gsp new file mode 100644 index 0000000..1b25f52 --- /dev/null +++ b/grails-app/views/person/create.gsp @@ -0,0 +1,46 @@ + + + + + + <g:message code="default.create.label" args="[entityName]" /> + + +
+
+
+ + +
+
+
+

+ +
${flash.message}
+
+ + + + +
+ +
+
+ +
+
+
+
+
+
+ + diff --git a/grails-app/views/person/edit.gsp b/grails-app/views/person/edit.gsp new file mode 100644 index 0000000..f04d064 --- /dev/null +++ b/grails-app/views/person/edit.gsp @@ -0,0 +1,48 @@ + + + + + + <g:message code="default.edit.label" args="[entityName]" /> + + +
+
+
+ + +
+
+
+

+ +
${flash.message}
+
+ + + + + +
+ +
+
+ +
+
+
+
+
+
+ + diff --git a/grails-app/views/person/index.gsp b/grails-app/views/person/index.gsp new file mode 100644 index 0000000..b56920d --- /dev/null +++ b/grails-app/views/person/index.gsp @@ -0,0 +1,39 @@ + + + + + + <g:message code="default.list.label" args="[entityName]" /> + + +
+
+
+ + +
+
+
+

+ +
${flash.message}
+
+ + + + + + +
+
+
+
+ + diff --git a/grails-app/views/person/show.gsp b/grails-app/views/person/show.gsp new file mode 100644 index 0000000..3ec3654 --- /dev/null +++ b/grails-app/views/person/show.gsp @@ -0,0 +1,39 @@ + + + + + + <g:message code="default.show.label" args="[entityName]" /> + + +
+
+
+ + +
+
+
+

+ +
${flash.message}
+
+ + +
+ + +
+
+
+
+
+
+ +