Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.DS_Store
scripts/
scripts/
dump/
24 changes: 24 additions & 0 deletions backend/migrations/12-add-timeline-to-event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const mongoose = require('mongoose')
const Promise = require('bluebird')

module.exports = {
index: 12,
name: '12-add-timeline-to-event',
description: 'add timeline event',
run: async () => {
const nres = await mongoose
.model('Event')
.updateMany(
{ eventTimeline: { $exists: false } },
{ $set: { eventTimeline: { items: [] } } },
)
const bres = await mongoose
.model('Event')
.updateMany(
{ eventTimeline: null },
{ $set: { eventTimeline: { items: [] } } },
)
console.info('Done with event timeline', nres.n, nres.nModified)
return Promise.resolve()
},
}
18 changes: 18 additions & 0 deletions backend/migrations/13-set-eventLocation-null-where-not-exists.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const mongoose = require('mongoose')
const Promise = require('bluebird')

module.exports = {
index: 13,
name: '13-set-eventLocation-null-where-not-exists',
description: 'set eventLocation null where not exists',
run: async () => {
const nres = await mongoose
.model('Event')
.updateMany(
{ eventLocation: { $exists: false } },
{ $set: { eventLocation: null } },
)
console.info('Done with event timeline', nres.n, nres.nModified)
return Promise.resolve()
},
}
2 changes: 2 additions & 0 deletions backend/migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const migrations = [
require('./09-sync-registration-to-profiles'),
require('./10-add-banner-priority-and-approved-to-event'),
require('./11-add-organization-to-event'),
require('./12-add-timeline-to-event'),
require('./13-set-eventLocation-null-where-not-exists'),
]

