Skip to content

Commit

Permalink
filter asp events and set participations right
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiKaestle committed Feb 27, 2025
1 parent ad5a1f5 commit 24a009c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions dao/participation.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func ParticipationInsert(ctx context.Context, i *models.ParticipationCreate, tok
}
if _, err = EventApplicationsUpdate(ctx, &models.EventApplicationsUpdate{ID: i.EventID, Applications: models.EventApplications{
Requested: event.Applications.Requested + 1,
Confirmed: event.Applications.Confirmed,
Rejected: event.Applications.Rejected,
Withdrawn: event.Applications.Withdrawn,
Total: event.Applications.Total + 1,
}}); err != nil {
return
Expand Down
7 changes: 6 additions & 1 deletion models/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,10 +592,15 @@ func (i *EventParam) PublicFilter() bson.D {
func (i *EventQuery) FilterAsp(token *AccessToken) bson.D {
filter := vmdb.NewFilter()
if token.PoolRoles.Validate(ASPEventRole) {
filter.EqualString("crew_id", token.CrewID)
status := bson.A{}
status = append(status, bson.D{{Key: "event_asp_id", Value: token.ID}})
status = append(status, bson.D{{Key: "crew_id", Value: token.CrewID}})
filter.Append(bson.E{Key: "$or", Value: status})
} else {
filter.EqualString("event_asp_id", token.ID)
}
filter.GteInt64("end_at", fmt.Sprint(time.Now().AddDate(0, -6, 0).Unix()))
filter.EqualStringList("event_state.state", []string{"published", "finished"})
return filter.Bson()
}

Expand Down

0 comments on commit 24a009c

Please sign in to comment.