Example #1
0
Including another URLconf
    1. Add an import:  from blog import urls as blog_urls
    2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url, patterns
from django.contrib import admin
from rest_framework import routers
from rest_framework_nested import routers
from authentication.views import AccountViewSet, IndexView, LoginView, LogoutView
from posts.views import AccountPostsViewSet, PostViewSet

router = routers.SimpleRouter()
router.register(r'accounts', AccountViewSet)
router.register(r'posts', PostViewSet)
accounts_router = routers.NestedSimpleRouter(
    router, r'accounts', lookup='account'
)
accounts_router.register(r'posts', AccountPostsViewSet)

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'^api/v1/', include(router.urls)),
    url(r'^api/v1/', include(router.urls)),
    url(r'^api/v1/', include(accounts_router.urls)),
    # url(r'^api/v1/accounts', AccountViewSet.as_view({
    #     'get': 'list',
    #     'post': 'create'
    #     }), name='account'),
     url(r'^api/v1/auth/login/$', LoginView.as_view(), name='login'),
    url(r'^api/v1/auth/logout/$', LogoutView.as_view(), name='logout'),
    url('^.*$', IndexView.as_view(), name='index'),
Example #2
0
            raise serializers.ValidationError(("School's max student limit is reached"))
        instance.school = validated_data.get('school', instance.school)
        instance.first_name = validated_data.get('first_name', instance.first_name)
        instance.last_name = validated_data.get('last_name', instance.last_name)
        instance.student_identification = validated_data.get('student_identification', instance.student_identification)
        instance.save()
        return instance


class StudentViewSet(viewsets.ModelViewSet):
    queryset = Student.objects.all()
    serializer_class = StudentSerializer

    def get_queryset(self):
        return Student.objects.filter(school=self.kwargs['school_pk'])

router = routers.DefaultRouter()
router.register(r'endpoint/schools', SchoolViewSet, base_name='schools')


school_router = routers.NestedSimpleRouter(router, r'endpoint/schools', lookup='school')
school_router.register(r'students', StudentViewSet, base_name='student')


urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^', include(router.urls)),
    url(r'^', include(school_router.urls)),
    url(r'^api-auth/', include('rest_framework.urls')),
]
Example #3
0
from django.urls.conf import include
from .views import CommentsViewSet, IssuesViewSet, RegisterAPI, ProjectViewSet, ContributorViewSet
from django.urls import path
from rest_framework_simplejwt.views import (TokenObtainPairView,
                                            TokenRefreshView)
from rest_framework import routers
from rest_framework_nested import routers

router = routers.DefaultRouter()
router.register(r'projects', ProjectViewSet, basename="Project")

project_router = routers.NestedSimpleRouter(router,
                                            r'projects',
                                            lookup='project')
project_router.register(r'users', ContributorViewSet, basename='project-users')
issues_routeur = routers.NestedSimpleRouter(router,
                                            r'projects',
                                            lookup='project')
issues_routeur.register(r'issues', IssuesViewSet, basename='project-issues')
comments_routeur = routers.NestedSimpleRouter(issues_routeur,
                                              r'issues',
                                              lookup='issue')
comments_routeur.register(r'comments', CommentsViewSet, basename='comment')

urlpatterns = [
    path('', include(router.urls)),
    path('', include(project_router.urls)),
    path('', include(issues_routeur.urls)),
    path('', include(comments_routeur.urls)),
    path('signup', RegisterAPI.as_view(), name='register'),
    path('login', TokenObtainPairView.as_view(), name='token_obtain_pair'),
Example #4
0
   ),
   generator_class=views.SwaggerSchema,
   public=True,
)


router = routers.DefaultRouter(trailing_slash=False)
router.register(r'tasks', views.TaskViewSet)
router.register(r'task-services', views.TaskServiceViewSet)
router.register(r'releases', views.ReleaseViewSet)
router.register(r'release-notes', views.ReleaseNoteViewSet)
router.register(r'events', views.EventViewSet, 'events-detail')
router.register(r'studies', views.StudiesViewSet, 'studies')

study_router = routers.NestedSimpleRouter(router, r'studies',
                                          trailing_slash=False,
                                          lookup='study')
study_router.register(r'releases', views.StudyReleasesViewSet,
                      basename='study-releases')

