• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

iplweb / bpp / 18634744198

19 Oct 2025 07:00PM UTC coverage: 31.618% (-29.9%) from 61.514%
18634744198

push

github

mpasternak
Merge branch 'release/v202510.1270'

657 of 9430 branches covered (6.97%)

Branch coverage included in aggregate %.

229 of 523 new or added lines in 42 files covered. (43.79%)

11303 existing lines in 316 files now uncovered.

14765 of 39346 relevant lines covered (37.53%)

0.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.37
src/bpp_setup_wizard/views.py
1
from django.contrib import messages
1✔
2
from django.contrib.auth import get_user_model, login
1✔
3
from django.contrib.auth.decorators import login_required
1✔
4
from django.shortcuts import redirect, render
1✔
5
from django.utils.decorators import method_decorator
1✔
6
from django.views import View
1✔
7
from django.views.generic import FormView
1✔
8

9
from bpp.models import Uczelnia
1✔
10

11
from .forms import SetupAdminForm, UczelniaSetupForm
1✔
12

13
BppUser = get_user_model()
1✔
14

15

16
class SetupWizardView(FormView):
1✔
17
    """Main setup wizard view for initial system configuration."""
18

19
    template_name = "bpp_setup_wizard/setup.html"
1✔
20
    form_class = SetupAdminForm
1✔
21

22
    def dispatch(self, request, *args, **kwargs):
1✔
23
        # Check if setup is already complete (users exist)
UNCOV
24
        if BppUser.objects.exists():
×
UNCOV
25
            messages.info(
×
26
                request,
27
                "System został już skonfigurowany. Kreator konfiguracji jest niedostępny.",
28
            )
UNCOV
29
            return redirect("/")
×
30

UNCOV
31
        return super().dispatch(request, *args, **kwargs)
×
32

33
    def form_valid(self, form):
1✔
34
        # Create the admin user
UNCOV
35
        user = form.save()
×
36

37
        # Log the user in automatically using the Django ModelBackend
38
        # Since this is a fresh setup, we use the standard backend
UNCOV
39
        login(self.request, user, backend="django.contrib.auth.backends.ModelBackend")
×
40

UNCOV
41
        messages.success(
×
42
            self.request,
43
            f"Administrator '{user.username}' został utworzony pomyślnie. "
44
            f"Zostałeś automatycznie zalogowany.",
45
        )
46

47
        # Redirect to main page (which will trigger Uczelnia setup if needed)
UNCOV
48
        return redirect("/")
×
49

50
    def get_context_data(self, **kwargs):
1✔
UNCOV
51
        context = super().get_context_data(**kwargs)
×
UNCOV
52
        context["title"] = "Kreator konfiguracji BPP"
×
UNCOV
53
        context["subtitle"] = "Konfiguracja początkowa systemu"
×
UNCOV
54
        return context
×
55

56

57
class SetupStatusView(View):
1✔
58
    """View to check if setup is required."""
59

60
    def get(self, request):
1✔
UNCOV
61
        needs_setup = not BppUser.objects.exists()
×
62

UNCOV
63
        return render(
×
64
            request,
65
            "bpp_setup_wizard/status.html",
66
            {"needs_setup": needs_setup, "user_count": BppUser.objects.count()},
67
        )
68

69

70
@method_decorator(login_required, name="dispatch")
1✔
71
class UczelniaSetupView(FormView):
1✔
72
    """Setup wizard for Uczelnia (University) configuration."""
73

74
    template_name = "bpp_setup_wizard/uczelnia_setup.html"
1✔
75
    form_class = UczelniaSetupForm
1✔
76

77
    def dispatch(self, request, *args, **kwargs):
1✔
78
        # Check if Uczelnia is already configured
UNCOV
79
        if Uczelnia.objects.exists():
×
UNCOV
80
            messages.info(request, "Uczelnia została już skonfigurowana.")
×
UNCOV
81
            return redirect("/")
×
82

83
        # Check if user is authenticated and is superuser
UNCOV
84
        if not request.user.is_superuser:
×
UNCOV
85
            messages.error(request, "Tylko administrator może skonfigurować uczelnię.")
×
UNCOV
86
            return redirect("/")
×
87

UNCOV
88
        return super().dispatch(request, *args, **kwargs)
×
89

90
    def form_valid(self, form):
1✔
91
        # Create the Uczelnia
UNCOV
92
        uczelnia = form.save()
×
93

UNCOV
94
        messages.success(
×
95
            self.request,
96
            f"Uczelnia '{uczelnia.nazwa}' została skonfigurowana pomyślnie.",
97
        )
98

99
        # Redirect to main page
UNCOV
100
        return redirect("/")
×
101

102
    def get_context_data(self, **kwargs):
1✔
UNCOV
103
        context = super().get_context_data(**kwargs)
×
UNCOV
104
        context["title"] = "Konfiguracja uczelni"
×
UNCOV
105
        context["subtitle"] = "Podstawowe dane instytucji"
×
UNCOV
106
        return context
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc