Skip to content

Commit

Permalink
commit progress update #1659
Browse files Browse the repository at this point in the history
  • Loading branch information
salomon-j committed Jan 23, 2025
1 parent b46ac0d commit 06ba467
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.apache.commons.io.FilenameUtils
import org.apache.http.HttpStatus
import org.apache.http.entity.ContentType
import org.grails.web.json.JSONArray
import org.grails.web.json.JSONObject
import org.springframework.context.MessageSource
import org.springframework.web.multipart.MultipartFile

Expand Down Expand Up @@ -1866,7 +1867,7 @@ class BioActivityController {
log.debug("includeSiteData = ${includeSiteData}")

String userId = userService.getCurrentUserId()
def activity = activityService.get(id)
def activity = activityService.get(id, null, userId, false,includeSiteData)
String projectId = activity?.projectId
def model = [:]

Expand All @@ -1880,12 +1881,11 @@ class BioActivityController {
} else if (!projectId) {
model.error = "No project associated with the activity"
} else if (projectService.isUserAdminForProject(userId, projectId) || activityService.isUserOwnerForActivity(userId, activity?.activityId)) {
model = [activity: activity]
if (includeSiteData) {
def activitySite = siteService.get(model.activity.siteId, [view: 'brief'])
model.site = [siteId: activitySite.siteId, name:activitySite.name, geoJson:activitySite.geoIndex]
activity.site = new JSONObject([siteId:activity.site.siteId, name:activity.site.name, geoJson:activity.site.geoIndex])
activity.remove('siteId')
}

model = [activity: activity]
} else {
response.status = 401
model.error = "Access denied: User is not an owner of this activity ${activity?.activityId}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,17 @@ class ActivityService {
webService.getJson(grailsApplication.config.ecodata.service.url + '/activity/getDistinctSitesForProject/'+ id)
}

def get(id, version = null, userId = null, hideMemberOnlyFlds = false) {
def get(id, version = null, userId = null, hideMemberOnlyFlds = false, includeSiteData = false) {
def params = '?hideMemberOnlyFlds=' + hideMemberOnlyFlds
if (version) {
params += '&version=' + version
}
if (userId) {
params += '&userId=' + userId
}
if (includeSiteData) {
params += '&view=site'
}

def activity = webService.getJson(grailsApplication.config.ecodata.service.url + '/activity/' + id + params)
activity
Expand Down

0 comments on commit 06ba467

Please sign in to comment.