Skip to content

Commit

Permalink
updated edit / new functionality for sections to allow editing
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandunn committed Apr 1, 2014
1 parent 28baacc commit 5014ad4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,24 @@ class RegisterController extends grails.plugins.springsecurity.ui.RegisterContro
userLaboratory = Laboratory.findById(command.laboratoryId as Integer)
}

println " laboratory id: ${command.laboratoryId} -> ${userLaboratory}"

String salt = saltSource instanceof NullSaltSource ? null : command.username
SecUser user = lookupUserClass().newInstance(
// email: command.email
username: command.username
, accountLocked: true
, enabled: true
, fullName: command.fullName
, laboratory: userLaboratory
)



if(userLaboratory){
user.addToLaboratories(userLaboratory)
userLaboratory.addToUsers(user)
}

// Role role = Role.findByAuthority(Role.ROLE_VERIFIED)
// SecUserRole secUserRole = new SecUserRole(
// secUser: user
Expand Down
10 changes: 7 additions & 3 deletions grails-app/taglib/edu/uoregon/nic/nemo/portal/UserTagLib.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class UserTagLib {
def editable = { attrs, body ->
def currentUser = springSecurityService.currentUser
log.debug "has a current user ${currentUser}"
log.debug "attrs: ${attrs}"
if(!currentUser) return

if(userService.isAdmin(currentUser)){
Expand All @@ -18,6 +19,8 @@ class UserTagLib {

def users = attrs.users

log.debug "users: ${users}"

if(users instanceof SecUser){
if (currentUser == users){
out << body()
Expand All @@ -28,12 +31,13 @@ class UserTagLib {

def user = attrs.user ?: currentUser

log.debug "user ${currentUser}"
log.debug "A user! user ${attrs.user}"
log.debug "A user2! user ${user}"

if(users){
println "users - ${users}"
log.debug "users - ${users}"
for(u in users){
println "u ${u}"
log.debug "U ${u?.id} vs ${user.id}"
if(u.id == user.id){
out << body()
return
Expand Down
5 changes: 2 additions & 3 deletions grails-app/views/condition/show.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@

</table>


<g:editable users="${conditionInstance?.experiment?.laboratory?.users}">
<g:form>
<fieldset class="buttons">
Expand All @@ -79,9 +78,9 @@


<div class="indent-dependent">
<g:include view="stimulus/section.gsp" model="[stimuli: stimulusList]"/>
<g:include view="stimulus/section.gsp" model="[stimuli: stimulusList,experimentInstance:conditionInstance.experiment]"/>

<g:include view="response/section.gsp" model="[responses: responseList]"/>
<g:include view="response/section.gsp" model="[responses: responseList,experimentInstance:conditionInstance.experiment]"/>
</div>

</div>
Expand Down

0 comments on commit 5014ad4

Please sign in to comment.