From aca54a132859158e0118a1ad302b5d00c6442b81 Mon Sep 17 00:00:00 2001 From: Artem Dumanov Date: Sat, 16 May 2020 18:52:06 +0300 Subject: [PATCH 1/9] Added views setting variables --- rest_invitations/app_settings.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rest_invitations/app_settings.py b/rest_invitations/app_settings.py index 6041164..a2d4230 100644 --- a/rest_invitations/app_settings.py +++ b/rest_invitations/app_settings.py @@ -8,6 +8,8 @@ from .serializers import \ InvitationWriteSerializer as DefaultInvitationWriteSerializer from .utils import import_callable +from .views import InvitationViewSet as DefaultInvitationViewSet +from .views import accept_invitation as default_accept_invitation # Serializers InvitationReadSerializer = import_callable( @@ -32,6 +34,21 @@ ) ) +InvitationViewSet = import_callable( + getattr( + settings, + 'INVITATION_VIEW', + DefaultInvitationViewSet + ) +) +accept_invitation = import_callable( + getattr( + settings, + 'INVITATION_ACCEPT_INVATION', + default_accept_invitation + ) +) + # Urls API_BASE_URL = getattr( settings, 'INVITATION_API_BASE_URL', 'invitations' From 709de8ea10200c7b47037424a2419168e738a883 Mon Sep 17 00:00:00 2001 From: Artem Dumanov Date: Sat, 16 May 2020 18:54:37 +0300 Subject: [PATCH 2/9] Fixed urls to consume views from settings --- rest_invitations/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_invitations/urls.py b/rest_invitations/urls.py index 36585ce..e5d7a8c 100644 --- a/rest_invitations/urls.py +++ b/rest_invitations/urls.py @@ -2,7 +2,7 @@ from rest_framework import routers from .app_settings import ACCEPT_INVITE_URL, API_BASE_URL -from .views import InvitationViewSet, accept_invitation +from .app_settings import (InvitationViewSet, accept_invitation) router = routers.SimpleRouter() router.register(r'{0}'.format(API_BASE_URL), InvitationViewSet) From 7cdfd20ce35e816ad324b0da713770398f33ed98 Mon Sep 17 00:00:00 2001 From: Artem Dumanov Date: Sat, 16 May 2020 22:05:47 +0300 Subject: [PATCH 3/9] Moved views callable import to the urls --- rest_invitations/urls.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rest_invitations/urls.py b/rest_invitations/urls.py index e5d7a8c..ada786f 100644 --- a/rest_invitations/urls.py +++ b/rest_invitations/urls.py @@ -3,6 +3,20 @@ from .app_settings import ACCEPT_INVITE_URL, API_BASE_URL from .app_settings import (InvitationViewSet, accept_invitation) +InvitationViewSet = import_callable( + getattr( + settings, + 'INVITATION_VIEW', + DefaultInvitationViewSet + ) +) +accept_invitation = import_callable( + getattr( + settings, + 'INVITATION_ACCEPT_INVATION', + default_accept_invitation + ) +) router = routers.SimpleRouter() router.register(r'{0}'.format(API_BASE_URL), InvitationViewSet) From 532c228035e9c3a2a45abca2e43afea452698018 Mon Sep 17 00:00:00 2001 From: Artem Dumanov Date: Sat, 16 May 2020 22:07:07 +0300 Subject: [PATCH 4/9] Removed callable views import from app_settings --- rest_invitations/app_settings.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/rest_invitations/app_settings.py b/rest_invitations/app_settings.py index a2d4230..6041164 100644 --- a/rest_invitations/app_settings.py +++ b/rest_invitations/app_settings.py @@ -8,8 +8,6 @@ from .serializers import \ InvitationWriteSerializer as DefaultInvitationWriteSerializer from .utils import import_callable -from .views import InvitationViewSet as DefaultInvitationViewSet -from .views import accept_invitation as default_accept_invitation # Serializers InvitationReadSerializer = import_callable( @@ -34,21 +32,6 @@ ) ) -InvitationViewSet = import_callable( - getattr( - settings, - 'INVITATION_VIEW', - DefaultInvitationViewSet - ) -) -accept_invitation = import_callable( - getattr( - settings, - 'INVITATION_ACCEPT_INVATION', - default_accept_invitation - ) -) - # Urls API_BASE_URL = getattr( settings, 'INVITATION_API_BASE_URL', 'invitations' From 36d18873eca9d4109b561a0ec1bbcd1958bcc05a Mon Sep 17 00:00:00 2001 From: Artem Dumanov Date: Sat, 16 May 2020 22:11:40 +0300 Subject: [PATCH 5/9] Fixed import --- rest_invitations/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_invitations/urls.py b/rest_invitations/urls.py index ada786f..68debb9 100644 --- a/rest_invitations/urls.py +++ b/rest_invitations/urls.py @@ -2,7 +2,7 @@ from rest_framework import routers from .app_settings import ACCEPT_INVITE_URL, API_BASE_URL -from .app_settings import (InvitationViewSet, accept_invitation) +from .views import (InvitationViewSet, accept_invitation) InvitationViewSet = import_callable( getattr( settings, From c673fda520e4ee7d0d762b05df4b09879a347581 Mon Sep 17 00:00:00 2001 From: Artem Dumanov Date: Sat, 16 May 2020 22:13:03 +0300 Subject: [PATCH 6/9] Added callable import --- rest_invitations/urls.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rest_invitations/urls.py b/rest_invitations/urls.py index 68debb9..b9e2bac 100644 --- a/rest_invitations/urls.py +++ b/rest_invitations/urls.py @@ -3,6 +3,8 @@ from .app_settings import ACCEPT_INVITE_URL, API_BASE_URL from .views import (InvitationViewSet, accept_invitation) +from .utils import import_callable + InvitationViewSet = import_callable( getattr( settings, From 9045162c054a491f6f9844c29a6a2197d7bfc0df Mon Sep 17 00:00:00 2001 From: Artem Dumanov Date: Sat, 16 May 2020 22:14:01 +0300 Subject: [PATCH 7/9] Update urls.py --- rest_invitations/urls.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rest_invitations/urls.py b/rest_invitations/urls.py index b9e2bac..1056eb3 100644 --- a/rest_invitations/urls.py +++ b/rest_invitations/urls.py @@ -4,6 +4,7 @@ from .app_settings import ACCEPT_INVITE_URL, API_BASE_URL from .views import (InvitationViewSet, accept_invitation) from .utils import import_callable +from django.conf import settings InvitationViewSet = import_callable( getattr( From 040c8984eb94df52f41bf6544770abe5bdbdd98c Mon Sep 17 00:00:00 2001 From: Artem Dumanov Date: Sat, 16 May 2020 22:14:55 +0300 Subject: [PATCH 8/9] Update urls.py --- rest_invitations/urls.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rest_invitations/urls.py b/rest_invitations/urls.py index 1056eb3..545118f 100644 --- a/rest_invitations/urls.py +++ b/rest_invitations/urls.py @@ -10,14 +10,14 @@ getattr( settings, 'INVITATION_VIEW', - DefaultInvitationViewSet + InvitationViewSet ) ) accept_invitation = import_callable( getattr( settings, 'INVITATION_ACCEPT_INVATION', - default_accept_invitation + accept_invitation ) ) From 6cb06394b285a7a7a2eea2b359a820121c9b34c9 Mon Sep 17 00:00:00 2001 From: Artem Dumanov Date: Sat, 18 Dec 2021 19:58:14 +0200 Subject: [PATCH 9/9] Update utils.py Delete print --- rest_invitations/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rest_invitations/utils.py b/rest_invitations/utils.py index d5d38d5..7e24ba2 100644 --- a/rest_invitations/utils.py +++ b/rest_invitations/utils.py @@ -6,5 +6,4 @@ def import_callable(path): return path else: module, attr_name = path.rsplit('.', 1) - print(module, attr_name) return getattr(import_module(module), attr_name)