Skip to content

Commit

Permalink
EDF: [premieroctet#177] add reservable tickets computed field in even…
Browse files Browse the repository at this point in the history
…t schema
  • Loading branch information
Bastien-Wappizy committed Dec 30, 2024
1 parent 4646db5 commit b5a966c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backend/web/server/plugins/entreprisedufutur/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const { getTagUrl } = require('../../utils/mailing')
const { getterPartnerList } = require('./admin_dashboard')
const { getUnknownEmails, getInputsValid } = require('./order')
const AdminDashboard = require('../../models/AdminDashboard')
const { getRegistered, getRegisteredNumber } = require('./event')
const { getRegistered, getRegisteredNumber, getReservableTickets } = require('./event')

//Notification plugin setup
setAllowedTypes(NOTIFICATION_TYPES)
Expand Down Expand Up @@ -422,6 +422,7 @@ declareVirtualField({model: 'event', field: 'status', requires: 'start_date', in
})
declareComputedField({model: 'event', field: 'registered_users', getterFn: getRegistered})
declareComputedField({model: 'event', field: 'registered_users_count', getterFn: getRegisteredNumber})
declareComputedField({model: 'event', field: 'reservable_tickets', getterFn: getReservableTickets})

// Mission declaration
declareEnumField({model: 'mission', field: 'estimation_duration_unit', enumValues: ESTIMATED_DURATION_UNITS})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,15 @@ const EventSchema = new Schema({
required: false,
default: []
},
reservable_tickets: {
//computed
type: [{
type: Schema.Types.ObjectId,
ref: 'eventTickets',
required: true
}],
default: [],
},
}, schemaOptions)

/* eslint-disable prefer-arrow-callback */
Expand Down

0 comments on commit b5a966c

Please sign in to comment.