-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add federation plugin, add federation models, add API route for shared events * handle AccessToken that does not belong to a FederatedGuest * add frontend view to display incoming events, add OAuth2 flow, add API route for own user data * add nav link, use correct signup url * check access token validity before serving the event detail view * add shift signup flow for federated users, add referrer to start correct OAuth2 flow, * set session expiration * add QualificationSerializer * respect included qualifications * improve incoming event view * make pylint happy * add form to select guests to share an event with * add RedeemFederationInviteCodeView * finish invite flow * fix event create * fix event create * fix event create * fix naming * add delete views for host and guest, handle invite code expiration * add InviteCodeRevealView, add explanations and experimental labels * remove expired invite codes * fix authorize translation * address some review comments * address more review comments * address more reivew comments * add flow to tear down federation connection * fix poetry.lock * fix tests * fix linter * address review comments * fix css for external event list * start adding tests * add test_redeem_invitecode_api * add shared_event_list_test * add shared_event_detail test * fix lockfile * remove django_db_serialized_rollback * lint templates * run all tests with rollback emulation * enable OAuth testing * fix poetry.lock * add translations --------- Co-authored-by: Felix Rindt <[email protected]>
- Loading branch information
1 parent
34fee3e
commit 078333b
Showing
40 changed files
with
1,937 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from django.db.models import Q | ||
from django.utils import timezone | ||
from oauth2_provider.contrib.rest_framework import IsAuthenticatedOrTokenHasScope | ||
from rest_framework.exceptions import PermissionDenied | ||
from rest_framework.fields import SerializerMethodField | ||
from rest_framework.generics import RetrieveAPIView | ||
from rest_framework.relations import SlugRelatedField | ||
from rest_framework.serializers import ModelSerializer | ||
|
||
from ephios.core.models import Qualification, UserProfile | ||
|
||
|
||
class QualificationSerializer(ModelSerializer): | ||
category = SlugRelatedField(slug_field="uuid", read_only=True) | ||
includes = SerializerMethodField() | ||
|
||
class Meta: | ||
model = Qualification | ||
fields = [ | ||
"uuid", | ||
"title", | ||
"abbreviation", | ||
"category", | ||
"includes", | ||
] | ||
|
||
def get_includes(self, obj): | ||
qualifications = Qualification.collect_all_included_qualifications(obj.includes.all()) | ||
return [q.uuid for q in qualifications] | ||
|
||
|
||
class UserProfileSerializer(ModelSerializer): | ||
qualifications = SerializerMethodField() | ||
|
||
class Meta: | ||
model = UserProfile | ||
fields = [ | ||
"first_name", | ||
"last_name", | ||
"date_of_birth", | ||
"email", | ||
"qualifications", | ||
] | ||
|
||
def get_qualifications(self, obj): | ||
return QualificationSerializer( | ||
Qualification.objects.filter( | ||
Q(grants__user=obj) | ||
& (Q(grants__expires__gte=timezone.now()) | Q(grants__expires__isnull=True)) | ||
), | ||
many=True, | ||
).data | ||
|
||
|
||
class UserProfileMeView(RetrieveAPIView): | ||
serializer_class = UserProfileSerializer | ||
queryset = UserProfile.objects.all() | ||
permission_classes = [IsAuthenticatedOrTokenHasScope] | ||
required_scopes = ["ME_READ"] | ||
|
||
def get_object(self): | ||
if self.request.user is None: | ||
raise PermissionDenied() | ||
return self.request.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.