Is there an easy way in Grails to not allow deletion for any domain class? And, rather, there is a delete flag in each domain, which is updated whenever something is deleted.
In addition, in fact, all list / show methods should not show objects in which the delete flag is true.
I know that I can do this by manually editing all my CRUD methods in all controllers, but there seems to be too much work when working with Grails, where everything can be done by changing some kind of flag somewhere !!
My usual list method is as follows: almost all list methods in my project allow the user to access things that belong only to the user's company.
def list = {
params.max = Math.min(params.max ? params.int('max') : 10, 100)
def documentsList = Documents.createCriteria().list(params){
eq("company.id",session.companyId)
maxResults(params.max)
order("dateCreated","desc")
}
[documentsInstanceList: documentsList , documentsInstanceTotal: documentsList.getTotalCount() ]
}
source
share