Skip to content

Commit 1f34158

Browse files
committed
#3873 - removed applyInterestImageId and exploreAsGuestImageId
1 parent 58041bf commit 1f34158

15 files changed

Lines changed: 16 additions & 377 deletions

File tree

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

Lines changed: 0 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;

src/backend/src/prisma/migrations/20260211034109_guest_home_page/migration.sql

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
-- AlterTable
9+
ALTER TABLE "Organization" DROP COLUMN "applyInterestImageId",
10+
DROP COLUMN "exploreAsGuestImageId",
11+
ADD COLUMN "finishlineDescription" TEXT NOT NULL DEFAULT '',
12+
ADD COLUMN "finishlineLogo" TEXT;

src/backend/src/prisma/schema.prisma

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,8 +1312,6 @@ model Organization {
13121312
advisor User? @relation(name: "advisor", fields: [advisorId], references: [userId])
13131313
advisorId String?
13141314
description String @default("")
1315-
applyInterestImageId String?
1316-
exploreAsGuestImageId String?
13171315
newMemberImageId String?
13181316
logoImageId String?
13191317
slackWorkspaceId String?

src/backend/src/prisma/seed.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ 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:
131129
'https://docs.google.com/forms/d/e/1FAIpQLSeCvG7GqmZm_gmSZiahbVTW9ZFpEWG0YfGQbkSB_whhHzxXpA/closedform',
132130
finishlineDescription:

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

Lines changed: 0 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',

src/backend/src/services/organizations.services.ts

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -104,37 +104,6 @@ export default class OrganizationsService {
104104
return newLinks;
105105
}
106106

107-
/**
108-
* sets an organizations images
109-
* @param submitter the user who is setting the images
110-
* @param organizationId the organization which the images will be set up
111-
* @param images the images which are being set
112-
*/
113-
static async setImages(
114-
applyInterestImage: Express.Multer.File | null,
115-
exploreAsGuestImage: Express.Multer.File | null,
116-
submitter: User,
117-
organization: Organization
118-
) {
119-
if (!(await userHasPermission(submitter.userId, organization.organizationId, isAdmin))) {
120-
throw new AccessDeniedAdminOnlyException('update images');
121-
}
122-
123-
const applyInterestImageData = applyInterestImage ? await uploadFile(applyInterestImage) : null;
124-
const exploreAsGuestImageData = exploreAsGuestImage ? await uploadFile(exploreAsGuestImage) : null;
125-
const updateData = {
126-
...(applyInterestImageData && { applyInterestImageId: applyInterestImageData.id }),
127-
...(exploreAsGuestImageData && { exploreAsGuestImageId: exploreAsGuestImageData.id })
128-
};
129-
130-
const newImages = await prisma.organization.update({
131-
where: { organizationId: organization.organizationId },
132-
data: updateData
133-
});
134-
135-
return newImages;
136-
}
137-
138107
/**
139108
Gets all the useful links for an organization
140109
@param organizationId the organization to get the links for
@@ -255,26 +224,6 @@ export default class OrganizationsService {
255224
return updatedOrganization;
256225
}
257226

258-
/**
259-
* Gets all organization Images for the given organization Id
260-
* @param organizationId organization Id of the milestone
261-
* @returns all the milestones from the given organization
262-
*/
263-
static async getOrganizationImages(organizationId: string) {
264-
const organization = await prisma.organization.findUnique({
265-
where: { organizationId }
266-
});
267-
268-
if (!organization) {
269-
throw new NotFoundException('Organization', organizationId);
270-
}
271-
272-
return {
273-
applyInterestImage: organization.applyInterestImageId,
274-
exploreAsGuestImage: organization.exploreAsGuestImageId
275-
};
276-
}
277-
278227
/**
279228
* Updates the featured projects of an organization
280229
* @param projectIds project ids of featured projects

src/backend/src/transformers/organizationTransformer.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ export const organizationTransformer = (organization: Organization): Organizatio
55
return {
66
...organization,
77
applicationLink: organization.applicationLink ?? undefined,
8-
applyInterestImageId: organization.applyInterestImageId ?? undefined,
9-
exploreAsGuestImageId: organization.exploreAsGuestImageId ?? undefined,
108
newMemberImageId: organization.newMemberImageId ?? undefined
119
};
1210
};

src/backend/tests/unit/organization.test.ts

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -42,46 +42,6 @@ describe('Organization Tests', () => {
4242
});
4343
});
4444

45-
describe('Set Images', () => {
46-
const file1 = { originalname: 'image1.png' } as Express.Multer.File;
47-
const file2 = { originalname: 'image2.png' } as Express.Multer.File;
48-
const file3 = { originalname: 'image3.png' } as Express.Multer.File;
49-
it('Fails if user is not an admin', async () => {
50-
await expect(
51-
OrganizationsService.setImages(file1, file2, await createTestUser(wonderwomanGuest, orgId), organization)
52-
).rejects.toThrow(new AccessDeniedAdminOnlyException('update images'));
53-
});
54-
55-
it('Succeeds and updates all the images', async () => {
56-
const testBatman = await createTestUser(batmanAppAdmin, orgId);
57-
(uploadFile as Mock).mockImplementation((file) => {
58-
return Promise.resolve({ name: `${file.originalname}`, id: `uploaded-${file.originalname}` });
59-
});
60-
61-
await OrganizationsService.setImages(file1, file2, testBatman, organization);
62-
63-
const oldOrganization = await prisma.organization.findUnique({
64-
where: {
65-
organizationId: orgId
66-
}
67-
});
68-
69-
expect(oldOrganization).not.toBeNull();
70-
expect(oldOrganization?.applyInterestImageId).toBe('uploaded-image1.png');
71-
expect(oldOrganization?.exploreAsGuestImageId).toBe('uploaded-image2.png');
72-
73-
await OrganizationsService.setImages(file1, file3, testBatman, organization);
74-
75-
const updatedOrganization = await prisma.organization.findUnique({
76-
where: {
77-
organizationId: orgId
78-
}
79-
});
80-
81-
expect(updatedOrganization?.exploreAsGuestImageId).toBe('uploaded-image3.png');
82-
});
83-
});
84-
8545
describe('Set Useful Links', () => {
8646
it('Fails if user is not an admin', async () => {
8747
await expect(
@@ -204,30 +164,6 @@ describe('Organization Tests', () => {
204164
});
205165
});
206166

207-
describe('Get Organization Images', () => {
208-
it('Fails if an organization does not exist', async () => {
209-
await expect(async () => await OrganizationsService.getOrganizationImages('1')).rejects.toThrow(
210-
new NotFoundException('Organization', '1')
211-
);
212-
});
213-
214-
it('Succeeds and gets all the images', async () => {
215-
const testBatman = await createTestUser(batmanAppAdmin, orgId);
216-
await createTestLinkType(testBatman, orgId);
217-
await OrganizationsService.setImages(
218-
{ originalname: 'image1.png' } as Express.Multer.File,
219-
{ originalname: 'image2.png' } as Express.Multer.File,
220-
testBatman,
221-
organization
222-
);
223-
const images = await OrganizationsService.getOrganizationImages(orgId);
224-
225-
expect(images).not.toBeNull();
226-
expect(images.applyInterestImage).toBe('uploaded-image1.png');
227-
expect(images.exploreAsGuestImage).toBe('uploaded-image2.png');
228-
});
229-
});
230-
231167
describe('Set Logo', () => {
232168
const file1 = { originalname: 'image1.png' } as Express.Multer.File;
233169
const file2 = { originalname: 'image2.png' } as Express.Multer.File;

src/backend/tests/unmocked/organization.test.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -42,46 +42,6 @@ describe('Organization Tests', () => {
4242
});
4343
});
4444

45-
describe('Set Images', () => {
46-
const file1 = { originalname: 'image1.png' } as Express.Multer.File;
47-
const file2 = { originalname: 'image2.png' } as Express.Multer.File;
48-
const file3 = { originalname: 'image3.png' } as Express.Multer.File;
49-
it('Fails if user is not an admin', async () => {
50-
await expect(
51-
OrganizationsService.setImages(file1, file2, await createTestUser(wonderwomanGuest, orgId), organization)
52-
).rejects.toThrow(new AccessDeniedAdminOnlyException('update images'));
53-
});
54-
55-
it('Succeeds and updates all the images', async () => {
56-
const testBatman = await createTestUser(batmanAppAdmin, orgId);
57-
(uploadFile as Mock).mockImplementation((file) => {
58-
return Promise.resolve({ id: `uploaded-${file.originalname}` });
59-
});
60-
61-
await OrganizationsService.setImages(file1, file2, testBatman, organization);
62-
63-
const oldOrganization = await prisma.organization.findUnique({
64-
where: {
65-
organizationId: orgId
66-
}
67-
});
68-
69-
expect(oldOrganization).not.toBeNull();
70-
expect(oldOrganization?.applyInterestImageId).toBe('uploaded-image1.png');
71-
expect(oldOrganization?.exploreAsGuestImageId).toBe('uploaded-image2.png');
72-
73-
await OrganizationsService.setImages(file1, file3, testBatman, organization);
74-
75-
const updatedOrganization = await prisma.organization.findUnique({
76-
where: {
77-
organizationId: orgId
78-
}
79-
});
80-
81-
expect(updatedOrganization?.exploreAsGuestImageId).toBe('uploaded-image3.png');
82-
});
83-
});
84-
8545
describe('Set Useful Links', () => {
8646
it('Fails if user is not an admin', async () => {
8747
await expect(

0 commit comments

Comments
 (0)