Skip to content

Commit

Permalink
- removed user check since GA is not used anymore
Browse files Browse the repository at this point in the history
- added download tracking on DOI controller
  • Loading branch information
temi committed Jun 29, 2023
1 parent 1d8a4fb commit 85c2305
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@ profileEditor.controller('DoiController', function (util, $filter, profileServic
}
});
}

self.trackDownload = function (context, opusId, profileId, publicationId) {
var url = context + '/opus/' + opusId + '/profile/' + profileId + '/publication/' + publicationId + '/file'
profileService.trackPageview(url);
}

});
23 changes: 10 additions & 13 deletions grails-app/controllers/au/org/ala/profile/api/ApiInterceptor.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,16 @@ class ApiInterceptor {
def method = controllerClass?.getMethod(actionName, [] as Class[])

if (authorization) {
def user = authService.userDetails()
if (user) {
if (params.opusId && (opus = profileService.getOpus(params.opusId))) {
params.isOpusPrivate = opus.privateCollection
if ((params.isOpusPrivate
|| controllerClass?.isAnnotationPresent(RequiresAccessToken)
|| method?.isAnnotationPresent(RequiresAccessToken)
) && (token != opus.accessToken)) {
log.warn("No valid access token for opus ${opus.uuid} when calling ${controllerName}/${actionName}")
authorised = false
} else {
authorised = true
}
if (params.opusId && (opus = profileService.getOpus(params.opusId))) {
params.isOpusPrivate = opus.privateCollection
if ((params.isOpusPrivate
|| controllerClass?.isAnnotationPresent(RequiresAccessToken)
|| method?.isAnnotationPresent(RequiresAccessToken)
) && (token != opus.accessToken)) {
log.warn("No valid access token for opus ${opus.uuid} when calling ${controllerName}/${actionName}")
authorised = false
} else {
authorised = true
}
}
}
Expand Down
1 change: 1 addition & 0 deletions grails-app/views/profile/publication.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<div>
<a class="btn btn-primary"
ng-href="${request.contextPath}/opus/{{doiCtrl.opus.shortName || doiCtrl.opus.uuid }}/profile/{{doiCtrl.profileId}}/publication/{{doiCtrl.selectedPublication.uuid}}/file"
ng-click="doiCtrl.trackDownload('${request.contextPath}', doiCtrl.opus.uuid, doiCtrl.profileId, doiCtrl.selectedPublication.uuid)"
target="_blank"><span class="glyphicon glyphicon-download"></span> Download PDF</a>
<a class="btn btn-default"
href="${request.contextPath}/opus/{{doiCtrl.opus.shortName ? doiCtrl.opus.shortName : doiCtrl.opus.uuid}}/profile/{{doiCtrl.profile.scientificName}}" target="_blank">View Profile</a>
Expand Down

0 comments on commit 85c2305

Please sign in to comment.