Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
tibetsprague committed Aug 23, 2022
2 parents e39e07b + 19b58b8 commit b9f0942
Show file tree
Hide file tree
Showing 16 changed files with 370 additions and 105 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [4.2.0] - 2022-08-19

### Added
- Add, delete and update Custom Views for groups that can either be a link to an external URL or a filtered view of posts in a group
- Project management link and Donations link added to posts (only used for projects right now)
- Query for non-logged in users to be able to look up public posts

### Fixed
- Bugs that could unset a location or area polygon when saving settings

## [4.1.5] - 2022-07-05

### Fixed
Expand Down
1 change: 1 addition & 0 deletions api/graphql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export function makePublicQueries (userId, fetchOne, fetchMany) {
// Can only access public communities and posts
group: async (root, { id, slug }) => fetchOne('Group', slug || id, slug ? 'slug' : 'id', { visibility: Group.Visibility.PUBLIC }),
groups: (root, args) => fetchMany('Group', Object.assign(args, { visibility: Group.Visibility.PUBLIC })),
post: (root, { id }) => fetchOne('Post', id, 'id', { isPublic: true }),
posts: (root, args) => fetchMany('Post', Object.assign(args, { isPublic: true }))
}
}
Expand Down
70 changes: 49 additions & 21 deletions api/graphql/makeModels.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,18 @@ export default async function makeModels (userId, isAdmin, apiClient) {
Post: {
model: Post,
attributes: [
'accept_contributions',
'announcement',
'created_at',
'updated_at',
'fulfilled_at',
'donations_link',
'end_time',
'start_time',
'location',
'announcement',
'accept_contributions',
'fulfilled_at',
'is_public',
'type'
'location',
'project_management_link',
'start_time',
'type',
'updated_at'
],
getters: {
commenters: (p, { first }) => p.getCommenters(first, userId),
Expand All @@ -176,25 +178,28 @@ export default async function makeModels (userId, isAdmin, apiClient) {
: ''
},
relations: [
{comments: {querySet: true}},
{ comments: { querySet: true } },
'groups',
{user: {alias: 'creator'}},
{ user: { alias: 'creator' } },
'followers',
'locationObject',
{members: {querySet: true}},
{eventInvitations: {querySet: true}},
{ members: { querySet: true } },
{ eventInvitations: { querySet: true } },
'linkPreview',
'postMemberships',
{media: {
alias: 'attachments',
arguments: ({ type }) => [type]
}},
{tags: {alias: 'topics'}}
{
media: {
alias: 'attachments',
arguments: ({ type }) => [type]
}
},
{ tags: { alias: 'topics' } }
],
filter: postFilter(userId, isAdmin),
isDefaultTypeForTable: true,
fetchMany: ({ afterTime, beforeTime, boundingBox, context, filter, first, groupSlugs, isFulfilled, offset, order, sortBy, search, topic, topics, types }) =>
fetchMany: ({ activePostsOnly = false, afterTime, beforeTime, boundingBox, context, filter, first, groupSlugs, isFulfilled, offset, order, sortBy, search, topic, topics, types }) =>
searchQuerySet('posts', {
activePostsOnly,
afterTime,
beforeTime,
boundingBox,
Expand Down Expand Up @@ -236,6 +241,7 @@ export default async function makeModels (userId, isAdmin, apiClient) {
relations: [
{activeMembers: { querySet: true }},
{childGroups: {querySet: true}},
{customViews: {querySet: true}},
{groupRelationshipInvitesFrom: {querySet: true}},
{groupRelationshipInvitesTo: {querySet: true}},
{groupTags: {
Expand All @@ -260,8 +266,9 @@ export default async function makeModels (userId, isAdmin, apiClient) {
{parentGroups: {querySet: true}},
{posts: {
querySet: true,
filter: (relation, { afterTime, beforeTime, boundingBox, filter, isAnnouncement, isFulfilled, order, search, sortBy, topic, topics, types }) =>
filter: (relation, { activePostsOnly = false, afterTime, beforeTime, boundingBox, filter, isAnnouncement, isFulfilled, order, search, sortBy, topic, topics, types }) =>
relation.query(filterAndSortPosts({
activePostsOnly,
afterTime,
beforeTime,
boundingBox,
Expand Down Expand Up @@ -303,8 +310,9 @@ export default async function makeModels (userId, isAdmin, apiClient) {
{viewPosts: {
querySet: true,
arguments: () => [userId],
filter: (relation, { afterTime, beforeTime, boundingBox, filter, isFulfilled, order, search, sortBy, topic, topics, types }) =>
filter: (relation, { activePostsOnly = false, afterTime, beforeTime, boundingBox, filter, isFulfilled, order, search, sortBy, topic, topics, types }) =>
relation.query(filterAndSortPosts({
activePostsOnly,
afterTime,
beforeTime,
boundingBox,
Expand Down Expand Up @@ -438,14 +446,34 @@ export default async function makeModels (userId, isAdmin, apiClient) {
'created_at',
'status',
'type',
'updated_at',
'updated_at'
],
getters: {
questionAnswers: i => i.questionAnswers().fetch()
},
relations: ['createdBy', 'fromGroup', 'toGroup']
},

CustomView: {
model: CustomView,
attributes: [
'group_id',
'is_active',
'search_text',
'icon',
'name',
'external_link',
'view_mode',
'active_posts_only',
'post_types',
'order'
],
relations: [
'group',
{ tags: { alias: 'topics' } }
]
},

Invitation: {
model: Invitation,
attributes: [
Expand All @@ -458,7 +486,7 @@ export default async function makeModels (userId, isAdmin, apiClient) {
relations: [
'creator',
'group'
],
]
},

JoinRequest: {
Expand Down
1 change: 1 addition & 0 deletions api/graphql/mutations/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export async function removeModerator (userId, personId, groupId, isRemoveFromGr

export async function updateGroup (userId, groupId, changes) {
const group = await getModeratedGroup(userId, groupId)

return group.update(convertGraphqlData(changes))
}

Expand Down
125 changes: 89 additions & 36 deletions api/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ type Person {
moderatedGroupMemberships(first: Int, cursor: ID, order: String): [Membership]
moderatedGroupMembershipsTotal: Int
posts(
activePostsOnly: Boolean,
afterTime: Date,
beforeTime: Date,
boundingBox: [PointInput],
Expand Down Expand Up @@ -197,6 +198,7 @@ type Group {
autocomplete: String
): GroupQuerySet
createdAt: Date
customViews: CustomViewQuerySet
description: String
geoShape: JSON
groupExtensions: GroupExtensionQuerySet
Expand Down Expand Up @@ -245,6 +247,7 @@ type Group {
pendingInvitations(first: Int, cursor: ID, order: String): InvitationQuerySet
prerequisiteGroups(onlyNotMember: Boolean): GroupQuerySet
posts(
activePostsOnly: Boolean,
afterTime: Date,
beforeTime: Date,
boundingBox: [PointInput],
Expand Down Expand Up @@ -273,6 +276,7 @@ type Group {
typeDescriptor: String
typeDescriptorPlural: String
viewPosts(
activePostsOnly: Boolean,
afterTime: Date,
beforeTime: Date,
boundingBox: [PointInput],
Expand Down Expand Up @@ -345,6 +349,29 @@ type Widget {
name: String
}

type CustomView {
id: Int
name: String
groupId: Int
group: Group
isActive: Boolean
searchText: String
icon: String
externalLink: String
viewMode: String
order: Int
activePostsOnly: Boolean
postTypes: [String]
topics: [Topic]
topicsTotal: Int
}

type CustomViewQuerySet {
total: Int
hasMore: Boolean
items: [CustomView]
}

type GroupRelationship {
id: ID
childGroup: Group
Expand Down Expand Up @@ -447,42 +474,44 @@ type Interstitial {

type Post {
id: ID
title: String
details: String
type: String
createdAt: Date
updatedAt: Date
fulfilledAt: Date
startTime: Date
endTime: Date
location: String
locationObject: Location
isPublic: Boolean
creator: Person
followers(first: Int, cursor: ID, order: String): [Person]
followersTotal: Int
acceptContributions: Boolean
activeMembers(first: Int, cursor: ID, order: String): PersonQuerySet
members(first: Int, cursor: ID, order: String): PersonQuerySet
eventInvitations(first: Int, cursor: ID, order: String): EventInvitationQuerySet
groups(first: Int, cursor: ID, order: String): [Group]
groupsTotal: Int
announcement: Boolean
attachments(type: String): [Attachment]
attachmentsTotal: Int
comments(first: Int, cursor: ID, order: String): CommentQuerySet
commenters(first: Int): [Person]
commentersTotal: Int
commentsTotal: Int
createdAt: Date
creator: Person
details: String
donationsLink: String
endTime: Date
eventInvitations(first: Int, cursor: ID, order: String): EventInvitationQuerySet
groups(first: Int, cursor: ID, order: String): [Group]
groupsTotal: Int
followers(first: Int, cursor: ID, order: String): [Person]
followersTotal: Int
fulfilledAt: Date
linkPreview: LinkPreview
votesTotal: Int
location: String
locationObject: Location
myVote: Boolean
attachments(type: String): [Attachment]
attachmentsTotal: Int
postMemberships: [PostMembership]
postMembershipsTotal: Int,
topics: [Topic],
postMembershipsTotal: Int
projectManagementLink: String
isPublic: Boolean
members(first: Int, cursor: ID, order: String): PersonQuerySet
myEventResponse: String
startTime: Date
title: String
topics: [Topic]
topicsTotal: Int
announcement: Boolean
acceptContributions: Boolean
totalContributions: Int
myEventResponse: String
type: String
updatedAt: Date
votesTotal: Int
}

type PostMembership {
Expand Down Expand Up @@ -678,6 +707,7 @@ type Query {
messageThread(id: ID): MessageThread
post(id: ID): Post
posts(
activePostsOnly: Boolean,
afterTime: Date,
beforeTime: Date,
boundingBox: [PointInput],
Expand Down Expand Up @@ -782,23 +812,25 @@ input MeInput {
}

input PostInput {
title: String
acceptContributions: Boolean
announcement: Boolean
details: String
type: String
donationsLink: String
endTime: Date
eventInviteeIds: [ID]
fileUrls: [String]
groupIds: [String]
linkPreviewId: String
imageUrls: [String]
isPublic: Boolean
linkPreviewId: String
location: String
locationId: ID
imageUrls: [String]
fileUrls: [String]
announcement: Boolean
topicNames: [String]
memberIds: [ID]
acceptContributions: Boolean
eventInviteeIds: [ID]
projectManagementLink: String
startTime: Date
endTime: Date
title: String
topicNames: [String]
type: String
}

input CommentInput {
Expand Down Expand Up @@ -874,6 +906,7 @@ input GroupInput {
active: Boolean
avatarUrl: String
bannerUrl: String
customViews: [CustomViewInput]
description: String
geoShape: String
groupToGroupJoinQuestions: [QuestionInput]
Expand Down Expand Up @@ -912,6 +945,26 @@ input GroupExtensionInput {
type: String
}

input CustomViewInput {
id: ID
name: String
groupId: Int
isActive: Boolean
searchText: String
icon: String
externalLink: String
viewMode: String
activePostsOnly: Boolean
postTypes: [String]
order: Int
topics: [CustomViewTopicInput]
}

input CustomViewTopicInput {
id: ID
name: String
}

input QuestionInput {
id: Int
questionId: Int
Expand Down
Loading

0 comments on commit b9f0942

Please sign in to comment.