urlpatterns = [
    url(r'^', include(router.urls)),
    url(r'^', include(study_router.urls)),
    url(r'^django-rq/', include('django_rq.urls')),
    url(r'^swagger(?P<format>\.json|\.yaml)$',
        schema_view.without_ui(cache_timeout=None), name='schema-json'),
    url(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=None),
        name='schema-swagger-ui'),
    url(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=None),
        name='schema-redoc'),
    path('graphql', csrf_exempt(GraphQLView.as_view(graphiql=True))),
Example #5
0
from django.conf.urls import url
from rest_framework import routers
from rest_framework.urlpatterns import format_suffix_patterns
from rest_framework_nested import routers

from app_name.views.v1.test_session_controller import BusView, StationView, StationScheduleView, ReserveScheduleView, \
    ReservationView

router = routers.SimpleRouter(trailing_slash=False)
# router.register(r'test_session', TestSessionView, base_name='test_session')
# urlpatterns = router.urls
# /bus, /station, /schedule, /reserve
router.register(r'bus', BusView, base_name='bus')
router.register(r'station', StationView, base_name='station')
router.register(r'schedule', ReserveScheduleView, base_name='schedule')
router.register(r'reservation', ReservationView, base_name='reservation')

# /station/pk/info
station_route = routers.NestedSimpleRouter(router,
                                           r'station',
                                           lookup='station',
                                           trailing_slash=False)
station_route.register(r'schedule',
                       StationScheduleView,
                       base_name='station schedule')

urlpatterns = []

urlpatterns += router.urls
urlpatterns += station_route.urls
Example #6
0
File: urls.py Project: PIWEEK/plin
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
from rest_framework import routers
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
from rest_framework_nested import routers

from trips.viewsets import TripViewSet, PlanViewSet, DayViewSet
from users.viewsets import CreateUserViewSet, MeView

router = routers.DefaultRouter()
router.register(r'users', CreateUserViewSet, basename='users')
router.register(r'trips', TripViewSet, basename='trip')

# Automatic routes for nested viewsets
trips_router = routers.NestedSimpleRouter(router, r'trips', lookup='trip')
trips_router.register(r'plans', PlanViewSet, basename='plan')
trips_router.register(r'days', DayViewSet, basename='day')

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/', include(trips_router.urls)),
    path('api/', include(router.urls)),
    path('api/me/', MeView.as_view(), name='me'),
    path('api/token/', TokenObtainPairView.as_view(),
         name='token_obtain_pair'),
    path('api/token/refresh/',
         TokenRefreshView.as_view(),
         name='token_refresh'),
    path('api-auth/',
         include('rest_framework.urls')),  # login to the browsable api
Example #7
0
from django.urls import include,path
from rest_framework import routers
from rest_framework_nested import routers
from .views import *
from rest_framework_jwt.views import obtain_jwt_token, refresh_jwt_token,verify_jwt_token

router=routers.DefaultRouter()
router.register(r'users',UserViewSet)#get auth user info
# router.register(r'profile',UserProfile)#get user profile
# router.register(r'view', UserViewSet, basename='user')
router.register(r'ContactUs', ContactUs, basename='Contact_Us')#Contact us post and get all for admin
router.register(r'User', User_Profile, 'User')#User apis
router.register(r'Password', Password, 'Password')#User apis

contact_router = routers.NestedSimpleRouter(router, r'User', lookup='User')
contact_router.register(r'Verify', User_Profile, base_name='User-Username')


# router.register(r'mixins', SnippetDetail)#User apis
# router.register(r'Profile', Profile,)#User apis


