-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feat(kontres)/add image to bookable item (#785) * added optional image to bookable item model * added update method in serializer to handle new images * linting * remove update method for images * Feat(kontres)/add approved by (#786) * added approved by field * endpoint will now set approved by * serializer will return full user object in approved_by_detail * created test for approved by * migration * remove unnecessary code * removed write-only field in approved-by context * Create minutes for Codex (#787) * init * format * Feat(minute)/viewset (#788) * added richer reponse on post and put * added to admin panel * added filter for minute * Feat(kontres)/add notification (#790) * created methods for sending notification to admin and user * endpoint will now send notification if needed * add migrations for new notification types * Memberships with fines activated (#791) init * Feat(user)/user bio (#758) * Created model, serializer and view for user-bio * Created user bio model and made migrations * Created user bio serializer + viewsets + added new endpoint * Tested create method + added bio serializer to user serializer * Format * Created update method and started testing * Debugging test failures in user retrieve * fixed model error * Created user_bio_factory + started testing put method * Created fixture for UserBio * Created custom excpetion for duplicate user bio * Added permissions and inherited from BaseModel * Modularized serializer for bio * Use correct serializers in viewset + added destroy method * Finished testing bio viewset integration + format * Changed environent file to .env to avoid pushing up keys * Fix: Flipped assertion statement in test, since user bio should not be deleted * skiped buggy test from kontres * added mark to pytest.skip * Moved keys to .env file and reverted docker variables * Skip buggy kontres test * format * Added str method to user_bio * Removed unused imports * format * Changed user relation to a OneToOne-field (same affect as ForeignKey(unique=True) + removed check for duplicate bio in serializer * Migrations + changed assertion status code in duplicate bio test (could try catch in serializer to produce 400 status code) * format * format * Changed limit for description 50 -> 500 + migrations * Migrate * added id to serializer * merged leaf nodes in migrations * format --------- Co-authored-by: Ester2109 <[email protected]> Co-authored-by: Mads Nylund <[email protected]> Co-authored-by: Mads Nylund <[email protected]> Co-authored-by: Tam Le <[email protected]> * Update CHANGELOG.md * added filter for allowed photos for user (#794) added filter for allowed photos * Upped payment time when coming from waiting list (#796) * fixed paymenttime saved to db (#798) * fixed bug (#800) * Disallow users to unregister when payment is done (#802) added 400 status code for deleting paid registration * update changelog * Added serializer for category in event (#804) added serializer for category in event * Permission middelware (#806) * added a check for existing user and id on request * format * Permission refactor of QR Codes (#807) * added permissions to qr code and refactored viewset * format * removed unused imports * Permissions for payment orders (#808) * added read permissions * added permissions for payment order and tests * format * chore(iac): updated docs and force https (#810) chore: updated docs and force https * feat(iac): add terraform guardrails so index don't nuke our infra (#811) feat: add guardrails so index don't fup * Automatic registration for new users with Feide (#809) * started on feide registration endpoint * made endpoint for creating user with Feide * added test for parse group * finished * format * removes three years if in digtrans * changelog update --------- Co-authored-by: Erik Skjellevik <[email protected]> Co-authored-by: haruixu <[email protected]> Co-authored-by: Ester2109 <[email protected]> Co-authored-by: Tam Le <[email protected]> Co-authored-by: martcl <[email protected]>
- Loading branch information
1 parent
e939867
commit 6f118fc
Showing
26 changed files
with
815 additions
and
97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,3 +57,95 @@ class EventIsFullError(ValueError): | |
|
||
class RefundFailedError(ValueError): | ||
pass | ||
|
||
|
||
class FeideError(ValueError): | ||
def __init__( | ||
self, | ||
message="Det skjedde en feil under registrering av din bruker ved hjelp av Feide.", | ||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, | ||
): | ||
self.message = message | ||
self.status_code = status_code | ||
|
||
|
||
class FeideTokenNotFoundError(FeideError): | ||
def __init__( | ||
self, | ||
message="Fikk ikke tak i Feide token for din bruker. Prøv igjen eller registrer deg manuelt.", | ||
): | ||
self.message = message | ||
super().__init__(self.message, status_code=status.HTTP_404_NOT_FOUND) | ||
|
||
|
||
class FeideUserInfoNotFoundError(FeideError): | ||
def __init__( | ||
self, | ||
message="Fikk ikke tak i brukerinformasjon om deg fra Feide. Prøv igjen eller registrer deg manuelt.", | ||
): | ||
self.message = message | ||
super().__init__(self.message, status_code=status.HTTP_404_NOT_FOUND) | ||
|
||
|
||
class FeideUsernameNotFoundError(FeideError): | ||
def __init__( | ||
self, | ||
message="Fikk ikke tak i brukernavn fra Feide. Prøv igjen eller registrer deg manuelt.", | ||
): | ||
self.message = message | ||
super().__init__(self.message, status_code=status.HTTP_404_NOT_FOUND) | ||
|
||
|
||
class FeideUserGroupsNotFoundError(FeideError): | ||
def __init__( | ||
self, | ||
message="Fikk ikke tak i dine gruppetilhørigheter fra Feide. Prøv igjen eller registrer deg manuelt.", | ||
): | ||
self.message = message | ||
super().__init__(self.message, status_code=status.HTTP_404_NOT_FOUND) | ||
|
||
|
||
class FeideGetTokenError(FeideError): | ||
def __init__( | ||
self, | ||
message="Fikk ikke tilgang til Feide sitt API for å hente ut din token. Prøv igjen eller registrer deg manuelt.", | ||
): | ||
self.message = message | ||
super().__init__( | ||
self.message, status_code=status.HTTP_500_INTERNAL_SERVER_ERROR | ||
) | ||
|
||
|
||
class FeideUsedUserCode(FeideError): | ||
def __init__( | ||
self, | ||
message="Feide innloggings kode har allerede blitt brukt. Prøv å registrere deg på nytt.", | ||
): | ||
self.message = message | ||
super().__init__(self.message, status_code=status.HTTP_409_CONFLICT) | ||
|
||
|
||
class FeideGetUserGroupsError(FeideError): | ||
def __init__( | ||
self, | ||
message="Fikk ikke tilgang til Feide sitt API for å hente ut dine utdanninger. Prøv igjen eller registrer deg manuelt.", | ||
): | ||
self.message = message | ||
super().__init__( | ||
self.message, status_code=status.HTTP_500_INTERNAL_SERVER_ERROR | ||
) | ||
|
||
|
||
class FeideParseGroupsError(FeideError): | ||
def __init__( | ||
self, | ||
message="Vi fant ingen utdanningen du tilhører som er en del av TIHLDE. Hvis du mener dette er feil så kan du opprette en bruker manuelt og sende mail til [email protected] for å den godkjent.", | ||
): | ||
self.message = message | ||
super().__init__(self.message, status_code=status.HTTP_404_NOT_FOUND) | ||
|
||
|
||
class FeideUserExistsError(FeideError): | ||
def __init__(self, message="Det finnes allerede en bruker med dette brukernavnet."): | ||
self.message = message | ||
super().__init__(self.message, status_code=status.HTTP_409_CONFLICT) |
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,32 @@ | ||
import pytest | ||
|
||
from app.content.util.feide_utils import parse_feide_groups | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_parse_feide_groups(): | ||
"""A list of group ids should return the slugs that is in TIHLDE""" | ||
groups = [ | ||
"fc:fs:fs:prg:ntnu.no:BDIGSEC", | ||
"fc:fs:fs:prg:ntnu.no:ITBAITBEDR", | ||
"fc:fs:fs:prg:ntnu.no:ITJEETTE", | ||
"fc:fs:fs:prg:ntnu.no:ITJESE", | ||
"fc:fs:fs:prg:ntnu.no:BDIGSEREC", | ||
"fc:fs:fs:prg:ntnu.no:BIDATA", | ||
"fc:fs:fs:prg:ntnu.no:ITMAIKTSA", | ||
"fc:fs:fs:prg:ntnu.no:ITBAINFODR", | ||
"fc:fs:fs:prg:ntnu.no:ITBAINFO", | ||
] | ||
|
||
slugs = parse_feide_groups(groups) | ||
|
||
correct_slugs = [ | ||
"dataingenir", | ||
"digital-forretningsutvikling", | ||
"digital-infrastruktur-og-cybersikkerhet", | ||
"digital-samhandling", | ||
"drift-studie", | ||
"informasjonsbehandling", | ||
] | ||
|
||
assert sorted(slugs) == sorted(correct_slugs) |
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.