text: from abc import ABC
  
  from django.contrib import messages
  from django.shortcuts import render, redirect
  from django.core.exceptions import PermissionDenied
  from django.contrib.auth.decorators import login_required
  from django.contrib.messages.views import SuccessMessageMixin
  from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
  from django.views.generic import CreateView, DetailView, UpdateView, DeleteView, ListView
  
  from .forms import *
  from .models import *
  from .filters import UserFilter
  
  
  class ClubCreate(LoginRequiredMixin, SuccessMessageMixin, UserPassesTestMixin, CreateView, ABC):
      model = Club
      template_name = 'account/club_create.html'
      fields = ['name']
      success_url = '/club_create'
      success_message = "Club name has been successfully created!"
  
      def test_func(self):
          return self.request.user.is_superuser
  
  
  @login_required
  def user_create(request):
      if request.user.is_superuser:
          if request.method == 'POST':
              form = TrenerCreateForm(request.POST, request.FILES)
              if form.is_valid():
                  form.save()
                  messages.success(request, 'An account has been successfully created! :)')
                  return redirect('user_list')
          else:
              form = TrenerCreateForm()
          return render(request, 'account/user_create.html', {'form': form})
  
      elif request.user.is_trener:
          if request.method == 'POST':
              form = UtøverCreateForm(request.POST, request.FILES)
              if form.is_valid():
                  user = form.save(commit=False)
                  user.club = request.user.club
                  user.save()
                  messages.success(request, 'An account has been successfully created! :)')
                  return redirect('user_list')
          else:
              form = UtøverCreateForm()
          return render(request, 'account/user_create.html', {'form': form})
  
      else:
          raise PermissionDenied()
  
  
  @login_required
  def user_profile(request):
      if request.method == 'POST':
          form = UserProfileForm(request.POST, request.FILES, instance=request.user)
          if form.is_valid():
              form.save()
              messages.success(request, 'Your account has been successfully updated!')
              return redirect('user_profile')
      else:
          form = UserProfileForm(instance=request.user)
  
      context = {'form': form}
  
      return render(request, 'account/user_profile.html', context)
  
  
  class UserDetails(LoginRequiredMixin, DetailView):
      model = User
      template_name = 'account/user_details.html'
  
  
  class UserUpdate(LoginRequiredMixin, SuccessMessageMixin, UserPassesTestMixin, UpdateView):
      model = User
      template_name = 'account/user_update.html'
      fields = ['image', 'first_name', 'last_name', 'email', 'year_of_birth', 'is_utøver', 'is_trener']
      success_message = "The account has been successfully updated!"
  
      def test_func(self):
          user = self.get_object()
          if self.request.user.club == user.club and self.request.user.is_trener:
              return True
          return False
  
  
  class UserDelete(LoginRequiredMixin, SuccessMessageMixin, DeleteView):
      model = User
      template_name = 'account/user_delete.html'
      success_url = '/user_list'
      success_message = "The account has been successfully deleted!"
  
      def test_func(self):
          user = self.get_object()
          if self.request.user.club == user.club and self.request.user.is_trener:
              return True
          return False
  
      def delete(self, request, *args, **kwargs):
          messages.success(self.request, self.success_message)
          return super(UserDelete, self).delete(request, *args, **kwargs)
  
  
  class UserList(LoginRequiredMixin, ListView):
      model = User
      template_name = 'account/user_list.html'
      context_object_name = 'users'
      paginate_by = 25
  
      def get_context_data(self, **kwargs):
          if self.request.user.is_superuser:
              users = User.objects.filter(is_trener=True).order_by('club', 'first_name', 'last_name')
          else:
              users = User.objects.filter(club=self.request.user.club).order_by('-is_trener', '-is_utøver', 'first_name',
                                                                                'last_name')
          total_users = users.count()
  
          user_filter = UserFilter(self.request.GET, queryset=users)
          users = user_filter.qs
  
          page_size = self.get_paginate_by(users)
          context_object_name = self.get_context_object_name(users)
          if page_size:
              paginator, page, users, is_paginated = self.paginate_queryset(users, page_size)
              context = {
                  'paginator': paginator,
                  'page_obj': page,
                  'is_paginated': is_paginated,
                  'users': users,
                  'total_users': total_users,
                  'user_filter': user_filter,
              }
          else:
              context = {
                  'paginator': None,
                  'page_obj': None,
                  'is_paginated': False,
                  'users': users,
                  'total_users': total_users,
                  'user_filter': user_filter,
              }
          if context_object_name is not None:
              context[context_object_name] = users
          context.update(kwargs)
          return super().get_context_data(**context)
  