@@ -2,6 +2,7 @@ package be.sgl.backend.service.activity
22
33import be.sgl.backend.dto.ActivityRegistrationStatus
44import be.sgl.backend.entity.branch.Branch
5+ import be.sgl.backend.entity.branch.BranchStatus
56import be.sgl.backend.entity.registrable.activity.Activity
67import be.sgl.backend.entity.registrable.activity.ActivityRestriction
78import be.sgl.backend.entity.user.User
@@ -35,11 +36,16 @@ class CheckRegistrationStatusForUser {
3536 logger.info { " No active branch found for ${user.username} " }
3637 return ActivityRegistrationStatus (activeMembership = false )
3738 }
38- val relevantRestrictions = activity.getRestrictionsForBranches(relevantBranches)
39+ var relevantRestrictions = activity.getRestrictionsForBranches(relevantBranches)
3940 if (relevantRestrictions.isEmpty()) {
4041 logger.info { " No applicable restrictions found for ${user.username} " }
4142 return ActivityRegistrationStatus ()
4243 }
44+ val nonPassiveRelevantBranches = relevantBranches.filter { it.status != BranchStatus .PASSIVE }
45+ if (activity.getRestrictionsForBranches(nonPassiveRelevantBranches).isNotEmpty()) {
46+ logger.info { " Applicable non-passive branch restrictions found, prioritizing these" }
47+ relevantRestrictions = activity.getRestrictionsForBranches(nonPassiveRelevantBranches)
48+ }
4349 if (isGlobalLimitReached(activity)) {
4450 logger.info { " Global activity limit (${activity.registrationLimit} ) is reached for ${activity.name} " }
4551 return ActivityRegistrationStatus (closedOptions = relevantRestrictions)
0 commit comments