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
68 changes: 37 additions & 31 deletions src/backend/src/controllers/organizations.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,6 @@ export default class OrganizationsController {
}
}

static async setImages(req: Request, res: Response, next: NextFunction) {
try {
const { applyInterestImage = [], exploreAsGuestImage = [] } = req.files as {
applyInterestImage?: Express.Multer.File[];
exploreAsGuestImage?: Express.Multer.File[];
};

const applyInterestFile = applyInterestImage[0] || null;
const exploreAsGuestFile = exploreAsGuestImage[0] || null;

const newImages = await OrganizationsService.setImages(
applyInterestFile,
exploreAsGuestFile,
req.currentUser,
req.organization
);

res.status(200).json(newImages);
} catch (error: unknown) {
next(error);
}
}
static async getAllUsefulLinks(req: Request, res: Response, next: NextFunction) {
try {
const links = await OrganizationsService.getAllUsefulLinks(req.organization.organizationId);
Expand Down Expand Up @@ -97,15 +75,6 @@ export default class OrganizationsController {
}
}

static async getOrganizationImages(req: Request, res: Response, next: NextFunction) {
try {
const images = await OrganizationsService.getOrganizationImages(req.organization.organizationId);
res.status(200).json(images);
} catch (error: unknown) {
next(error);
}
}

static async setOrganizationFeaturedProjects(req: Request, res: Response, next: NextFunction) {
try {
const { projectIds } = req.body;
Expand Down Expand Up @@ -142,6 +111,29 @@ export default class OrganizationsController {
}
}

static async setPlatformLogoImage(req: Request, res: Response, next: NextFunction) {
try {
if (!req.file) {
throw new HttpException(400, 'Invalid or undefined image data');
}

const updatedOrg = await OrganizationsService.setPlatformLogoImage(req.file, req.currentUser, req.organization);

res.status(200).json(updatedOrg);
} catch (error: unknown) {
next(error);
}
}

static async getPlatformLogoImage(req: Request, res: Response, next: NextFunction) {
try {
const platformLogoImageId = await OrganizationsService.getPlatformLogoImage(req.organization.organizationId);
res.status(200).json(platformLogoImageId);
} catch (error: unknown) {
next(error);
}
}

static async setNewMemberImage(req: Request, res: Response, next: NextFunction) {
try {
if (!req.file) {
Expand Down Expand Up @@ -181,6 +173,20 @@ export default class OrganizationsController {
}
}

static async setPlatformDescription(req: Request, res: Response, next: NextFunction) {
try {
const updatedOrg = await OrganizationsService.setPlatformDescription(
req.body.platformDescription,
req.currentUser,
req.organization
);

res.status(200).json(updatedOrg);
} catch (error: unknown) {
next(error);
}
}

static async getOrganizationFeaturedProjects(req: Request, res: Response, next: NextFunction) {
try {
const featuredProjects = await OrganizationsService.getOrganizationFeaturedProjects(req.organization.organizationId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
Warnings:

- You are about to drop the column `applyInterestImageId` on the `Organization` table. All the data in the column will be lost.
- You are about to drop the column `exploreAsGuestImageId` on the `Organization` table. All the data in the column will be lost.

*/
-- AlterTable
ALTER TABLE "Organization" DROP COLUMN "applyInterestImageId",
DROP COLUMN "exploreAsGuestImageId",
ADD COLUMN "platformDescription" TEXT NOT NULL DEFAULT '',
ADD COLUMN "platformLogoImageId" TEXT;
18 changes: 9 additions & 9 deletions src/backend/src/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -1027,12 +1027,12 @@ enum DayOfWeek {
}

model Schedule_Slot {
scheduleSlotId String @id @default(uuid())
startTime DateTime
endTime DateTime
allDay Boolean @default(false)
eventId String
event Event @relation(fields: [eventId], references: [eventId])
scheduleSlotId String @id @default(uuid())
startTime DateTime
endTime DateTime
allDay Boolean @default(false)
eventId String
event Event @relation(fields: [eventId], references: [eventId])

@@index([endTime])
@@index([startTime])
Expand Down Expand Up @@ -1088,7 +1088,7 @@ model Event {
shops Shop[]
machinery Machinery[]
workPackages Work_Package[]
documents Document[]
documents Document[]
status Event_Status
initialDateScheduled DateTime?
questionDocumentLink String?
Expand Down Expand Up @@ -1312,8 +1312,6 @@ model Organization {
advisor User? @relation(name: "advisor", fields: [advisorId], references: [userId])
advisorId String?
description String @default("")
applyInterestImageId String?
exploreAsGuestImageId String?
newMemberImageId String?
logoImageId String?
slackWorkspaceId String?
Expand All @@ -1322,6 +1320,8 @@ model Organization {
partReviewSampleImageId String?
partReviewGuideLink String?
sponsorshipNotificationsSlackChannelId String?
platformDescription String @default("")
platformLogoImageId String?

// Relation references
wbsElements WBS_Element[]
Expand Down
15 changes: 15 additions & 0 deletions src/backend/src/prisma/seed-data/users.seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ const joeBlow: Prisma.UserCreateInput = {
}
};

const guestUser: Prisma.UserCreateInput = {
firstName: 'Guest',
lastName: 'User',
googleAuthId: 'guest-google-id',
email: 'guest@husky.neu.edu',
emailId: 'guest',
userSettings: {
create: {
defaultTheme: Theme.DARK,
slackId: SLACK_ID ? SLACK_ID : 'guest'
}
}
};

const wonderwoman: Prisma.UserCreateInput = {
firstName: 'Diana',
lastName: 'Prince',
Expand Down Expand Up @@ -994,6 +1008,7 @@ export const dbSeedAllUsers = {
thomasEmrax,
joeShmoe,
joeBlow,
guestUser,
wonderwoman,
flash,
aquaman,
Expand Down
20 changes: 8 additions & 12 deletions src/backend/src/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ const performSeed: () => Promise<void> = async () => {
userCreatedId: thomasEmrax.userId,
description:
'Northeastern Electric Racing is a student-run organization at Northeastern University building all-electric formula-style race cars from scratch to compete in Forumla Hybrid + Electric Formula SAE (FSAE).',
applyInterestImageId: '1_iak6ord4JP9TcR1sOYopyEs6EjTKQpw',
exploreAsGuestImageId: '1wRes7V_bMm9W7_3JCIDXYkMUiy6B3wRI',
applicationLink:
'https://docs.google.com/forms/d/e/1FAIpQLSeCvG7GqmZm_gmSZiahbVTW9ZFpEWG0YfGQbkSB_whhHzxXpA/closedform'
'https://docs.google.com/forms/d/e/1FAIpQLSeCvG7GqmZm_gmSZiahbVTW9ZFpEWG0YfGQbkSB_whhHzxXpA/closedform',
platformDescription:
'Finishline is a Project Management Dashboard developed by the Software Team at Northeastern Electric Racing.',
platformLogoImageId: '1auQO3GYydZOo1-vCn0D2iyCfaxaVFssx'
}
});

Expand Down Expand Up @@ -264,6 +265,7 @@ const performSeed: () => Promise<void> = async () => {
const regina = await createUser(dbSeedAllUsers.regina, RoleEnum.MEMBER, organizationId);
const patrick = await createUser(dbSeedAllUsers.patrick, RoleEnum.MEMBER, organizationId);
const spongebob = await createUser(dbSeedAllUsers.spongebob, RoleEnum.MEMBER, organizationId);
await createUser(dbSeedAllUsers.guestUser, RoleEnum.GUEST, organizationId);

await UsersService.updateUserRole(cyborg.userId, thomasEmrax, 'APP_ADMIN', ner);

Expand Down Expand Up @@ -367,21 +369,15 @@ const performSeed: () => Promise<void> = async () => {
const mechanical = await TeamsService.createTeamType(
batman,
'Mechanical',
'YouTubeIcon',
'Construction',
'This is the mechanical team',
ner
);
const software = await TeamsService.createTeamType(
thomasEmrax,
'Software',
'InstagramIcon',
'This is the software team',
ner
);
const software = await TeamsService.createTeamType(thomasEmrax, 'Software', 'Code', 'This is the software team', ner);
const electrical = await TeamsService.createTeamType(
cyborg,
'Electrical',
'SettingsIcon',
'ElectricBolt',
'This is the electrical team',
ner
);
Expand Down
22 changes: 14 additions & 8 deletions src/backend/src/routes/organizations.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ const upload = multer({ limits: { fileSize: MAX_FILE_SIZE }, storage: memoryStor
organizationRouter.get('/current', OrganizationsController.getCurrentOrganization);
organizationRouter.post('/useful-links/set', ...linkValidators, validateInputs, OrganizationsController.setUsefulLinks);
organizationRouter.get('/useful-links', OrganizationsController.getAllUsefulLinks);
organizationRouter.post(
'/images/update',
upload.fields([
{ name: 'applyInterestImage', maxCount: 1 },
{ name: 'exploreAsGuestImage', maxCount: 1 }
]),
OrganizationsController.setImages
);

organizationRouter.post(
'/application-link/update',
Expand Down Expand Up @@ -51,6 +43,14 @@ organizationRouter.post(
);
organizationRouter.post('/logo/update', upload.single('logo'), OrganizationsController.setLogoImage);
organizationRouter.get('/logo', OrganizationsController.getOrganizationLogoImage);

organizationRouter.post(
'/platform-logo/update',
upload.single('platformLogo'),
OrganizationsController.setPlatformLogoImage
);
organizationRouter.get('/platform-logo', OrganizationsController.getPlatformLogoImage);

organizationRouter.post(
'/new-member-image/update',
upload.single('newMemberImage'),
Expand All @@ -63,6 +63,12 @@ organizationRouter.post(
validateInputs,
OrganizationsController.setOrganizationDescription
);
organizationRouter.post(
'/platform-description/set',
body('platformDescription').isString(),
validateInputs,
OrganizationsController.setPlatformDescription
);
organizationRouter.get('/featured-projects', OrganizationsController.getOrganizationFeaturedProjects);
organizationRouter.post(
'/workspaceId/set',
Expand Down
Loading