Skip to content

Commit

Permalink
EDF: [premieroctet#175] change unknown_email field to unknown_tickets…
Browse files Browse the repository at this point in the history
… in order schema
  • Loading branch information
Bastien-Wappizy committed Dec 26, 2024
1 parent 6ff979a commit 33f8908
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backend/web/server/plugins/entreprisedufutur/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ declareVirtualField({model: 'order', field: 'order_tickets', multiple: true, ins
}
})
declareVirtualField({model: 'order', field: 'order_tickets_count', instance: 'Number'})
declareComputedField({model: 'order', field: 'unknown_emails', getterFn: getUnknownEmails})
declareComputedField({model: 'order', field: 'unknown_tickets', getterFn: getUnknownEmails})
declareComputedField({model: 'order', field: 'are_inputs_valid', getterFn: getInputsValid})

//OrderTicket declarations
Expand Down
3 changes: 2 additions & 1 deletion backend/web/server/plugins/entreprisedufutur/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const getUnknownEmails = async (userId, params, data) => {
const exist = await User.exists({email:t.email})
return !exist
})
return unknownEmailTickets.map(ticket => ticket.email)

return unknownEmailTickets.map(ticket => new OrderTicket(ticket))
}

const getInputsValid = async (userId, params, data) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ const OrderSchema = new Schema({
enum:Object.keys(ORDER_STATUSES),
required: [true, `Le statut de la commande est obligatoire`]
},
unknown_emails: {
unknown_tickets: {
//computed
type: [{
type: String,
type: Schema.Types.ObjectId,
ref: 'userTicket',
required: true
}],
default: []
Expand Down

0 comments on commit 33f8908

Please sign in to comment.