from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter from django_urls import UrlManager from rest_auth.registration.views import ( SocialLoginView, SocialConnectView, SocialAccountDisconnectView, ) from rest_framework.routers import APIRootView from ...utils.urls import url_mapping google_urls = UrlManager() @google_urls.path('login/', name='google_login') class GoogleLogin(SocialLoginView): adapter_class = GoogleOAuth2Adapter @google_urls.path('connect/', name='google_connect') class GoogleConnect(SocialConnectView): ... @google_urls.path('disconnect/', name='google_disconnect') class GoogleDisconnect(SocialAccountDisconnectView): ... @google_urls.path('', name='google') class Google(APIRootView):
from rest_framework.routers import APIRootView from utils.urls import url_mapping from . import views from .router import RooterWithUrls router = RooterWithUrls() router.register(r'entries', views.EntryViewSet) router.register(r'users', views.UserViewSet) router.register(r'titles', views.TitleViewSet) router.register(r'title_channels', views.TitleChannelViewSet) router.register(r'events', views.EventViewSet) router.register(r'user_trophies', views.UserTrophyViewSet) router.register(r'notifications', views.NotificationViewSet) rest_auth_registration_urls = UrlManager() rest_auth_registration_urls.extend(_rest_auth_registration_urls) rest_auth_urls = UrlManager() rest_auth_urls.extend(_rest_auth_urls) @rest_auth_registration_urls.path('', name='auth_registration') class Registration(APIRootView): """Registration endpoints.""" api_root_dict = url_mapping(rest_auth_urls.url_patterns) rest_auth_urls.extend( [path('registration/', include(rest_auth_registration_urls.url_patterns))])
from django.urls import path, include from django_urls import UrlManager from rest_framework.routers import APIRootView from .google import google_urls from ...utils.urls import url_mapping social_auth_urls = UrlManager() social_auth_urls.extend([ path('google/', include((google_urls.url_patterns, 'api'), namespace='google_auth')) ]) @social_auth_urls.path('', name='social_auth') class SocialAuthentication(APIRootView): """Third party authentication endpoints.""" api_root_dict = url_mapping(social_auth_urls.url_patterns, 'api')
from django.conf.urls import re_path from django_private_chat import views from django_urls import UrlManager mainsite_urls = UrlManager(views_root='mainsite.views') message_urlpatterns = [ re_path(r'^message/(?P<username>[a-zA-Z0-9-]+)', views.DialogListView.as_view(), name='message'), ] mainsite_urls._url_patterns += message_urlpatterns
from django.http import Http404 from django_urls import UrlManager from rest_framework import status from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from rest_framework.routers import APIRootView from rest_framework.views import APIView from apps.sour_and_perky.models import Entry, User, Title from utils.urls import url_mapping from ..serializer import (EntryLikeSerializer, EntryDislikeSerializer, EntryFavSerializer, UserFollowSerializer, TitleFollowSerializer) relation_urls = UrlManager() def relation_add_remove(model): class GenericRelationAddRemoveMixin: """@DynamicAttrs.""" permission_classes = (IsAuthenticated, ) @staticmethod def get_object(pk): try: return model.objects.get(pk=pk) except model.DoesNotExist: raise Http404 def post(self, request, format=None):