Skip to content

Commit

Permalink
feat(Events): add support for online events
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Mar 23, 2021
1 parent 2f5136d commit d4e2b94
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 4 deletions.
45 changes: 45 additions & 0 deletions server/graphql/schemaV1.graphql
Expand Up @@ -114,6 +114,11 @@ type Collective implements CollectiveInterface {
"""
isPledged: Boolean
data: JSON @deprecated(reason: "2020-10-08: This field is not provided anymore and will return an empty object")

"""
Private instructions related to an event
"""
privateInstructions: String
githubContributors: JSON!
slug: String
path: String
Expand Down Expand Up @@ -406,6 +411,11 @@ input CollectiveInputType {
tiers: [TierInputType]
settings: JSON
data: JSON

"""
Private instructions related to an event
"""
privateInstructions: String
members: [MemberInputType]
notifications: [NotificationInputType]
HostCollectiveId: Int
Expand Down Expand Up @@ -462,6 +472,11 @@ interface CollectiveInterface {
"""
isPledged: Boolean
data: JSON @deprecated(reason: "2020-10-08: This field is not provided anymore and will return an empty object")

"""
Private instructions related to an event
"""
privateInstructions: String
githubContributors: JSON!
slug: String
path: String
Expand Down Expand Up @@ -1084,6 +1099,11 @@ type Event implements CollectiveInterface {
"""
isPledged: Boolean
data: JSON @deprecated(reason: "2020-10-08: This field is not provided anymore and will return an empty object")

"""
Private instructions related to an event
"""
privateInstructions: String
githubContributors: JSON!
slug: String
path: String
Expand Down Expand Up @@ -1451,6 +1471,11 @@ type Fund implements CollectiveInterface {
"""
isPledged: Boolean
data: JSON @deprecated(reason: "2020-10-08: This field is not provided anymore and will return an empty object")

"""
Private instructions related to an event
"""
privateInstructions: String
githubContributors: JSON!
slug: String
path: String
Expand Down Expand Up @@ -2478,6 +2503,11 @@ type Organization implements CollectiveInterface {
"""
isPledged: Boolean
data: JSON @deprecated(reason: "2020-10-08: This field is not provided anymore and will return an empty object")

"""
Private instructions related to an event
"""
privateInstructions: String
githubContributors: JSON!
slug: String
path: String
Expand Down Expand Up @@ -2857,6 +2887,11 @@ type Project implements CollectiveInterface {
"""
isPledged: Boolean
data: JSON @deprecated(reason: "2020-10-08: This field is not provided anymore and will return an empty object")

"""
Private instructions related to an event
"""
privateInstructions: String
githubContributors: JSON!
slug: String
path: String
Expand Down Expand Up @@ -3706,6 +3741,11 @@ type User implements CollectiveInterface {
"""
isPledged: Boolean
data: JSON @deprecated(reason: "2020-10-08: This field is not provided anymore and will return an empty object")

"""
Private instructions related to an event
"""
privateInstructions: String
githubContributors: JSON!
slug: String
path: String
Expand Down Expand Up @@ -3989,6 +4029,11 @@ type Vendor implements CollectiveInterface {
"""
isPledged: Boolean
data: JSON @deprecated(reason: "2020-10-08: This field is not provided anymore and will return an empty object")

"""
Private instructions related to an event
"""
privateInstructions: String
githubContributors: JSON!
slug: String
path: String
Expand Down
16 changes: 16 additions & 0 deletions server/graphql/v1/CollectiveInterface.js
Expand Up @@ -652,6 +652,10 @@ export const CollectiveInterfaceType = new GraphQLInterfaceType({
type: GraphQLJSON,
deprecationReason: '2020-10-08: This field is not provided anymore and will return an empty object',
},
privateInstructions: {
type: GraphQLString,
description: 'Private instructions related to an event',
},
githubContributors: { type: new GraphQLNonNull(GraphQLJSON) },
slug: { type: GraphQLString },
path: { type: GraphQLString },
Expand Down Expand Up @@ -1107,6 +1111,18 @@ const CollectiveFields = () => {
return {};
},
},
privateInstructions: {
type: GraphQLString,
description: 'Private instructions related to an event',
resolve(collective, _, req) {
if (
collective.type === types.EVENT &&
(req.remoteUser?.isAdminOfCollective(collective) || req.remoteUser?.hasRole(roles.PARTICIPANT, collective))
) {
return collective.data?.privateInstructions;
}
},
},
githubContributors: {
type: new GraphQLNonNull(GraphQLJSON),
resolve(collective) {
Expand Down
1 change: 1 addition & 0 deletions server/graphql/v1/inputTypes.js
Expand Up @@ -169,6 +169,7 @@ export const CollectiveInputType = new GraphQLInputObjectType({
tiers: { type: new GraphQLList(TierInputType) },
settings: { type: GraphQLJSON },
data: { type: GraphQLJSON, deprecationReason: '2020-10-08: data cannot be edited. This field will be ignored.' },
privateInstructions: { type: GraphQLString, description: 'Private instructions related to an event' },
members: { type: new GraphQLList(MemberInputType) },
notifications: { type: new GraphQLList(NotificationInputType) },
HostCollectiveId: { type: GraphQLInt },
Expand Down
20 changes: 18 additions & 2 deletions server/graphql/v1/mutations/collectives.js
Expand Up @@ -56,6 +56,12 @@ export async function createCollective(_, args, req) {
};
}
}
// Set private instructions
if (args.collective.privateInstructions) {
collectiveData.data = {
privateInstructions: args.collective.privateInstructions,
};
}

collectiveData.isActive = false;
if (args.collective.ParentCollectiveId) {
Expand Down Expand Up @@ -291,7 +297,7 @@ export function editCollective(_, args, req) {
}

const newCollectiveData = {
...omit(args.collective, ['location', 'type', 'ParentCollectiveId', 'data']),
...omit(args.collective, ['location', 'type', 'ParentCollectiveId', 'data', 'privateInstructions']),
LastEditedByUserId: req.remoteUser.id,
};

Expand Down Expand Up @@ -381,7 +387,17 @@ export function editCollective(_, args, req) {
return collective.updateCurrency(newCollectiveData.currency, req.remoteUser);
}
})
.then(() => collective.update(omit(newCollectiveData, ['HostCollectiveId', 'hostFeePercent', 'currency']))) // we omit those attributes that have already been updated above
.then(() => {
// Set private instructions value
if (args.collective.privateInstructions) {
newCollectiveData.data = {
...collective.data,
privateInstructions: args.collective.privateInstructions,
};
}
// we omit those attributes that have already been updated above
return collective.update(omit(newCollectiveData, ['HostCollectiveId', 'hostFeePercent', 'currency']));
})
.then(() => collective.editTiers(args.collective.tiers))
.then(() => {
// @deprecated since 2019-10-21: now using dedicated `editCoreContributors` endpoint
Expand Down
2 changes: 1 addition & 1 deletion server/lib/notifications.js
Expand Up @@ -152,8 +152,8 @@ async function notifyUserId(UserId, activity, options = {}) {
}
}
}

activity.data.event = event.info;
activity.data.isOffline = activity.data.event.locationName !== 'Online';
activity.data.collective = parentCollective.info;
options.from = `${parentCollective.name} <no-reply@${parentCollective.slug}.opencollective.com>`;
}
Expand Down
15 changes: 14 additions & 1 deletion templates/emails/ticket.confirmed.hbs
Expand Up @@ -13,7 +13,20 @@ Subject: {{ order.quantity }} {{pluralize "ticket" n=order.quantity}} confirmed

<p>This confirms your {{ order.quantity }} {{pluralize "ticket" n=order.quantity}}{{#if order.totalAmount}} for a total of {{currency order.totalAmount currency=order.currency}}{{/if}}. </p>

<p>We are excited that you'll be joining us at <a href="{{config.host.website}}/{{collective.slug}}/events/{{event.slug}}">{{ event.name }}</a> on {{ moment event.startsAt timezone=event.timezone format="MMMM Do YYYY" }} at {{ moment event.startsAt timezone=event.timezone format="h:mma" }} at {{ event.locationName }} ({{event.address}}).</p>
<p>We are excited that you'll be joining us at <a href="{{config.host.website}}/{{collective.slug}}/events/{{event.slug}}">{{ event.name }}</a> on {{ moment event.startsAt timezone=event.timezone format="MMMM Do YYYY" }} at {{ moment event.startsAt timezone=event.timezone format="h:mma" }}
{{#if isOffline }}
at {{ event.locationName }} ({{event.address}}).
{{else if event.address}}
on {{event.address}}.
{{/if}}
</p>

{{#if event.data.privateInstructions}}
<h2>Private Instructions</h2>
<p>
{{event.data.privateInstructions}}
</p>
{{/if}}

{{#if transactionPdf}}
<h2>📎 Attachments</h2>
Expand Down

0 comments on commit d4e2b94

Please sign in to comment.