Skip to content

Commit

Permalink
Merge branch 'release/6.1.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
cdausmus committed Nov 15, 2023
2 parents 058bfdf + 8ab644d commit 7237d05
Show file tree
Hide file tree
Showing 26 changed files with 677 additions and 91 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ branches:
only:
- master
- develop
- feature/dg-101
- /^feature\/.*$/
- /^hotfix\/.*$/
services:
- postgresql
addons:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {
id "com.dorongold.task-tree" version "2.1.1"
}

version "6.1.6"
version "6.1.7"
group "au.org.ala"
description "Digivol application"

Expand Down
10 changes: 8 additions & 2 deletions grails-app/assets/javascripts/admin-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,19 @@ function adminStats(config) {
self.getTranscriptionTimeByProjectType();
};

self.toISODate = function(dateObj) {
return dateObj.getFullYear() + '-' +
('0'+ (dateObj.getMonth()+1)).slice(-2) + '-' +
('0'+ dateObj.getDate()).slice(-2) + 'T00:00:00';
}

self.exportToCSV = function (data, reportType) {
// var dt = new google.visualization.DataTable(data);
// var csv = dt.toCSV();
// if (downloadCSV(csv, reportType) == "failed") {
//request browser to trigger server api to download
var startParam = self.startDate != null ? self.startDate.toISOString() : '';
var endParam = self.endDate != null ? self.endDate.toISOString() : '';
var startParam = self.startDate != null ? self.toISODate(self.startDate) : '';
var endParam = self.endDate != null ? self.toISODate(self.endDate) : '';
var institutionParam = self.institutionId;
var url = config.exportCSVReport + "?reportType=" + reportType + "&startDate=" + encodeURIComponent(startParam) +
"&endDate=" + encodeURIComponent(endParam) + "&institutionId=" + encodeURIComponent(institutionParam);
Expand Down
4 changes: 3 additions & 1 deletion grails-app/conf/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ spring:
enabled: true
baselineOnMigrate: true
baselineVersion: 1
outOfOrder: true
outOfOrder: false
default-schema: 'public'
table: 'schema_version'

server:
tomcat:
Expand Down
39 changes: 19 additions & 20 deletions grails-app/conf/spring/resources.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,48 @@ import au.org.ala.volunteer.BVPServletFilter
import au.org.ala.volunteer.DigivolServletContextConfig
import au.org.ala.volunteer.collectory.CollectoryClientFactoryBean
import org.flywaydb.core.Flyway
import org.flywaydb.core.api.MigrationVersion
import org.flywaydb.core.api.configuration.ClassicConfiguration
import org.springframework.beans.factory.config.BeanDefinition
import org.springframework.boot.web.servlet.FilterRegistrationBean

// Place your Spring DSL code here
beans = {
// customPageRenderer(CustomPageRenderer, ref("groovyPagesTemplateEngine")) {
// groovyPageLocator = ref("groovyPageLocator")
// }

collectoryClient(CollectoryClientFactoryBean) {
endpoint = 'http://collections.ala.org.au/ws/'
}

// bvpSecurePluginFilter(BVPSecurePluginFilter) {
// securityPrimitives = ref("securityPrimitives")
// }

applicationContextHolder(ApplicationContextHolder) { bean ->
bean.factoryMethod = 'getInstance'
}

digivolServletContextConfig(DigivolServletContextConfig)

bvpServletFilter(FilterRegistrationBean) {
bvpServletFilterBean(BVPServletFilter) {
authService = ref("authService")
}
bvpServletFilterRegistrationBean(FilterRegistrationBean) {
name = 'BVPServletFilter'
filter = bean(BVPServletFilter)
filter = ref("bvpServletFilterBean")
urlPatterns = [ '/*' ]
asyncSupported = true
}

if (application.config.getProperty('flyway.enabled', Boolean)) {
if (application.config.getProperty('spring.flyway.enabled', Boolean)) {

flyway(Flyway) { bean ->
bean.initMethod = 'migrate'
flywayConfiguration(ClassicConfiguration) { bean ->
dataSource = ref('dataSource')
baselineOnMigrate = application.config.getProperty('flyway.baselineOnMigrate', Boolean, false)
def outOfOrderProp = application.config.getProperty('flyway.outOfOrder', Boolean, false)
defaultSchema = application.config.getProperty('spring.flyway.default-schema')
table = application.config.getProperty('spring.flyway.table')
baselineOnMigrate = application.config.getProperty('spring.flyway.baselineOnMigrate', Boolean, true)
def outOfOrderProp = application.config.getProperty('spring.flyway.outOfOrder', Boolean, false)
outOfOrder = outOfOrderProp
//locations = application.config.flyway.locations ?: 'classpath:db/migration'
locations = ['classpath:db/migration']
if (application.config.getProperty('flyway.baselineVersion', Integer))
baselineVersionAsString = application.config.getProperty('flyway.baselineVersion', Integer).toString()
locationsAsStrings = application.config.getProperty('spring.flyway.locations', List<String>, ['classpath:db/migration'])
if (application.config.getProperty('spring.flyway.baselineVersion', Integer))
baselineVersionAsString = application.config.getProperty('spring.flyway.baselineVersion', Integer).toString()
}

flyway(Flyway, ref('flywayConfiguration')) { bean ->
bean.initMethod = 'migrate'
}

BeanDefinition sessionFactoryBeanDef = getBeanDefinition('sessionFactory')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package au.org.ala.volunteer

import au.org.ala.cas.util.AuthenticationCookieUtils
import au.org.ala.web.AuthService
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j

Expand All @@ -9,6 +9,7 @@ import groovy.util.logging.Slf4j
class DigivolActivityInterceptor {

UserService userService
AuthService authService
SettingsService settingsService

DigivolActivityInterceptor() {
Expand All @@ -25,7 +26,7 @@ class DigivolActivityInterceptor {
return true
}

def userId = AuthenticationCookieUtils.getUserName(request)
def userId = authService.userName
if (userId) {
userService.recordUserActivity(userId, request, params)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package au.org.ala.volunteer

import au.org.ala.cas.util.AuthenticationCookieUtils
import com.google.common.base.Stopwatch
import com.google.common.base.Strings
import grails.converters.JSON
import grails.gorm.transactions.Transactional
import grails.web.servlet.mvc.GrailsParameterMap
import org.apache.commons.io.FileUtils
import org.jooq.DSLContext
import org.springframework.dao.DataIntegrityViolationException
import org.springframework.web.multipart.MultipartFile
Expand Down Expand Up @@ -56,7 +54,7 @@ class ProjectController {

String currentUserId = null

def username = AuthenticationCookieUtils.getUserName(request)
def username = authService.userName
if (username) currentUserId = authService.getUserForEmailAddress(username)?.userId

if (!projectInstance) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SettingController {
SettingDefinition settingDefinition = getSettingDefByKey(key)
if (settingDefinition && value) {
settingsService.setSetting(key, value)
flash.message= "Setting '${key}' set to '${value}'"
flash.message= "Updated setting '${key}'."
} else {
flash.message= "Save setting failed! Either the setting key or value was missing/null"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,15 @@ class TranscribeController {
def skipNextAction = params.getBoolean('skipNextAction', false)
WebUtils.cleanRecordValues(params.recordValues as Map)

fieldSyncService.syncFields(taskInstance, params.recordValues as Map, currentUser, markTranscribed,
false, null, fieldSyncService.truncateFieldsForProject(taskInstance.project),
request.remoteAddr, transcription)
fieldSyncService.syncFields(taskInstance,
params.recordValues as Map,
currentUser,
markTranscribed as boolean,
false,
null,
fieldSyncService.truncateFieldsForProject(taskInstance.project),
request.remoteAddr,
transcription)

if (!taskInstance.hasErrors()) {
updatePicklists(taskInstance)
Expand All @@ -321,6 +327,7 @@ class TranscribeController {
render([success: true] as JSON)
} else {
log.debug("Save successful, skip to next task.")
welcomeUser(currentUserObj)
redirect(action: 'showNextFromProject', id: taskInstance.project.id,
params: [prevId: taskInstance.id, prevUserId: currentUser, complete: params.id, mode: params.mode ?: ''])
}
Expand All @@ -330,6 +337,7 @@ class TranscribeController {
render([success: true] as JSON)
} else {
log.debug("Save successful. Redirecting to show next action view")
welcomeUser(currentUserObj)
redirect(action: 'showNextAction', id: params.id, params: [mode: params.mode ?: ''])
}
}
Expand All @@ -352,6 +360,15 @@ class TranscribeController {
}
}

private void welcomeUser(User user) {
// Welcome email? Send if this was their first transcription and haven't been welcomed yet
User updatedUser = User.get(user.id)
if (!updatedUser.hasBeenWelcomed()) {
log.debug("User being sent welcome email after transcribing first task.")
userService.sendWelcomeEmail(updatedUser, UserService.WELCOME_EMAIL_TRANSCRIPTION)
}
}

/**
* Show the next task for the supplied project.
*/
Expand Down
18 changes: 15 additions & 3 deletions grails-app/domain/au/org/ala/volunteer/User.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ class User implements AsyncEntity<User> {
String firstName
String lastName
String organisation
Integer transcribedCount = 0 //the number of tasks completed by the user
Integer validatedCount = 0 // the number of task completed by this user and then validated by a validator
Date created //set to the date when the user first contributed
Integer transcribedCount = 0 // the number of tasks completed by the user
Integer validatedCount = 0 // the number of task completed by this user and then validated by a validator
Date created // set to the date when the user first contributed
Date welcomeEmailSent // Datetime user is sent the 'welcome' email.

String displayName // computed

Expand All @@ -23,6 +24,7 @@ class User implements AsyncEntity<User> {
table 'vp_user'
displayName formula: '''FIRST_NAME || ' ' || LAST_NAME'''
version false
welcomeEmailSent column: 'welcome_date'
}

static constraints = {
Expand All @@ -34,6 +36,7 @@ class User implements AsyncEntity<User> {
displayName nullable: true // nullable for unit tests
userId maxSize: 200
email maxSize: 200
welcomeEmailSent nullable: true
}

@Override
Expand Down Expand Up @@ -74,4 +77,13 @@ class User implements AsyncEntity<User> {
public String toString() {
"User (id: $id, userId: ${userId}, displayName: ${displayName})"
}

/**
* Returns true or false if a given user has been sent a welcome email yet.
* @return
*/
def hasBeenWelcomed() {
log.debug("User.hasBeenWelcomed: ${!(welcomeEmailSent == null)}")
return !(welcomeEmailSent == null)
}
}
3 changes: 3 additions & 0 deletions grails-app/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ default.button.dont.validate.label=Save partial validation

default.leaderboard.describeBadges.label=Badges

default.user.welcome.subject=Welcome to DigiVol!
default.user.welcome.preview=A welcome to DigiVol from the Australian Museum and Atlas of Living Australia.

# Data binding errors. Use "typeMismatch.$className.$propertyName to customize (eg typeMismatch.Book.author)
typeMismatch.java.net.URL=Property {0} must be a valid URL
typeMismatch.java.net.URI=Property {0} must be a valid URI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import javax.sql.DataSource
@Slf4j
class NewUserDigestNotifierJob {
def mailService
def userService
DataSource dataSource
static concurrent = false

Expand Down Expand Up @@ -89,6 +90,15 @@ class NewUserDigestNotifierJob {
sql.close()
}
}

// Welcome emails
def userList = User.findAllByWelcomeEmailSent(null)
if (userList.size() > 0) {
userList.each {user ->
userService.sendWelcomeEmail(user, UserService.WELCOME_EMAIL_SYNC)
}
}

log.info("New User Digest Notifier job finishing at ${new Date()}")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,9 @@ class InstitutionMessageService {
// Render the message, if errors, set the status and move on.
String message
try {
message = groovyPageRenderer.render(view: '/institutionMessage/messageTemplate',
model: [subject : iMessage.subject,
message = groovyPageRenderer.render(view: '/mail/messageTemplate',
model: [messageTemplate : 'institutionMsg',
subject : iMessage.subject,
inboxPreview : "A message from ${iMessage.institution.name}",
serverUrl : serverUrl,
institutionName : iMessage.institution.name,
Expand Down
Loading

0 comments on commit 7237d05

Please sign in to comment.