Skip to content

Commit

Permalink
[premieroctet#74] - add enum private public to event schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Batiste1998 committed Aug 30, 2024
1 parent 928d00f commit 2dee05b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
10 changes: 9 additions & 1 deletion backend/web/server/plugins/cyberleague/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,20 @@ const CONTENT_VISIBILITY = {
[CONTENT_PUBLIC]: 'public'
}

const EVENT_VISIBILITY_PRIVATE = 'EVENT_VISIBILITY_PRIVATE'
const EVENT_VISIBILITY_PUBLIC = 'EVENT_VISIBILITY_PUBLIC'

const EVENT_VISIBILITY = {
[EVENT_VISIBILITY_PRIVATE]: 'prive',
[EVENT_VISIBILITY_PUBLIC]: 'public'
}

module.exports = {
DISC_ADMIN, DISC_MEMBER, DISC_PARTNER, DISCRIMINATOR_KEY,
ROLES, ROLE_ADMIN, ROLE_MEMBER, ROLE_PARTNER,
CONTENT_TYPE, CONTENT_TYPE_ARTICLE, CONTENT_TYPE_GUIDE, CONTENT_TYPE_PODCAST, CONTENT_TYPE_VIDEO,
SECTOR,
CATEGORIES, CATEGORY_THREAT_ANALYSIS, CATEGORY_NETWORK_SECURITY, CATEGORY_CRYPTOGRAPHY, CATEGORY_APP_SECURITY, CATEGORY_FORENSIC, CATEGORY_ACCESS_AND_IDENTITY_MANAGEMENT, CATEGORY_CONFORMITY_AND_CONTROL, CATEGORY_CLOUD_SECURITY, CATEGORY_SYSTEM_SECURITY, CATEGORY_SENSITIZATION_AND_FORMATION, CATEGORY_EMERGING_SAFETY_TECHNOLOGIES, CATEGORY_INCIDENT_MANAGEMENT, CATEGORY_SECURITY_POLICY_DESIGN, CATEGORY_ICS_SCADA, CATEGORY_EVENT_AND_COMMUNITY, CATEGORY_ACCESS_AND_IDENTITY_MANAGEMENT_ADVANCED, CATEGORY_ENDPOINTS_SECURITY, CATEGORY_DATA_SECURITY, CATEGORY_NETWORK_SECURITY_ADVANCED, CATEGORY_SYSTEM_ARCHITECTURE_SECURITY, CATEGORY_INTERNAL_THREAT_PROTECTION, CATEGORY_CRISIS_MANAGEMENT, CATEGORY_APP_AND_DEVOPS_SECURITY, CATEGORY_CLOUD_AND_VIRTUAL_ENVIRONMENT_SECURITY, CATEGORY_COMPLIANCE_MANAGEMENT, CATEGORY_ATD_ATR, CATEGORY_SOCIAL_NETWORK_AND_REPUTATION_SECURITY, CATEGORY_FINANCIAL_SECURITY, CATEGORY_R_AND_D_SECURITY,
JOBS, JOB_GENERAL_MANAGER, JOB_DIGITAL_MANAGER, JOB_IT, JOB_FINANCIAL_MANAGER, JOB_GENERAL_COUNSEL, JOB_COMMERCIAL_MANAGER, JOB_MARKETING_MANAGER, JOB_STUDENT, JOB_OTHER,
COMPANY_SIZE, ESTIMATED_DURATION_UNITS, ESTIMATED_DURATION_UNIT_JOURS, ESTIMATED_DURATION_UNIT_SEMAINES, ESTIMATED_DURATION_UNIT_MOIS, LOOKING_FOR_MISSION, LOOKING_FOR_MISSION_YES, LOOKING_FOR_MISSION_NO, CONTENT_VISIBILITY, CONTENT_PRIVATE, CONTENT_PUBLIC
COMPANY_SIZE, ESTIMATED_DURATION_UNITS, ESTIMATED_DURATION_UNIT_JOURS, ESTIMATED_DURATION_UNIT_SEMAINES, ESTIMATED_DURATION_UNIT_MOIS, LOOKING_FOR_MISSION, LOOKING_FOR_MISSION_YES, LOOKING_FOR_MISSION_NO, CONTENT_VISIBILITY, CONTENT_PRIVATE, CONTENT_PUBLIC, EVENT_VISIBILITY, EVENT_VISIBILITY_PRIVATE, EVENT_VISIBILITY_PUBLIC
}
5 changes: 4 additions & 1 deletion backend/web/server/plugins/cyberleague/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {
setPostPutData,
idEqual,
} = require('../../utils/database')
const { ROLES, SECTOR, CATEGORIES, CONTENT_TYPE, JOBS, COMPANY_SIZE, ROLE_PARTNER, ROLE_ADMIN, ROLE_MEMBER, ESTIMATED_DURATION_UNITS, LOOKING_FOR_MISSION, CONTENT_VISIBILITY } = require('./consts')
const { ROLES, SECTOR, CATEGORIES, CONTENT_TYPE, JOBS, COMPANY_SIZE, ROLE_PARTNER, ROLE_ADMIN, ROLE_MEMBER, ESTIMATED_DURATION_UNITS, LOOKING_FOR_MISSION, CONTENT_VISIBILITY, EVENT_VISIBILITY } = require('./consts')
const { PURCHASE_STATUS } = require('../../../utils/consts')
const Company = require('../../models/Company')
const { BadRequestError } = require('../../utils/errors')
Expand Down Expand Up @@ -158,6 +158,9 @@ declareVirtualField({model: 'group', field: 'users_count', instance: 'Number'})

//Partner declarations

// Event declarations
declareEnumField({model: 'event', field: 'visibility', enumValues: EVENT_VISIBILITY})

// Enums Mission Schema
declareEnumField({model: 'mission', field: 'estimation_duration_unit', enumValues: ESTIMATED_DURATION_UNITS})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const mongoose = require('mongoose')
const { schemaOptions } = require('../../../utils/schemas')
const { EVENT_VISIBILITY, EVENT_VISIBILITY_PUBLIC } = require('../consts')

const Schema = mongoose.Schema

Expand Down Expand Up @@ -46,7 +47,13 @@ const EventSchema = new Schema({
replay_url: {
type: String,
required: false
}
},
visibility: {
type: String,
enum: Object.keys(EVENT_VISIBILITY),
required: true,
default: EVENT_VISIBILITY_PUBLIC,
},
}, schemaOptions)

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

0 comments on commit 2dee05b

Please sign in to comment.