mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-21 01:48:21 +02:00
Invalidate registrations, fix profile creation
This commit is contained in:
@ -10,7 +10,7 @@ def save_user_profile(instance, created, raw, **_kwargs):
|
||||
# When provisionning data, do not try to autocreate
|
||||
return
|
||||
|
||||
if created:
|
||||
if created and instance.is_active:
|
||||
from .models import Profile
|
||||
Profile.objects.get_or_create(user=instance)
|
||||
instance.profile.save()
|
||||
instance.profile.save()
|
||||
|
@ -102,11 +102,8 @@ class UserUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
|
||||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self, **kwargs):
|
||||
if kwargs:
|
||||
return reverse_lazy('member:user_detail',
|
||||
kwargs={'pk': kwargs['id']})
|
||||
else:
|
||||
return reverse_lazy('member:user_detail', args=(self.object.id,))
|
||||
url = 'member:user_detail' if self.object.profile.registration_valid else 'registration:future_user_detail'
|
||||
return reverse_lazy(url, args=(self.object.id,))
|
||||
|
||||
|
||||
class UserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
|
||||
@ -117,6 +114,12 @@ class UserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
|
||||
context_object_name = "user_object"
|
||||
template_name = "member/profile_detail.html"
|
||||
|
||||
def get_queryset(self, **kwargs):
|
||||
"""
|
||||
We can't display information of a not registered user.
|
||||
"""
|
||||
return super().get_queryset().filter(profile__registration_valid=True)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
user = context['user_object']
|
||||
|
Reference in New Issue
Block a user