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

iplweb / bpp / 851809f0-9849-4611-a43d-17c345104d20

18 Feb 2025 12:47AM UTC coverage: 47.247% (-0.01%) from 47.257%
851809f0-9849-4611-a43d-17c345104d20

push

circleci

mpasternak
Merge tag 'v202502.1157' into dev

Nowa wersja: v202502.1157 v202502.1157

1 of 1 new or added line in 1 file covered. (100.0%)

279 existing lines in 11 files now uncovered.

16739 of 35429 relevant lines covered (47.25%)

1.21 hits per line

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

41.67
src/pbn_api/views.py
1
# Create your views here.
2
import sentry_sdk
3✔
3
from django.db import transaction
3✔
4
from django.http import HttpResponseBadRequest
3✔
5
from django.views.generic import RedirectView
3✔
6

7
from .client import OAuthMixin
3✔
8
from .exceptions import AuthenticationConfigurationError, AuthenticationResponseError
3✔
9
from .signals import token_set_successfully
3✔
10

11
from django.contrib import messages
3✔
12
from django.contrib.auth.mixins import LoginRequiredMixin
3✔
13

14
from django.utils import timezone
3✔
15

16
from bpp.models import Uczelnia
3✔
17

18

19
class TokenRedirectPage(LoginRequiredMixin, RedirectView):
3✔
20
    def get_redirect_url(self, *args, **kwargs):
3✔
UNCOV
21
        uczelnia = Uczelnia.objects.get_default()
×
UNCOV
22
        return OAuthMixin.get_auth_url(uczelnia.pbn_api_root, uczelnia.pbn_app_name)
×
23

24

25
class TokenLandingPage(LoginRequiredMixin, RedirectView):
3✔
26
    def get_redirect_url(self, *args, **kwargs):
3✔
UNCOV
27
        ott = self.request.GET.get("ott")
×
28

UNCOV
29
        if not ott:
×
30
            raise HttpResponseBadRequest("Brak parametru OTT lub pusty")
×
31

UNCOV
32
        uczelnia = Uczelnia.objects.get_default()
×
33

UNCOV
34
        try:
×
UNCOV
35
            user_token = OAuthMixin.get_user_token(
×
36
                uczelnia.pbn_api_root,
37
                uczelnia.pbn_app_name,
38
                uczelnia.pbn_app_token,
39
                ott,
40
            )
41
            user = self.request.user
×
UNCOV
42
            user.pbn_token = user_token
×
UNCOV
43
            user.pbn_token_updated = timezone.now()
×
UNCOV
44
            user.save()
×
45

46
            transaction.on_commit(lambda: token_set_successfully.send(sender=user))
×
47

UNCOV
48
            messages.info(
×
49
                self.request, "Autoryzacja w PBN API przeprowadzona pomyślnie."
50
            )
51

52
        except AuthenticationConfigurationError as e:
×
UNCOV
53
            messages.error(
×
54
                self.request, f"Nie można autoryzować zalogowania do PBN - {e}"
55
            )
UNCOV
56
            sentry_sdk.capture_exception(e)
×
57

58
        except AuthenticationResponseError as e:
×
UNCOV
59
            messages.error(
×
60
                self.request,
61
                "Bez możliwości autoryzacji - błąd odpowiedzi z serwera "
62
                "autoryzacyjnego. Ze względów bezpieczeństwa wyświetlenie niewskazane - "
63
                "błąd przekazano do administratora serwisu.  ",
64
            )
UNCOV
65
            sentry_sdk.capture_exception(e)
×
66

UNCOV
67
        return "/"
×
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