diff --git a/apps/authentication/api/tests/user_data_tests.py b/apps/authentication/api/tests/user_data_tests.py index 5bd2b28d0..26814b472 100644 --- a/apps/authentication/api/tests/user_data_tests.py +++ b/apps/authentication/api/tests/user_data_tests.py @@ -72,7 +72,7 @@ def test_user_cannot_create_an_email_with_an_existing_address(self): def test_user_can_change_primary_email(self): self.assertTrue(self.email.primary) - email: Email = G(Email, user=self.user, verfied=False) + email: Email = G(Email, user=self.user, verified=False) response = self.client.patch( self.id_url(email.id), {"primary": True}, **self.headers @@ -89,7 +89,7 @@ def test_user_can_change_primary_email(self): def test_user_cannot_remove_primary_email_without_selecting_a_new_primary(self): self.assertTrue(self.email.primary) - email: Email = G(Email, user=self.user, verfied=False) + email: Email = G(Email, user=self.user, verified=False) response = self.client.patch( self.id_url(email.id), {"primary": False}, **self.headers @@ -108,7 +108,7 @@ def test_user_cannot_remove_primary_email_without_selecting_a_new_primary(self): self.assertTrue(self.email.primary) def test_user_cannot_verify_emails_without_token(self): - email: Email = G(Email, user=self.user, verfied=False) + email: Email = G(Email, user=self.user, verified=False) response = self.client.patch( self.id_url(email.id), {"verified": True}, **self.headers ) @@ -121,7 +121,7 @@ def test_user_cannot_verify_emails_without_token(self): def test_user_cannot_change_the_address_of_an_existing_email(self): address = "test@example.com" other_address = "test@test.io" - email: Email = G(Email, user=self.user, verfied=False, email=address) + email: Email = G(Email, user=self.user, verified=False, email=address) self.client.patch( self.id_url(email.id), {"email": other_address}, **self.headers ) diff --git a/apps/dataporten/study/tests/task_tests.py b/apps/dataporten/study/tests/task_tests.py index b3a6c75ef..32cc39fb8 100644 --- a/apps/dataporten/study/tests/task_tests.py +++ b/apps/dataporten/study/tests/task_tests.py @@ -40,7 +40,7 @@ def test_fetch_groups_information(self, mocked_request): class StudyUpdatingTestCase(TestCase): def test_find_user_study_and_update_1st_grader(self): - user = G(OnlineUser) + user = G(OnlineUser, ntnu_username="testesen") groups = [ INFORMATICS_BACHELOR_STUDY_PROGRAMME, load_course(ITGK_ACTIVE, years_ago=0), @@ -57,7 +57,7 @@ def test_find_user_study_and_update_1st_grader(self): self.assertEqual(len(mail.outbox), 0) def test_find_user_study_and_update_5th_grader(self): - user = G(OnlineUser) + user = G(OnlineUser, ntnu_username="testesen") groups = [ INFORMATICS_MASTER_STUDY_PROGRAMME, load_course(PVS_ACTIVE, active=True), diff --git a/apps/events/tests/api_tests.py b/apps/events/tests/api_tests.py index 6dbcc9e7a..93b587ad4 100644 --- a/apps/events/tests/api_tests.py +++ b/apps/events/tests/api_tests.py @@ -487,7 +487,7 @@ def test_event_with_group_restriction(self): self.assertEqual(response.status_code, status.HTTP_200_OK) restricted_to_group: Group = G(Group) - G(GroupRestriction, event=self.event, group=restricted_to_group) + G(GroupRestriction, event=self.event, groups=[restricted_to_group]) response = self.client.get(self.id_url(self.event.id), **self.headers) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) @@ -502,7 +502,9 @@ def test_event_with_group_restriction(self): class AttendAPITestCase(OIDCTestCase): def setUp(self): self.committee = G(Group, name="Arrkom") - self.user = G(OnlineUser, name="test_user", groups=[self.committee]) + self.user = G( + OnlineUser, first_name="Test", last_name="Testesen", groups=[self.committee] + ) self.token = self.generate_access_token(self.user) self.headers = { **self.generate_headers(), diff --git a/apps/events/tests/utils.py b/apps/events/tests/utils.py index f074a1d38..895caf232 100644 --- a/apps/events/tests/utils.py +++ b/apps/events/tests/utils.py @@ -58,7 +58,9 @@ def add_payment_delay(payment: Payment, user: OnlineUser) -> PaymentDelay: def generate_user(username: str) -> OnlineUser: - user = G(OnlineUser, username=username, ntnu_username=username) + user = G( + OnlineUser, username=username, ntnu_username=username, phone_number="12345678" + ) G(Email, user=user) return user diff --git a/apps/gsuite/mail_syncer/tests/apiclient_utils_tests.py b/apps/gsuite/mail_syncer/tests/apiclient_utils_tests.py index 72162aa50..525ffac9a 100644 --- a/apps/gsuite/mail_syncer/tests/apiclient_utils_tests.py +++ b/apps/gsuite/mail_syncer/tests/apiclient_utils_tests.py @@ -282,7 +282,12 @@ def test_get_g_suite_users_for_group_no_members(self, mocked_g_suite_client): @patch("apps.gsuite.mail_syncer.utils.setup_g_suite_client", autospec=True) def test_get_g_suite_groups_for_user(self, mocked_g_suite_client): - user = G(OnlineUser) + user = G( + OnlineUser, + first_name="Test", + last_name="Testesen", + online_mail="test.testesen", + ) ow4_gsuite_sync = settings.OW4_GSUITE_SYNC ow4_gsuite_sync["ENABLED"] = True @@ -306,7 +311,12 @@ def test_get_g_suite_groups_for_user(self, mocked_g_suite_client): @patch("apps.gsuite.mail_syncer.utils.setup_g_suite_client", autospec=True) def test_get_g_suite_groups_for_user_no_members(self, mocked_g_suite_client): - user = G(OnlineUser) + user = G( + OnlineUser, + first_name="Test", + last_name="Testesen", + online_mail="test.testesen", + ) ow4_gsuite_sync = settings.OW4_GSUITE_SYNC ow4_gsuite_sync["ENABLED"] = True diff --git a/apps/gsuite/mail_syncer/tests/utils_tests.py b/apps/gsuite/mail_syncer/tests/utils_tests.py index 2d9560fb2..f7cc19f93 100644 --- a/apps/gsuite/mail_syncer/tests/utils_tests.py +++ b/apps/gsuite/mail_syncer/tests/utils_tests.py @@ -44,7 +44,12 @@ def test_get_user_no_params(self): self.assertRaises(ValueError, lambda: get_user(object)) def test_get_user(self): - user = G(OnlineUser) + user = G( + OnlineUser, + first_name="Test", + last_name="Testesen", + online_mail="test.testesen", + ) self.assertEqual(user, get_user(user, ow4=True)) self.assertEqual(user.online_mail, get_user(user, gsuite=True)) diff --git a/apps/payment/tests/view_tests.py b/apps/payment/tests/view_tests.py index 749cdd949..89b345afe 100644 --- a/apps/payment/tests/view_tests.py +++ b/apps/payment/tests/view_tests.py @@ -20,7 +20,7 @@ def setUp(self): self.attendance_event = G( AttendanceEvent, event=self.event, - unnatend_deadline=timezone.now() + timedelta(days=1), + unattend_deadline=timezone.now() + timedelta(days=1), ) self.user = G( User, diff --git a/apps/webshop/serializers.py b/apps/webshop/serializers.py index 143e2087c..43ce20ca4 100644 --- a/apps/webshop/serializers.py +++ b/apps/webshop/serializers.py @@ -63,20 +63,9 @@ class CurrentOrderLineDefault(serializers.CurrentUserDefault): Gets the currently active order_line for the logged in user """ - def __init__(self, *args, **kwargs): - self.order_line = None - super().__init__(*args, **kwargs) - - def set_context(self, serializer_field): - # Call set_context to set the user in the context of this object - super().set_context(serializer_field) - self.order_line = self.get_or_create_order_line() - - def get_or_create_order_line(self) -> OrderLine: - return OrderLine.get_current_order_line_for_user(self.user) - - def __call__(self): - return self.order_line + def __call__(self, serializer_field): + user = super().__call__(serializer_field) + return OrderLine.get_current_order_line_for_user(user) class OrderCreateSerializer(serializers.ModelSerializer): diff --git a/requirements.txt b/requirements.txt index 5fe237f61..d3db3a6cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,13 +18,13 @@ PyMuPDF==1.16.5 # django-filebrowser==3.12.1 # File uploading git+https://github.com/sehmaschine/django-filebrowser.git@4c1a86d67cd7424df57b0e6880152b309823f009#egg=django-filebrowser==3.12.2 git+https://github.com/dotKom/django-chunks.git@e6bf109d4fd286964024c140ac1b8f3d86713540#egg=django-chunks==0.4 -django-crispy-forms==1.8.1 # nice forms +django-crispy-forms==1.9.0 # nice forms django-extensions==2.2.8 # nice extra commands for debugging, etc -django-dynamic-fixture==3.0.2 # Dynamic fixtures for models +django-dynamic-fixture==3.1.0 # Dynamic fixtures for models django-recaptcha==2.0.6 # Google ReCaptcha django-oauth-toolkit==1.2.0 # OAuth2 authentication support django-watson==1.5.4 # Indexed model search lib -django-reversion==3.0.5 # Model version history with middleware hooks to all post_save signals +django-reversion==3.0.7 # Model version history with middleware hooks to all post_save signals django-guardian==2.2.0 # Per Object permissions framework django-taggit==1.2.0 # Generic multi-model tagging library django-taggit-serializer==0.1.7 # REST Framework serializers for Django-taggit @@ -50,8 +50,7 @@ coreapi==2.3.3 # API documentation requests[security]==2.22.0 # Wiki -# wiki==0.6 -git+https://github.com/django-wiki/django-wiki.git@f19f3e5d729e887054513229c727015f1eaed712#egg=wiki==0.5.1 +wiki==0.6b1 # Django 1.9 support sorl-thumbnail==12.6.2