Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions backend/models/checkIn.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import mongoose from 'mongoose';
mongoose.Promise = global.Promise;

const checkInSchema = mongoose.Schema({
userId: { type: String },
eventId: { type: String },
userId: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
eventId: { type: mongoose.Schema.Types.ObjectId, ref: 'Event' },
checkedIn: { type: Boolean, default: true },
createdDate: { type: Date, default: Date.now },
});
Expand Down
4 changes: 2 additions & 2 deletions backend/models/event.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ const eventSchema = mongoose.Schema({
checkInReady: { type: Boolean, default: false }, // is the event open for check-ins?
videoConferenceLink: { type: String }, // can be same or different from project
owner: {
ownerId: { type: Number } // id of user who created event
ownerId: { type: mongoose.Schema.Types.ObjectId, ref: 'User' } // id of user who created event
},
recurringEventLink: { // only populated if this event was created from a RecurringEvent
recurringEventId: { type: String }
recurringEventId: { type: mongoose.Schema.Types.ObjectId, ref: 'RecurringEvent' }
}
});

Expand Down
2 changes: 1 addition & 1 deletion backend/models/project.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const projectSchema = mongoose.Schema({
lookingDescription: { type: String }, // narrative on what the project is looking for
recruitingCategories: [{ type: String }], // same as global Skills picklist
partners: [{ type: String }], // any third-party partners on the project, e.g. City of LA
managedByUsers: [{ type: String }], // Which users may manage this project.
managedByUsers: [{ type: mongoose.Schema.Types.ObjectId, ref: 'User' }], // Which users may manage this project.
onboardOffboardVisible: { type: Boolean, default: true }, // Whether onboarding/offboarding forms are visible on the project page
});

Expand Down
4 changes: 2 additions & 2 deletions backend/models/projectTeamMember.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Idea for the future: numberGithubContributions (pull this from github?)
*/

const projectTeamMemberSchema = mongoose.Schema({
userId: { type: String }, // id of the user
projectId: { type: String }, // id of the project
userId: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, // id of the user
projectId: { type: mongoose.Schema.Types.ObjectId, ref: 'Project' }, // id of the project
teamMemberStatus: { type: String }, // Active or Inactive
vrmsProjectAdmin: { type: Boolean }, // does this team member have admin rights to the project in VRMS?
roleOnProject: { type: String }, // Developer, Project Manager, UX, Data Science
Expand Down
2 changes: 1 addition & 1 deletion backend/models/recurringEvent.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const recurringEventSchema = mongoose.Schema({
checkInReady: { type: Boolean, default: false }, // is the event open for check-ins?
videoConferenceLink: { type: String }, // can be same or different from project
owner: {
ownerId: { type: String, default: '123456' } // id of user who created event
ownerId: { type: mongoose.Schema.Types.ObjectId, ref: 'User' } // id of user who created event
}
});

Expand Down
2 changes: 1 addition & 1 deletion backend/models/user.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const userSchema = mongoose.Schema({
isHflaGithubMember: { type: Boolean }, // pull from API once github handle in place?
githubPublic2FA: { type: Boolean }, // does the user have 2FA enabled on their github and membership set to public?
availability: { type: String }, // availability to meet outside of hacknight times; string for now, more structured in future
managedProjects: [{ type: String }], // Which projects managed by user.
managedProjects: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Project' }], // Which projects managed by user.
//currentProject: { type: String } // no longer need this as we can get it from Project Team Member table
// password: { type: String, required: true }
isActive: { type: Boolean, default: true },
Expand Down
10 changes: 6 additions & 4 deletions backend/models/user.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeAll, beforeEach, afterAll, afterEach, test } from 'vitest';
import mongoose from 'mongoose';
import { User } from './user.model.js';
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, test, vi } from 'vitest';
import { setupIntegrationDB } from '../setup-test.js';
import { User } from './user.model.js';

setupIntegrationDB('user-model');

Expand Down Expand Up @@ -69,7 +69,7 @@ describe('User Model - Serialization', () => {
isHflaGithubMember: true,
githubPublic2FA: false,
availability: 'Evenings',
managedProjects: ['ProjectGamma'],
managedProjects: [new mongoose.Types.ObjectId()],
isActive: true,
createdDate: new Date(2023, 0, 15),
};
Expand All @@ -93,7 +93,9 @@ describe('User Model - Serialization', () => {
expect(serializedUser.isHflaGithubMember).toBe(userData.isHflaGithubMember);
expect(serializedUser.githubPublic2FA).toBe(userData.githubPublic2FA);
expect(serializedUser.availability).toBe(userData.availability);
expect([...serializedUser.managedProjects]).toEqual(userData.managedProjects);
expect(serializedUser.managedProjects.map(String)).toEqual(
userData.managedProjects.map(String),
);
expect(serializedUser.isActive).toBe(userData.isActive);
});
});
Expand Down