|
18 | 18 | ViewUserModelObjectPermissions, |
19 | 19 | ) |
20 | 20 | from ephios.api.serializers import ( |
| 21 | + ConsequenceSerializer, |
21 | 22 | ParticipationSerializer, |
22 | 23 | UserinfoParticipationSerializer, |
23 | 24 | UserProfileSerializer, |
| 25 | + WorkingHoursSerializer, |
| 26 | +) |
| 27 | +from ephios.core.models import ( |
| 28 | + AbstractParticipation, |
| 29 | + Consequence, |
| 30 | + LocalParticipation, |
| 31 | + UserProfile, |
| 32 | + WorkingHours, |
24 | 33 | ) |
25 | | -from ephios.core.models import AbstractParticipation, LocalParticipation, UserProfile |
26 | 34 |
|
27 | 35 |
|
28 | 36 | class UserProfileMeView(RetrieveAPIView): |
@@ -84,3 +92,20 @@ def get_queryset(self): |
84 | 92 | return AbstractParticipation.objects.filter( |
85 | 93 | localparticipation__user=self.kwargs.get("user") |
86 | 94 | ).select_related("shift", "shift__event", "shift__event__type") |
| 95 | + |
| 96 | + |
| 97 | +class WorkingHoursViewSet(viewsets.ReadOnlyModelViewSet): |
| 98 | + serializer_class = WorkingHoursSerializer |
| 99 | + permission_classes = [IsAuthenticatedOrTokenHasScope, ViewObjectPermissions] |
| 100 | + filter_backends = [DjangoFilterBackend] |
| 101 | + filterset_fields = ["user", "date"] |
| 102 | + required_scopes = ["CONFIDENTIAL_READ"] |
| 103 | + queryset = WorkingHours.objects.all() |
| 104 | + |
| 105 | + |
| 106 | +class ConsequenceViewSet(viewsets.ModelViewSet): |
| 107 | + serializer_class = ConsequenceSerializer |
| 108 | + permission_classes = [IsAuthenticatedOrTokenHasScope, ViewObjectPermissions] |
| 109 | + filter_backends = [DjangoFilterBackend] |
| 110 | + required_scopes = ["CONFIDENTIAL_WRITE"] |
| 111 | + queryset = Consequence.objects.all() |
0 commit comments