Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
tibetsprague committed Jun 21, 2022
2 parents 50037ec + 2469648 commit 577fc77
Show file tree
Hide file tree
Showing 6 changed files with 2,171 additions and 2,045 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [4.1.4] - 2022-06-20

### Fixed
- Groups not displaying when they don't have a location but location obfuscation is set to something other than Precise

## [4.1.3] - 2022-06-15

### Added
- Can update groupExtenions when updating a group

### Changed
- New collaboration for farms

## [4.1.2] - 2022-06-08

### Added
Expand Down
17 changes: 10 additions & 7 deletions api/graphql/makeModels.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,18 @@ export default async function makeModels (userId, isAdmin, apiClient) {
return g.get('location')
} else {
const locObj = await g.locationObject().fetch()
let display = locObj.get('country')
if (locObj.get('region')) {
display = locObj.get('region') + ", " + display
}
if (locObj.get('city')) {
display = locObj.get('city') + ", " + display
if (locObj) {
let display = locObj.get('country')
if (locObj.get('region')) {
display = locObj.get('region') + ", " + display
}
if (locObj.get('city')) {
display = locObj.get('city') + ", " + display
}
return display
}
return display
}
return null
},
locationObject: async (g) => {
// If precision is precise or user is a moderator of the group show the exact location
Expand Down
17 changes: 15 additions & 2 deletions api/models/Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ module.exports = bookshelf.Model.extend(merge({
},

update: async function (changes) {
var whitelist = [
const whitelist = [
'about_video_uri', 'active', 'access_code', 'accessibility', 'avatar_url', 'banner_url',
'description', 'geo_shape', 'location', 'location_id', 'name', 'moderator_descriptor',
'moderator_descriptor_plural', 'settings', 'type_descriptor', 'type_descriptor_plural', 'visibility'
Expand Down Expand Up @@ -424,11 +424,24 @@ module.exports = bookshelf.Model.extend(merge({
await Promise.map(parentRelationships.models, async (relationship) => {
const isNowPrereq = changes.prerequisite_group_ids.includes(relationship.get('parent_group_id'))
if (relationship.getSetting('isPrerequisite') !== isNowPrereq) {
await relationship.addSetting({ isPrerequisite: isNowPrereq}, true)
await relationship.addSetting({ isPrerequisite: isNowPrereq }, true)
}
})
}

if (changes.group_extensions) {
for (const extData of changes.group_extensions) {
const ext = await Extension.find(extData.type)
if (ext) {
const ge = (await GroupExtension.find(this.id, ext.id)) || new GroupExtension({ group_id: this.id, extension_id: ext.id })
ge.set({ data: extData.data })
await ge.save()
} else {
throw Error('Invalid extension type ' + extData.type)
}
}
}

this.set(saneAttrs)
await this.validate().then(() => this.save())
return this
Expand Down
10 changes: 9 additions & 1 deletion api/models/GroupExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ module.exports = bookshelf.Model.extend(Object.assign({
async type () {
return (await this.extension().fetch()).get('type')
}
}), {})
}), {
find (groupId, extensionId, opts = {}) {
if (!groupId || !extensionId) return Promise.resolve(null)

const where = { group_id: groupId, extension_id: extensionId }

return this.where(where).fetch(opts)
}
})
Loading

0 comments on commit 577fc77

Please sign in to comment.