diff --git a/api/validators/EventControllerRequests.ts b/api/validators/EventControllerRequests.ts index 1a8a1306..11686fb5 100644 --- a/api/validators/EventControllerRequests.ts +++ b/api/validators/EventControllerRequests.ts @@ -35,6 +35,9 @@ export class OptionalEventProperties implements IOptionalEventProperties { @Allow() googleCalendarEvent?: Uuid; + + @Allow() + foodItems?: string; } export class Event extends OptionalEventProperties implements IEvent { diff --git a/migrations/0046-add-food-items-column.ts b/migrations/0046-add-food-items-column.ts new file mode 100644 index 00000000..a7f4f142 --- /dev/null +++ b/migrations/0046-add-food-items-column.ts @@ -0,0 +1,22 @@ +import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; + +const TABLE_NAME = 'Events'; + +export class AddFoodItemsColumn1728959627663 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.addColumn(TABLE_NAME, + new TableColumn({ + name: 'foodItems', + type: 'varchar(255)', + isNullable: true, + })); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.dropColumn(TABLE_NAME, + new TableColumn({ + name: 'foodItems', + type: 'varchar(255)', + })); + } +} diff --git a/models/EventModel.ts b/models/EventModel.ts index 256fa443..ac58c94d 100644 --- a/models/EventModel.ts +++ b/models/EventModel.ts @@ -73,6 +73,9 @@ export class EventModel extends BaseEntity { @Column('varchar', { nullable: true }) googleCalendarEvent: Uuid; + @Column('varchar', { nullable: true }) + foodItems: string; + public getPublicEvent(canSeeAttendanceCode = false): PublicEvent { const publicEvent: PublicEvent = { uuid: this.uuid, @@ -91,6 +94,7 @@ export class EventModel extends BaseEntity { staffPointBonus: this.staffPointBonus, discordEvent: this.discordEvent, googleCalendarEvent: this.googleCalendarEvent, + foodItems: this.foodItems, }; if (canSeeAttendanceCode) publicEvent.attendanceCode = this.attendanceCode; return publicEvent; diff --git a/package.json b/package.json index a3480e32..04363810 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@acmucsd/membership-portal", - "version": "3.6.2", + "version": "3.7.0", "description": "REST API for ACM UCSD's membership portal.", "main": "index.d.ts", "files": [ diff --git a/tests/Seeds.ts b/tests/Seeds.ts index 979db0fc..2530a95c 100644 --- a/tests/Seeds.ts +++ b/tests/Seeds.ts @@ -209,6 +209,7 @@ async function seed(): Promise { ...EventFactory.daysBefore(6), attendanceCode: 'galaxybrain', ...staffed, + foodItems: 'Boba', }); const PAST_HACK_WORKSHOP = EventFactory.fake({ title: 'Hack: Intro to Rust', diff --git a/tests/data/EventFactory.ts b/tests/data/EventFactory.ts index bf6a9d38..ff8338e5 100644 --- a/tests/data/EventFactory.ts +++ b/tests/data/EventFactory.ts @@ -43,6 +43,7 @@ export class EventFactory { thumbnail: FactoryUtils.getRandomImageUrl(), discordEvent: faker.datatype.hexaDecimal(10), googleCalendarEvent: faker.datatype.hexaDecimal(10), + foodItems: null, }); return EventModel.merge(fake, substitute); } diff --git a/tests/event.test.ts b/tests/event.test.ts index ef1d64dd..9161a4c6 100644 --- a/tests/event.test.ts +++ b/tests/event.test.ts @@ -39,6 +39,7 @@ describe('event creation', () => { start: moment().subtract(2, 'hour').toDate(), end: moment().subtract(1, 'hour').toDate(), attendanceCode: 'p4rty', + foodItems: 'Boba', pointValue: 10, }; @@ -57,6 +58,7 @@ describe('event creation', () => { expect(eventResponse.event.committee).toEqual(event.committee); expect(eventResponse.event.start).toEqual(event.start); expect(eventResponse.event.end).toEqual(event.end); + expect(eventResponse.event.foodItems).toEqual(event.foodItems); expect(eventResponse.event.pointValue).toEqual(event.pointValue); // verifying response from event lookup @@ -83,6 +85,7 @@ describe('event creation', () => { start: moment().subtract(2, 'hour').toDate(), end: moment().subtract(1, 'hour').toDate(), attendanceCode: 'p4rty', + foodItems: '', pointValue: 10, }; @@ -114,6 +117,7 @@ describe('event creation', () => { start: moment().subtract(1, 'hour').toDate(), end: moment().subtract(2, 'hour').toDate(), attendanceCode: 'p4rty', + foodItems: null, pointValue: 10, }; diff --git a/tests/merchOrder.test.ts b/tests/merchOrder.test.ts index d3ab8720..89ce53a3 100644 --- a/tests/merchOrder.test.ts +++ b/tests/merchOrder.test.ts @@ -994,6 +994,7 @@ describe('merch order pickup events', () => { const persistedPickupEvent = await conn.manager.findOne(OrderPickupEventModel, { relations: ['orders', 'linkedEvent'] }); + expect(persistedPickupEvent).toStrictEqual(pickupEvent); // edit a linked event diff --git a/types/ApiRequests.ts b/types/ApiRequests.ts index 816b59f7..ed571143 100644 --- a/types/ApiRequests.ts +++ b/types/ApiRequests.ts @@ -157,6 +157,7 @@ export interface OptionalEventProperties { staffPointBonus?: number; discordEvent?: Uuid; googleCalendarEvent?: Uuid; + foodItems?: string; } export interface Event extends OptionalEventProperties { diff --git a/types/ApiResponses.ts b/types/ApiResponses.ts index d3dfa353..275d6e77 100644 --- a/types/ApiResponses.ts +++ b/types/ApiResponses.ts @@ -118,6 +118,7 @@ export interface PublicEvent { staffPointBonus: number; discordEvent: Uuid; googleCalendarEvent: Uuid; + foodItems: string; } export interface GetPastEventsResponse extends ApiResponse {