const run = async () => {
Expand Down
9 changes: 9 additions & 0 deletions backend/modules/event/graphql-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ class EventController {
return this._clean(Event.find().lean())
}

async update(id, event) {
if (!this.isAdmin) {
return null
}
return this._clean(
Event.findOneAndUpdate({ _id: id }, event, { new: true }),
)
}

async _clean(promise) {
const result = await promise
if (Array.isArray(result)) {
Expand Down
185 changes: 184 additions & 1 deletion backend/modules/event/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
GraphQLList,
GraphQLInt,
GraphQLBoolean,
GraphQLInputObjectType,
} = require('graphql')
const { GraphQLDateTime } = require('graphql-iso-date')

Expand All @@ -16,18 +17,171 @@ const dateUtils = require('../../common/utils/dateUtils')

const {
CloudinaryImage,
CloudinaryImageInput,
Address,
AddressInput,
Track,
TrackInput,
Challenge,
ChallengeInput,
TravelGrantConfig,
TravelGrantConfigInput,
RegistrationSection,
RegistrationSectionInput,
EventTag,
EventTagInput,
RegistrationConfig,
RegistrationConfigInput,
EventTheme,
EventThemeInput,
EventTimeline,
EventTimelineInput,
Webhook,
WebhookInput,
} = require('../graphql-shared-types')

const Organization = require('../organization/model')

const EventInput = new GraphQLInputObjectType({
name: 'EventInput',
fields: {
name: {
type: GraphQLString,
},
slug: {
type: GraphQLString,
},
timezone: {
type: GraphQLString,
},
coverImage: {
type: CloudinaryImageInput,
},
logo: {
type: CloudinaryImageInput,
},
eventType: {
type: GraphQLString,
},
description: {
type: GraphQLString,
},
/** Times */
registrationStartTime: {
type: GraphQLDateTime,
},
registrationEndTime: {
type: GraphQLDateTime,
},
startTime: {
type: GraphQLDateTime,
},
endTime: {
type: GraphQLDateTime,
},
submissionsStartTime: {
type: GraphQLDateTime,
},
submissionsEndTime: {
type: GraphQLDateTime,
},
reviewingStartTime: {
type: GraphQLDateTime,
},
reviewingEndTime: {
type: GraphQLDateTime,
},
finalsActive: {
type: GraphQLBoolean,
},
eventLocation: {
type: AddressInput,
},
tracksEnabled: {
type: GraphQLBoolean,
},
tracks: {
type: GraphQLList(TrackInput),
},
challengesEnabled: {
type: GraphQLBoolean,
},
challenges: {
type: GraphQLList(ChallengeInput),
},
travelGrantConfig: {
type: TravelGrantConfigInput,
},
reviewMethod: {
type: GraphQLString,
},
overallReviewMethod: {
type: GraphQLString,
},
customQuestions: {
type: GraphQLList(RegistrationSectionInput),
},
tags: {
type: GraphQLList(EventTagInput),
},
/** System metadata */
published: {
type: GraphQLBoolean,
},
galleryOpen: {
type: GraphQLBoolean,
},
owner: {
type: GraphQLString,
},
organisers: {
type: GraphQLList(GraphQLString),
},
organizations: {
type: GraphQLList(GraphQLID),
},
registrationConfig: {
type: RegistrationConfigInput,
},
demoLabel: {
type: GraphQLString,
},
demoHint: {
type: GraphQLString,
},
eventPrivacy: {
type: GraphQLString,
},
eventTerms: {
type: GraphQLString,
},
eventTimeline: {
type: EventTimelineInput,
},
demoPlaceholder: {
type: GraphQLString,
},
metaDescription: {
type: GraphQLString,
},
finalists: {
type: GraphQLList(GraphQLString),
},
frontPagePriority: {
type: GraphQLInt,
},
approved: {
type: GraphQLBoolean,
},
theme: {
type: EventThemeInput,
},
webhooks: {
type: GraphQLList(WebhookInput),
},
},
})

const EventType = new GraphQLObjectType({
name: 'Event',
fields: () => {
Expand Down Expand Up @@ -113,7 +267,7 @@ const EventType = new GraphQLObjectType({
type: GraphQLList(RegistrationSection),
},
tags: {
type: EventTag,
type: GraphQLList(EventTag),
},
/** System metadata */
published: {
Expand Down Expand Up @@ -146,6 +300,9 @@ const EventType = new GraphQLObjectType({
eventTerms: {
type: GraphQLString,
},
eventTimeline: {
type: EventTimeline,
},
demoPlaceholder: {
type: GraphQLString,
},
Expand All @@ -164,6 +321,9 @@ const EventType = new GraphQLObjectType({
theme: {
type: EventTheme,
},
webhooks: {
type: GraphQLList(Webhook),
},
// Implement userprofile in graphql
// TODO: Figure this stuff out
// winners: {
Expand Down Expand Up @@ -247,6 +407,23 @@ const QueryType = new GraphQLObjectType({
},
})

const MutationType = new GraphQLObjectType({
name: 'Mutation',
fields: {
updateEvent: {
type: EventType,
args: {
_id: {
type: GraphQLNonNull(GraphQLID),
},
event: {
type: GraphQLNonNull(EventInput),
},
},
},
},
})

const Resolvers = {
Query: {
myEvents: async (parent, args, context) => {
Expand Down Expand Up @@ -291,6 +468,11 @@ const Resolvers = {
return events
},
},
Mutation: {
updateEvent: async (parent, args, context) => {
return context.controller('Event').update(args._id, args.event)
},
},
Event: {
organizations: parent => {
return parent.organizations.map(orgId =>
Expand Down Expand Up @@ -326,6 +508,7 @@ const Resolvers = {

module.exports = {
QueryType,
MutationType,
Resolvers,
Types: {
EventType,
Expand Down
5 changes: 5 additions & 0 deletions backend/modules/event/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const RegistrationConfigSchema = require('@hackjunction/shared/schemas/Registrat
const AddressSchema = require('@hackjunction/shared/schemas/Address')
const WebhookSchema = require('@hackjunction/shared/schemas/Webhook')
const EventThemeSchema = require('@hackjunction/shared/schemas/EventTheme')
const EventTimelineSchema = require('@hackjunction/shared/schemas/EventTimeline')
const allowPublishPlugin = require('../../common/plugins/allowPublish')
const updateAllowedPlugin = require('../../common/plugins/updateAllowed')
const uploadHelper = require('../upload/helper')
Expand Down Expand Up @@ -189,6 +190,10 @@ const EventSchema = new mongoose.Schema({
type: [WebhookSchema.mongoose],
default: [],
},
eventTimeline: {
type: EventTimelineSchema.mongoose,
default: { items: [] },
},
metaDescription: {
type: String,
default: '',
Expand Down
25 changes: 23 additions & 2 deletions backend/modules/organization/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ const {
GraphQLString,
GraphQLNonNull,
GraphQLList,
GraphQLInputObjectType,
} = require('graphql')

const { CloudinaryImage } = require('../graphql-shared-types')

const OrganizationType = new GraphQLObjectType({
name: 'Organization',
fields: () => {
Expand Down Expand Up @@ -35,6 +34,27 @@ const OrganizationType = new GraphQLObjectType({
},
})

const graphqlInput = new GraphQLInputObjectType({
name: 'OrganizationInput',
fields: {
name: {
type: GraphQLNonNull(GraphQLString),
},
slug: {
type: GraphQLNonNull(GraphQLString),
},
about: {
type: GraphQLString,
},
link: {
type: GraphQLString,
},
icon: {
type: GraphQLString,
},
},
})

const QueryType = new GraphQLObjectType({
name: 'Query',
fields: {
Expand Down Expand Up @@ -80,4 +100,5 @@ module.exports = {
QueryType,
Resolvers,
OrganizationType,
graphqlInput,
}
Loading