Skip to content

Commit 94a33d3

Browse files
authored
Merge pull request #3971 from Northeastern-Electric-Racing/#3873-guest-home-page
#3873 guest home page
2 parents 90e509b + 15d33a9 commit 94a33d3

32 files changed

Lines changed: 716 additions & 592 deletions

src/backend/src/controllers/organizations.controllers.ts

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,6 @@ export default class OrganizationsController {
2222
}
2323
}
2424

25-
static async setImages(req: Request, res: Response, next: NextFunction) {
26-
try {
27-
const { applyInterestImage = [], exploreAsGuestImage = [] } = req.files as {
28-
applyInterestImage?: Express.Multer.File[];
29-
exploreAsGuestImage?: Express.Multer.File[];
30-
};
31-
32-
const applyInterestFile = applyInterestImage[0] || null;
33-
const exploreAsGuestFile = exploreAsGuestImage[0] || null;
34-
35-
const newImages = await OrganizationsService.setImages(
36-
applyInterestFile,
37-
exploreAsGuestFile,
38-
req.currentUser,
39-
req.organization
40-
);
41-
42-
res.status(200).json(newImages);
43-
} catch (error: unknown) {
44-
next(error);
45-
}
46-
}
4725
static async getAllUsefulLinks(req: Request, res: Response, next: NextFunction) {
4826
try {
4927
const links = await OrganizationsService.getAllUsefulLinks(req.organization.organizationId);
@@ -97,15 +75,6 @@ export default class OrganizationsController {
9775
}
9876
}
9977

100-
static async getOrganizationImages(req: Request, res: Response, next: NextFunction) {
101-
try {
102-
const images = await OrganizationsService.getOrganizationImages(req.organization.organizationId);
103-
res.status(200).json(images);
104-
} catch (error: unknown) {
105-
next(error);
106-
}
107-
}
108-
10978
static async setOrganizationFeaturedProjects(req: Request, res: Response, next: NextFunction) {
11079
try {
11180
const { projectIds } = req.body;
@@ -142,6 +111,20 @@ export default class OrganizationsController {
142111
}
143112
}
144113

114+
static async setPlatformLogoImage(req: Request, res: Response, next: NextFunction) {
115+
try {
116+
if (!req.file) {
117+
throw new HttpException(400, 'Invalid or undefined image data');
118+
}
119+
120+
const updatedOrg = await OrganizationsService.setPlatformLogoImage(req.file, req.currentUser, req.organization);
121+
122+
res.status(200).json(updatedOrg);
123+
} catch (error: unknown) {
124+
next(error);
125+
}
126+
}
127+
145128
static async setNewMemberImage(req: Request, res: Response, next: NextFunction) {
146129
try {
147130
if (!req.file) {
@@ -181,6 +164,20 @@ export default class OrganizationsController {
181164
}
182165
}
183166

167+
static async setPlatformDescription(req: Request, res: Response, next: NextFunction) {
168+
try {
169+
const updatedOrg = await OrganizationsService.setPlatformDescription(
170+
req.body.platformDescription,
171+
req.currentUser,
172+
req.organization
173+
);
174+
175+
res.status(200).json(updatedOrg);
176+
} catch (error: unknown) {
177+
next(error);
178+
}
179+
}
180+
184181
static async getOrganizationFeaturedProjects(req: Request, res: Response, next: NextFunction) {
185182
try {
186183
const featuredProjects = await OrganizationsService.getOrganizationFeaturedProjects(req.organization.organizationId);

src/backend/src/controllers/projects.controllers.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,16 @@ export default class ProjectsController {
166166

167167
static async createLinkType(req: Request, res: Response, next: NextFunction) {
168168
try {
169-
const { name, iconName, required } = req.body;
169+
const { name, iconName, required, isOnGuestHomePage } = req.body;
170170

171-
const newLinkType = await ProjectsService.createLinkType(req.currentUser, name, iconName, required, req.organization);
171+
const newLinkType = await ProjectsService.createLinkType(
172+
req.currentUser,
173+
name,
174+
iconName,
175+
required,
176+
req.organization,
177+
isOnGuestHomePage
178+
);
172179
res.status(200).json(newLinkType);
173180
} catch (error: unknown) {
174181
next(error);
@@ -449,13 +456,14 @@ export default class ProjectsController {
449456
static async editLinkType(req: Request, res: Response, next: NextFunction) {
450457
try {
451458
const { linkTypeName } = req.params as Record<string, string>;
452-
const { name: newName, iconName, required } = req.body;
459+
const { name: newName, iconName, required, isOnGuestHomePage } = req.body;
453460
const linkTypeUpdated = await ProjectsService.editLinkType(
454461
linkTypeName,
455462
iconName,
456463
required,
457464
req.currentUser,
458465
req.organization,
466+
isOnGuestHomePage,
459467
newName
460468
);
461469
res.status(200).json(linkTypeUpdated);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `applyInterestImageId` on the `Organization` table. All the data in the column will be lost.
5+
- You are about to drop the column `exploreAsGuestImageId` on the `Organization` table. All the data in the column will be lost.
6+
7+
*/
8+
-- DropForeignKey
9+
ALTER TABLE "Sponsor" DROP CONSTRAINT "Sponsor_sponsorTierId_fkey";
10+
11+
-- AlterTable
12+
ALTER TABLE "Link_Type" ADD COLUMN "isOnGuestHomePage" BOOLEAN NOT NULL DEFAULT false;
13+
14+
-- AlterTable
15+
ALTER TABLE "Organization" DROP COLUMN "applyInterestImageId",
16+
DROP COLUMN "exploreAsGuestImageId",
17+
ADD COLUMN "platformDescription" TEXT NOT NULL DEFAULT '',
18+
ADD COLUMN "platformLogoImageId" TEXT;
19+
20+
-- AlterTable
21+
ALTER TABLE "Sponsor" ALTER COLUMN "valueTypes" DROP DEFAULT;
22+
23+
-- AddForeignKey
24+
ALTER TABLE "Sponsor" ADD CONSTRAINT "Sponsor_sponsorTierId_fkey" FOREIGN KEY ("sponsorTierId") REFERENCES "Sponsor_Tier"("sponsorTierId") ON DELETE SET NULL ON UPDATE CASCADE;

src/backend/src/prisma/schema.prisma

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -599,16 +599,17 @@ model Work_Package {
599599
}
600600

601601
model Link_Type {
602-
id String @id @default(uuid())
603-
name String
604-
dateCreated DateTime @default(now())
605-
iconName String
606-
required Boolean
607-
creatorId String
608-
creator User @relation(name: "linkTypeCreator", fields: [creatorId], references: [userId])
609-
links Link[] @relation(name: "linkTypes")
610-
organizationId String
611-
organization Organization @relation(fields: [organizationId], references: [organizationId])
602+
id String @id @default(uuid())
603+
name String
604+
dateCreated DateTime @default(now())
605+
iconName String
606+
required Boolean
607+
creatorId String
608+
creator User @relation(name: "linkTypeCreator", fields: [creatorId], references: [userId])
609+
links Link[] @relation(name: "linkTypes")
610+
organizationId String
611+
organization Organization @relation(fields: [organizationId], references: [organizationId])
612+
isOnGuestHomePage Boolean @default(false)
612613
613614
@@unique([name, organizationId], name: "uniqueLinkType")
614615
@@index([organizationId])
@@ -1392,8 +1393,6 @@ model Organization {
13921393
advisor User? @relation(name: "advisor", fields: [advisorId], references: [userId])
13931394
advisorId String?
13941395
description String @default("")
1395-
applyInterestImageId String?
1396-
exploreAsGuestImageId String?
13971396
newMemberImageId String?
13981397
logoImageId String?
13991398
slackWorkspaceId String?
@@ -1402,6 +1401,8 @@ model Organization {
14021401
partReviewSampleImageId String?
14031402
partReviewGuideLink String?
14041403
sponsorshipNotificationsSlackChannelId String?
1404+
platformDescription String @default("")
1405+
platformLogoImageId String?
14051406
14061407
// Relation references
14071408
wbsElements WBS_Element[]

src/backend/src/prisma/seed-data/users.seed.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@ const joeBlow: Prisma.UserCreateInput = {
6262
}
6363
};
6464

65+
const guestUser: Prisma.UserCreateInput = {
66+
firstName: 'Guest',
67+
lastName: 'User',
68+
googleAuthId: 'guest-google-id',
69+
email: 'guest@husky.neu.edu',
70+
emailId: 'guest',
71+
userSettings: {
72+
create: {
73+
defaultTheme: Theme.DARK,
74+
slackId: SLACK_ID ? SLACK_ID : 'guest'
75+
}
76+
}
77+
};
78+
6579
const wonderwoman: Prisma.UserCreateInput = {
6680
firstName: 'Diana',
6781
lastName: 'Prince',
@@ -994,6 +1008,7 @@ export const dbSeedAllUsers = {
9941008
thomasEmrax,
9951009
joeShmoe,
9961010
joeBlow,
1011+
guestUser,
9971012
wonderwoman,
9981013
flash,
9991014
aquaman,

src/backend/src/prisma/seed.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,11 @@ const performSeed: () => Promise<void> = async () => {
125125
userCreatedId: thomasEmrax.userId,
126126
description:
127127
'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).',
128-
applyInterestImageId: '1_iak6ord4JP9TcR1sOYopyEs6EjTKQpw',
129-
exploreAsGuestImageId: '1wRes7V_bMm9W7_3JCIDXYkMUiy6B3wRI',
130128
applicationLink:
131-
'https://docs.google.com/forms/d/e/1FAIpQLSeCvG7GqmZm_gmSZiahbVTW9ZFpEWG0YfGQbkSB_whhHzxXpA/closedform'
129+
'https://docs.google.com/forms/d/e/1FAIpQLSeCvG7GqmZm_gmSZiahbVTW9ZFpEWG0YfGQbkSB_whhHzxXpA/closedform',
130+
platformDescription:
131+
'Finishline is a Project Management Dashboard developed by the Software Team at Northeastern Electric Racing.',
132+
platformLogoImageId: '1auQO3GYydZOo1-vCn0D2iyCfaxaVFssx'
132133
}
133134
});
134135

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

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

@@ -367,21 +369,15 @@ const performSeed: () => Promise<void> = async () => {
367369
const mechanical = await TeamsService.createTeamType(
368370
batman,
369371
'Mechanical',
370-
'YouTubeIcon',
372+
'Construction',
371373
'This is the mechanical team',
372374
ner
373375
);
374-
const software = await TeamsService.createTeamType(
375-
thomasEmrax,
376-
'Software',
377-
'InstagramIcon',
378-
'This is the software team',
379-
ner
380-
);
376+
const software = await TeamsService.createTeamType(thomasEmrax, 'Software', 'Code', 'This is the software team', ner);
381377
const electrical = await TeamsService.createTeamType(
382378
cyborg,
383379
'Electrical',
384-
'SettingsIcon',
380+
'ElectricBolt',
385381
'This is the electrical team',
386382
ner
387383
);
@@ -551,15 +547,22 @@ const performSeed: () => Promise<void> = async () => {
551547
);
552548

553549
/** Link Types */
554-
const confluenceLinkType = await ProjectsService.createLinkType(batman, 'Confluence', 'description', true, ner);
550+
const confluenceLinkType = await ProjectsService.createLinkType(batman, 'Confluence', 'description', true, ner, false);
555551

556-
const bomLinkType = await ProjectsService.createLinkType(batman, 'Bill of Materials', 'bar_chart', true, ner);
552+
const bomLinkType = await ProjectsService.createLinkType(batman, 'Bill of Materials', 'bar_chart', true, ner, false);
557553

558-
const mainWebsiteLinkType = await ProjectsService.createLinkType(batman, 'NER Website', 'bar_chart', true, ner);
554+
const mainWebsiteLinkType = await ProjectsService.createLinkType(batman, 'NER Website', 'bar_chart', true, ner, false);
559555

560-
const instagramWebsiteLinkType = await ProjectsService.createLinkType(batman, 'NER Instagram', 'bar_chart', true, ner);
556+
const instagramWebsiteLinkType = await ProjectsService.createLinkType(
557+
batman,
558+
'NER Instagram',
559+
'bar_chart',
560+
true,
561+
ner,
562+
false
563+
);
561564

562-
await ProjectsService.createLinkType(batman, 'Google Drive', 'folder', true, ner);
565+
await ProjectsService.createLinkType(batman, 'Google Drive', 'folder', true, ner, false);
563566

564567
/**
565568
* Projects

src/backend/src/routes/organizations.routes.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ const upload = multer({ limits: { fileSize: MAX_FILE_SIZE }, storage: memoryStor
1111
organizationRouter.get('/current', OrganizationsController.getCurrentOrganization);
1212
organizationRouter.post('/useful-links/set', ...linkValidators, validateInputs, OrganizationsController.setUsefulLinks);
1313
organizationRouter.get('/useful-links', OrganizationsController.getAllUsefulLinks);
14-
organizationRouter.post(
15-
'/images/update',
16-
upload.fields([
17-
{ name: 'applyInterestImage', maxCount: 1 },
18-
{ name: 'exploreAsGuestImage', maxCount: 1 }
19-
]),
20-
OrganizationsController.setImages
21-
);
2214

2315
organizationRouter.post(
2416
'/application-link/update',
@@ -51,6 +43,13 @@ organizationRouter.post(
5143
);
5244
organizationRouter.post('/logo/update', upload.single('logo'), OrganizationsController.setLogoImage);
5345
organizationRouter.get('/logo', OrganizationsController.getOrganizationLogoImage);
46+
47+
organizationRouter.post(
48+
'/platform-logo/update',
49+
upload.single('platformLogo'),
50+
OrganizationsController.setPlatformLogoImage
51+
);
52+
5453
organizationRouter.post(
5554
'/new-member-image/update',
5655
upload.single('newMemberImage'),
@@ -63,6 +62,12 @@ organizationRouter.post(
6362
validateInputs,
6463
OrganizationsController.setOrganizationDescription
6564
);
65+
organizationRouter.post(
66+
'/platform-description/set',
67+
nonEmptyString(body('platformDescription')),
68+
validateInputs,
69+
OrganizationsController.setPlatformDescription
70+
);
6671
organizationRouter.get('/featured-projects', OrganizationsController.getOrganizationFeaturedProjects);
6772
organizationRouter.post(
6873
'/workspaceId/set',

0 commit comments

Comments
 (0)