urlpatterns=[
    path('', include(router.urls)),
    # path('Profile/<int:pk>/', Profile.as_view()),#url for get/put/delete user profile with mixins
    path('api-token-auth/', obtain_jwt_token),#login
    path('api-token-refresh/', refresh_jwt_token),#refresh token
    path('api-token-verify/', verify_jwt_token),# verify token
    path('', include(contact_router.urls)),
    path('check', check),
Example #8
0
from django.urls import path, include
from rest_framework import routers

from .views import (UserViewSet, SubmissionsViewSet, CustomAuthToken,
                    UserProfileView)

router = routers.DefaultRouter()
router.register(r'', UserViewSet)

assignments_router = routers.NestedSimpleRouter(router, r'', lookup='list')
assignments_router.register(r'submissions',
                            SubmissionsViewSet,
                            basename='submissions')

urlpatterns = [
    path('', include(router.urls)),
    path('<int:pk>/profile/', UserProfileView.as_view(), name='user-profile'),
    path('', include(assignments_router.urls)),
    path('login', CustomAuthToken.as_view()),
    # path('authorize', CustomAuthToken.as_view()),
]
Example #9
0
from django.urls import path, include
from . import views
from rest_framework import routers
from rest_framework_nested import routers
from .views import current_user, UserList

router = routers.DefaultRouter()
router.register(r'profiles', views.ProfileView)

profile_router = routers.NestedSimpleRouter(
    router, r'profiles', lookup='profile')
profile_router.register(
    r'tournaments', views.TournamentView, base_name='profile-tournaments')

tournament_router = routers.NestedSimpleRouter(
    profile_router, r'tournaments', lookup='tournament')
tournament_router.register(
    r'events', views.EventView, base_name='tournament-events')

event_router = routers.NestedSimpleRouter(
    tournament_router, r'events', lookup='event')
event_router.register(
    r'participants', views.ParticipantView, base_name='event-participants')

# router.register("tournaments", views.TournamentView)
# router.register('events', views.EventView)
# router.register('participants', views.ParticipantView)


urlpatterns = [
    path(r'', include(router.urls)),
from django.urls import path, include
from rest_framework import routers
from django import urls
from rest_framework_nested import routers

from . import views

router = routers.SimpleRouter()
router.register(r'quotes', views.QuoteModelViewSet, basename='quote')

quote_router = routers.NestedSimpleRouter(router, r'quotes', lookup='quote')
quote_router.register(r'publications',
                      views.PublicationModelViewSet,
                      basename='publication')

quote_router.register(r'approvedmembers',
                      views.ApprovedMemberViewSet,
                      basename='approved')

app_name = 'dashboard'

urlpatterns = [
    path('', include(router.urls)),
    path('', include(quote_router.urls)),
]
Example #11
0
from rest_framework_extensions.routers import NestedRouterMixin
from rest_framework_nested import routers
from . import views

router = routers.SimpleRouter()
router.register(r'users', UserViewSet)
router.register(r'cycles', CycleViewSet)
router.register(r'cycleinfos', CycleInfoViewSet)
router.register(r'posts', PostViewSet)
router.register(r'comments', CommentViewSet)
router.register(r'chats', ChatViewSet)
router.register(r'messages', MessageViewSet)
router.register(r'friends', FriendViewSet)
router.register(r'userprofiles', UserProfileViewSet)

users_router = routers.NestedSimpleRouter(router, r'users', lookup='user')
users_router.register(r'profile', UserProfileViewSet, basename="userprofile")

usercycleinfo_router = routers.NestedSimpleRouter(router,
                                                  r'users',
                                                  lookup='user')
usercycleinfo_router.register(r'cycleinfo',
                              CycleInfoViewSet,
                              base_name='usercycleinfo')

userposts_router = routers.NestedSimpleRouter(router, r'users', lookup='user')
userposts_router.register(r'posts', PostViewSet, base_name='userpost')

urlpatterns = [
    path('', include(router.urls)),
    path('auth/', include('rest_auth.urls')),
Example #12
0
router.register('accommodation', views.AccommodationView)
router.register('accommodationImage', views.AccommodationImageView)
router.register('accommodationHosting', views.AccommodationHostingView)
router.register('booking', views.BookingView)
router.register('users', views.Users)
router.register('reviews', views.GetReviews)
router.register('search', views.SearchViews)
router.register('searchHosting',
                views.SearchHostingViews,
                base_name='searchHosting')
router.register('reviewCounter', views.ReviewCountViews)
router.register('bookRequest', views.BookRequestViews)
""" accomodation nested resources setup """
accommodation_router = routers.NestedSimpleRouter(router,
                                                  r'accommodation',
                                                  lookup='accommodation')
accommodation_router.register(r'reviews', views.AccomodationReviews)
""" users nested resources setup """
user_router = routers.NestedSimpleRouter(router, r'users', lookup='user')
user_router.register(r'reviews', views.UserReviews)

urlpatterns = [
    path('rest-auth/', include('rest_auth.urls')),
    url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
    url(r'^rest-auth/facebook/$',
        views.FacebookLogin.as_view(),
        name='fb_login'),
    url(r'^rest-auth/twitter/$',
        views.TwitterLogin.as_view(),
        name='twitter_login'),
Example #13
0
from django.urls import path, include
from rest_framework import routers
from rest_framework_nested import routers

from . import views

router = routers.SimpleRouter()
router.register('course', views.CourseViewSet),
router.register('class', views.ClassViewSet)
router.register('section', views.SectionViewSet)

course_router = routers.NestedSimpleRouter(router, r'course', lookup='course')
course_router.register(r'class',
                       views.CourseClassViewSet,
                       base_name='course-class')

examTerm_router = routers.NestedSimpleRouter(router, r'class', lookup='class')
examTerm_router.register(r'term',
                         views.ClassExamTermViewSet,
                         base_name='class-term')

section_router = routers.NestedSimpleRouter(router, r'class', lookup='class')
section_router.register(r'section',
                        views.ClassSectionViewset,
                        base_name='class-section')

urlpatterns = [
    path('', include(router.urls)),
    path('', include(course_router.urls)),
    path('', include(examTerm_router.urls)),
    path('', include(section_router.urls)),
Example #14
0
import rest_framework.routers
from django.urls import include, re_path
from rest_framework_nested import routers

from . import views

router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)
router.register(r'groups', views.GroupViewSet)
router.register(r'departments',
                views.DepartmentViewSet,
                base_name='departments')

department_router = routers.NestedSimpleRouter(router,
                                               r'departments',
                                               lookup='department')
department_router.register(r'courses',
                           views.CourseViewSet,
                           base_name='courses')

course_router = routers.NestedSimpleRouter(department_router,
                                           r'courses',
                                           lookup='course')
course_router.register(r'sections', views.SectionViewSet, base_name='sections')

direct_router = rest_framework.routers.SimpleRouter()
direct_router.register(r"sections",
                       views.DirectSectionViewSet,
                       base_name='sections_direct')

app_name = "api"
Example #15
0
                    HealthOfficerViewSet, DataViewSet, PatientDataViewSet,
                    ECGDataViewSet, EDADataViewSet, EMGDataViewSet,
                    AccelerometerDataViewSet, CustomObtainAuthToken)

router = routers.DefaultRouter()
router.register(r'users', UserViewSet)
router.register(r'patients', PatientViewSet)
router.register(r'datalist', DataViewSet)
router.register(r'healthofficers', HealthOfficerViewSet)
router.register(r'ecg', ECGDataViewSet)
router.register(r'eda', EDADataViewSet)
router.register(r'emg', EMGDataViewSet)
router.register(r'accelerometer', AccelerometerDataViewSet)

patients_router = routers.NestedSimpleRouter(router,
                                             r'patients',
                                             lookup='user')
patients_router.register(r'patientdata',
                         PatientDataViewSet,
                         basename='patient-data')

urlpatterns = [
    #path('', views.home, name='api-home'),
    path(r'register', RegisterAPI.as_view(), name='register'),
    path(r'login', LoginAPI.as_view(), name='login'),
    path(r'logout', knox_views.LogoutView.as_view(), name='logout'),
    path(r'logoutall', knox_views.LogoutAllView.as_view(), name='logoutall'),
    path(r'authenticate', CustomObtainAuthToken.as_view(),
         name='authenticate'),
    path(r'', include(router.urls)),
    path(r'', include(patients_router.urls)),
Example #16
0
from django.urls import include, path
from rest_framework import routers
from rest_framework_nested import routers
from users.views import UserListView
from portfolio.views import PortfolioViewSet, TransactionViewSet

router = routers.DefaultRouter()
router.register(r'portfolio', PortfolioViewSet, basename='portfolios')

portfolio_router = routers.NestedSimpleRouter(router,
                                              r'portfolio',
                                              lookup='portfolio')
portfolio_router.register(r'transaction',
                          TransactionViewSet,
                          basename='transactions')

urlpatterns = [
    path('users/', include('users.urls')),
    path('rest-auth/', include('rest_auth.urls')),
    path('rest-auth/registration/', include('rest_auth.registration.urls')),
    path('', include(router.urls)),
    path('', include(portfolio_router.urls)),
]