mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-10-31 07:49:57 +01:00 
			
		
		
		
	add register button at the end of WEI registration
This commit is contained in:
		| @@ -1084,7 +1084,44 @@ class WEISurveyEndView(LoginRequiredMixin, TemplateView): | ||||
|  | ||||
|     def get_context_data(self, **kwargs): | ||||
|         context = super().get_context_data(**kwargs) | ||||
|         context["club"] = WEIRegistration.objects.get(pk=self.kwargs["pk"]).wei | ||||
|         club = WEIRegistration.objects.get(pk=self.kwargs["pk"]).wei | ||||
|         context["club"] = club | ||||
|  | ||||
|         random_user = User.objects.filter(~Q(wei__wei__in=[club])).first() | ||||
|  | ||||
|         if random_user is None: | ||||
|             # This case occurs when all users are registered to the WEI. | ||||
|             # Don't worry, Pikachu never went to the WEI. | ||||
|             # This bug can arrive only in dev mode. | ||||
|             context["can_add_first_year_member"] = True | ||||
|             context["can_add_any_member"] = True | ||||
|         else: | ||||
|             # Check if the user has the right to create a registration of a random first year member. | ||||
|             empty_fy_registration = WEIRegistration( | ||||
|                 wei=club, | ||||
|                 user=random_user, | ||||
|                 first_year=True, | ||||
|                 birth_date="1970-01-01", | ||||
|                 gender="No", | ||||
|                 emergency_contact_name="No", | ||||
|                 emergency_contact_phone="No", | ||||
|             ) | ||||
|             context["can_add_first_year_member"] = PermissionBackend \ | ||||
|                 .check_perm(self.request, "wei.add_weiregistration", empty_fy_registration) | ||||
|  | ||||
|             # Check if the user has the right to create a registration of a random old member. | ||||
|             empty_old_registration = WEIRegistration( | ||||
|                 wei=club, | ||||
|                 user=User.objects.filter(~Q(wei__wei__in=[club])).first(), | ||||
|                 first_year=False, | ||||
|                 birth_date="1970-01-01", | ||||
|                 gender="No", | ||||
|                 emergency_contact_name="No", | ||||
|                 emergency_contact_phone="No", | ||||
|             ) | ||||
|             context["can_add_any_member"] = PermissionBackend \ | ||||
|                 .check_perm(self.request, "wei.add_weiregistration", empty_old_registration) | ||||
|  | ||||
|         return context | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user