Skip to content
Merged
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
7 changes: 0 additions & 7 deletions backend/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2383,9 +2383,6 @@ components:
description: Primary language used for the event occurrence
minLength: 2
maxLength: 30
location_id:
type: string
description: ID of a location in the database
manager_id:
type: string
description: ID of a manager in the database
Expand All @@ -2406,7 +2403,6 @@ components:
format: date-time
required:
- event_id
- location_id
- start_time
- end_time
- max_attendees
Expand Down Expand Up @@ -3724,9 +3720,6 @@ components:
description: Primary language used for the event occurrence
minLength: 2
maxLength: 30
location_id:
type: string
description: ID of a location in the database
manager_id:
type: string
description: ID of a manager in the database
Expand Down
2 changes: 0 additions & 2 deletions backend/internal/models/event_occurrence.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ type CreateEventOccurrenceInput struct {
Body struct {
ManagerId *uuid.UUID `json:"manager_id,omitempty" doc:"ID of a manager in the database"`
EventId uuid.UUID `json:"event_id" doc:"ID of an event in the database"`
LocationId uuid.UUID `json:"location_id" doc:"ID of a location in the database"`
StartTime time.Time `json:"start_time" doc:"Start time of the event occurrence"`
EndTime time.Time `json:"end_time" doc:"End time of the event occurrence"`
MaxAttendees int `json:"max_attendees" doc:"Maximum number of attendees" minimum:"1" maximum:"100"`
Expand All @@ -111,7 +110,6 @@ type UpdateEventOccurrenceInput struct {
Body struct {
ManagerId *uuid.UUID `json:"manager_id,omitempty" doc:"ID of a manager in the database"`
EventId *uuid.UUID `json:"event_id,omitempty" doc:"ID of an event in the database"`
LocationId *uuid.UUID `json:"location_id,omitempty" doc:"ID of a location in the database"`
StartTime *time.Time `json:"start_time,omitempty" doc:"Start time of the event occurrence"`
EndTime *time.Time `json:"end_time,omitempty" doc:"End time of the event occurrence"`
MaxAttendees *int `json:"max_attendees,omitempty" doc:"Maximum number of attendees" minimum:"1" maximum:"100"`
Expand Down
26 changes: 13 additions & 13 deletions backend/internal/models/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import (
)

type Organization struct {
ID uuid.UUID `json:"id" db:"id"`
Name string `json:"name" db:"name"`
Active bool `json:"active" db:"active"`
PfpS3Key *string `json:"pfp_s3_key,omitempty" db:"pfp_s3_key"`
PresignedURL *string `json:"presigned_url"`
LocationID *uuid.UUID `json:"location_id,omitempty" db:"location_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
StripeAccountID *string `json:"stripe_account_id" db:"stripe_account_id"`
StripeAccountActivated bool `json:"stripe_account_activated" db:"stripe_account_activated" default:"false"`
ID uuid.UUID `json:"id" db:"id"`
Name string `json:"name" db:"name"`
Active bool `json:"active" db:"active"`
PfpS3Key *string `json:"pfp_s3_key,omitempty" db:"pfp_s3_key"`
PresignedURL *string `json:"presigned_url"`
LocationID uuid.UUID `json:"location_id" db:"location_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
StripeAccountID *string `json:"stripe_account_id" db:"stripe_account_id"`
StripeAccountActivated bool `json:"stripe_account_activated" db:"stripe_account_activated" default:"false"`
}

// CreateOrganizationRouteInput is the multipart form input for creating an organization with an image
Expand Down Expand Up @@ -46,9 +46,9 @@ type UpdateOrganizationRouteInput struct {
}

type CreateOrganizationBody struct {
Name string `json:"name" minLength:"1" maxLength:"255" doc:"Organization name"`
Active *bool `json:"active,omitempty" doc:"Active status (defaults to true)"`
LocationID *uuid.UUID `json:"location_id,omitempty" format:"uuid" doc:"Associated location ID"`
Name string `json:"name" minLength:"1" maxLength:"255" doc:"Organization name"`
Active *bool `json:"active,omitempty" doc:"Active status (defaults to true)"`
LocationID uuid.UUID `json:"location_id" format:"uuid" doc:"Associated location ID"`
}
Comment on lines 48 to 52
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateOrganizationBody.LocationID is now non-optional, but the multipart form structs (CreateOrganizationFormData / UpdateOrganizationFormData) still don't mark location_id as required. That means requests could omit it and end up with a zero UUID, producing a less clear "location does not exist" error instead of a validation error, and the generated OpenAPI may not mark it as required. Consider adding required:"true" (and any other relevant validation) to the form field and regenerating the OpenAPI/client.

Copilot uses AI. Check for mistakes.

type UpdateOrganizationBody struct {
Expand Down
6 changes: 2 additions & 4 deletions backend/internal/service/handler/event-occurrence/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ func (h *Handler) CreateEventOccurrence(ctx context.Context, input *models.Creat
// check that foreign keys exist in the database
managerId := input.Body.ManagerId
eventId := input.Body.EventId
locationId := input.Body.LocationId

var managerErr error
if managerId != nil {
_, managerErr = h.ManagerRepository.GetManagerByID(ctx, *managerId)
}

_, eventErr := h.EventRepository.GetEventByID(ctx, eventId, input.AcceptLanguage)
_, locationErr := h.LocationRepository.GetLocationByID(ctx, locationId)

if managerErr != nil || eventErr != nil || locationErr != nil {
return nil, cmp.Or(managerErr, eventErr, locationErr)
if managerErr != nil || eventErr != nil {
return nil, cmp.Or(managerErr, eventErr)
}

eventOccurrence, err := h.EventOccurrenceRepository.CreateEventOccurrence(ctx, input)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ func TestHandler_CreateEventOccurrence(t *testing.T) {
input.AcceptLanguage = "en-US"
input.Body.ManagerId = &testMid
input.Body.EventId = event.ID
input.Body.LocationId = location.ID
input.Body.StartTime = start
input.Body.EndTime = end
input.Body.MaxAttendees = 15
Expand Down Expand Up @@ -201,7 +200,6 @@ func TestHandler_CreateEventOccurrence(t *testing.T) {
assert.Equal(t, *tt.input.Body.ManagerId, *eventOccurrence.ManagerId)
}
assert.Equal(t, tt.input.Body.EventId, eventOccurrence.Event.ID)
assert.Equal(t, tt.input.Body.LocationId, eventOccurrence.Location.ID)
assert.Equal(t, tt.input.Body.StartTime, eventOccurrence.StartTime)
assert.Equal(t, tt.input.Body.EndTime, eventOccurrence.EndTime)
assert.Equal(t, tt.input.Body.MaxAttendees, eventOccurrence.MaxAttendees)
Expand Down Expand Up @@ -380,7 +378,6 @@ func TestHandler_UpdateEventOccurrence(t *testing.T) {
input.ID = testEOID
input.Body.ManagerId = nil
input.Body.EventId = nil
input.Body.LocationId = nil
input.Body.StartTime = nil
input.Body.EndTime = nil
input.Body.MaxAttendees = &max
Expand All @@ -401,7 +398,6 @@ func TestHandler_UpdateEventOccurrence(t *testing.T) {
input.ID = testEOID
input.Body.ManagerId = nil
input.Body.EventId = nil
input.Body.LocationId = nil
input.Body.StartTime = nil
input.Body.EndTime = nil
input.Body.MaxAttendees = nil
Expand Down Expand Up @@ -439,7 +435,6 @@ func TestHandler_UpdateEventOccurrence(t *testing.T) {
input.ID = testEOID
input.Body.ManagerId = &midNew
input.Body.EventId = &eid
input.Body.LocationId = &lid
input.Body.StartTime = &startNew
input.Body.EndTime = &endNew
input.Body.MaxAttendees = &max
Expand Down
5 changes: 0 additions & 5 deletions backend/internal/service/handler/event-occurrence/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ func (h *Handler) UpdateEventOccurrence(ctx context.Context, input *models.Updat
_, eventErr = h.EventRepository.GetEventByID(ctx, *eventId, input.AcceptLanguage)
}

locationId := input.Body.LocationId
if locationId != nil {
_, locationErr = h.LocationRepository.GetLocationByID(ctx, *locationId)
}

if managerErr != nil || eventErr != nil || locationErr != nil {
return nil, cmp.Or(managerErr, eventErr, locationErr)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import (
)

func (h *Handler) CreateOrganization(ctx context.Context, input *models.CreateOrganizationInput, updateBody *models.UpdateOrganizationBody, image_data *[]byte, s3Client s3_client.S3Interface) (*models.Organization, error) {
if input.Body.LocationID != nil {
if _, err := h.LocationRepository.GetLocationByID(ctx, *input.Body.LocationID); err != nil {
return nil, errs.BadRequest("Invalid location_id: location does not exist")
}
if _, err := h.LocationRepository.GetLocationByID(ctx, input.Body.LocationID); err != nil {
return nil, errs.BadRequest("Invalid location_id: location does not exist")
}

var key *string
Expand Down
Loading
Loading