Skip to content

Commit

Permalink
Merge pull request #489 from AOEpeople/bugfix/#264726-event-backend-v…
Browse files Browse the repository at this point in the history
…alidation

Bugfix/#264726 event backend validation
  • Loading branch information
hacksch authored Jul 16, 2024
2 parents bbc10b7 + d67a63a commit a4abcca
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ IDP_CLIENT_SECRET=client-secret
* 801: User has no permission to enter or leave
* 802: User could not join the event
* 803: User could not leave the event
* 804: User could not join, because the event already happened
*MealGuestController 9xx*
* 901: Could not find the Invitation for the given hash
* 902: Parameters were not provided (eg. firstname and lastname)
Expand Down
1 change: 1 addition & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ parameters:
mealz.meal.search_timestamp: '2000-01-01'
mealz.meal.new_flag_counter: 2
mealz.meal.combined.price: 6.13
mealz.event.lock_participation_at: '17:00'
# PDO Session Handler options
# Define table and column names to store session data
app.session.handler.pdo.options:
Expand Down
5 changes: 5 additions & 0 deletions src/Mealz/MealBundle/Controller/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ public function join(DateTime $date): JsonResponse
}

$day = $this->dayRepository->getDayByDate($date);
$eventLockModifier = (string) $this->getParameter('mealz.event.lock_participation_at');

if (new DateTime() > $day->getDateTime()->modify($eventLockModifier)) {
return new JsonResponse(['message' => '804: User could not join the event'], Response::HTTP_INTERNAL_SERVER_ERROR);
}

$eventParticipation = $this->eventPartSrv->join($profile, $day);
if (null === $eventParticipation) {
Expand Down
13 changes: 10 additions & 3 deletions src/Resources/src/components/dashboard/EventData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
/>
<ParticipationCounter
:limit="0"
:mealCSS="!day.isLocked ? 'bg-primary-4' : 'bg-[#80909F]'"
:mealCSS="!isEventPast() ? 'bg-primary-4' : 'bg-[#80909F]'"
>
{{ day.event?.participations }}
</ParticipationCounter>
<CheckBox
:isActive="new Date(day.date.date) > new Date()"
:isActive="!isEventPast()"
:isChecked="day.event?.isParticipating ?? false"
@click="handleClick"
/>
Expand Down Expand Up @@ -72,7 +72,7 @@ const { getEventById, joinEvent, leaveEvent } = useEvents();
const { addLock, isLocked, removeLock } = useLockRequests();

async function handleClick() {
if (isLocked(props.dayId) === true) {
if (isLocked(props.dayId) === true || isEventPast() === true) {
return;
}
addLock(props.dayId);
Expand All @@ -83,4 +83,11 @@ async function handleClick() {
}
removeLock(props.dayId);
}

function isEventPast() {
const eventLockDate = new Date(props.day.date.date).setHours(17, 0);
const now = Date.now();
const isPast = eventLockDate < now;
return isPast;
}
</script>
1 change: 1 addition & 0 deletions src/Resources/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
"801": "Keine Berechtigung zum beitreten oder verlassen",
"802": "Dem Event konnte nicht beigetreten werden",
"803": "Das Event konnte nicht verlassen werden",
"804": "Dem Event kann nicht mehr beigetreten werden",
"903": "Sie haben sich schon angemeldet. Bei Fragen wenden Sie sich bitte an Ihren Ansprechpartner."
},
"success": {
Expand Down
1 change: 1 addition & 0 deletions src/Resources/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
"801": "No permission to enter or leave the event",
"802": "Couldn't join the event",
"803": "Couldn't leave the event",
"804": "Can't join the event anymore",
"903": "You are already registered. If you have any questions please message your contact person."
},
"success": {
Expand Down

0 comments on commit a4abcca

Please sign in to comment.