def test_create_user(self): request = self.factory.post( "/create-user/", { "username": "******", "email": "*****@*****.**", "password": "******", }, ) response = CreateUserView.as_view()(request) assert response.status_code == 201 assert set(response.data.keys()) == {"id", "username", "email"} assert User.objects.get( username="******").email == "*****@*****.**"
from django.conf.urls import url from permissions.views import AddPermissionView, DeletePermissionView, EditPermissionView from users.views import CreateUserView, UserListView, ManageUserView urlpatterns = [ url(r'new', CreateUserView.as_view(), name='create_user'), url(r'(?P<user_id>[\w\-]+)/manage', ManageUserView.as_view(), name='manage_user'), url(r'(?P<user_id>[\w\-]+)/add_permission', AddPermissionView.as_view(), name='add_permission'), url(r'(?P<user_id>[\w\-]+)/edit_permission/(?P<permission_id>[\w\-]+)', EditPermissionView.as_view(), name="edit_permission"), url(r'(?P<user_id>[\w\-]+)/delete_permission/(?P<permission_id>[\w\-]+)', DeletePermissionView.as_view(), name='delete_permission'), url(r'', UserListView.as_view(), name='user_list') ]
from posts.api import PostViewSet from posts.views import PostDetailView, BlogDetailView, CreatePostView, HomeView from users.api import UsersAPI, UserDetailAPI from users.views import LoginView, LogoutView, CreateUserView router = DefaultRouter() router.register('posts', PostViewSet) urlpatterns = [ path('admin/', admin.site.urls), path('', HomeView.as_view(), name='home'), path('blogs/<str:username>/<int:pk>', PostDetailView.as_view(), name='post_detail'), path('blogs/', BlogListView.as_view()), path('blogs/<str:username>/', BlogDetailView.as_view()), path('login', LoginView.as_view(), name='login'), path('logout', LogoutView.as_view(), name='logout'), path('new-post', CreatePostView.as_view(), name='new_post'), path('new-blog', CreateBlogView.as_view(), name='new_blog'), path('signup', CreateUserView.as_view(), name='new_user'), # API URLs path('api/v1/', include(router.urls)), path('api/v1/users/', UsersAPI.as_view(), name='api-user'), path('api/v1/users/<int:pk>/', UserDetailAPI.as_view(), name='api-user-detail'), path('api/v1/blogs/', BlogListAPI.as_view(), name='api-blogs'), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# /wallets/{pk}/ default_router.register('wallets', WalletViewSet, basename='wallets') ## TokenURI Router, generates: # /tokenuri/ # /tokenuri/{pk}/ default_router.register('tokenuri', TokenURIViewSet, basename='tokenuri') urlpatterns = [ path('admin/', admin.site.urls), path('api/auth/login/', LoginUserView.as_view(), name='login'), path('api/auth/logout/', LogoutUserView.as_view(), name='logout'), path('api/auth/password_update/', PasswordUpdateUserView.as_view(), name='password_update'), path('api/auth/create/', CreateUserView.as_view(), name='create_user'), path('api/auth/users/', ListUserView.as_view(), name='list_users'), path('api/auth/token/', CreateTokenView.as_view(), name='token'), path('api/auth/me/', ManageUserView.as_view(), name='me'), path('api/app/', include(default_router.urls)), path('api/app/', include(threads_nested_router.urls)), path('api/app/', include(posts_thread_nested_router.urls)), path('api/app/', include(posts_board_nested_router.urls)), ] if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.views.generic import TemplateView from rest_framework.authtoken.views import obtain_auth_token from rest_framework_swagger.views import get_swagger_view from rest_framework_swagger.renderers import OpenAPIRenderer, SwaggerUIRenderer from rest_framework.schemas import get_schema_view from rest_framework_jwt.views import obtain_jwt_token from rest_framework_jwt.views import refresh_jwt_token from rest_framework_jwt.views import verify_jwt_token from users.views import UserListView, CreateUserView, auth_user schema_view = get_swagger_view(title='Divorces API') urlpatterns = [ path('auth/', auth_user), path('register/', CreateUserView.as_view()), path('users/', UserListView.as_view()), path('users/<int:pk>/', UserListView.as_view()), path('grappelli/', include('grappelli.urls')), # grappelli URLS path('admin/', admin.site.urls), path('openapi', get_schema_view( title="Your Project", description="API for all things …" ), name='openapi-schema'), path('swagger-ui/', TemplateView.as_view( template_name='swagger-ui.html', extra_context={'schema_url':'openapi-schema'} ), name='swagger-ui'), path('redoc/', TemplateView.as_view( template_name='redoc.html', extra_context={'schema_url':'openapi-schema'}
from django.urls import path from openweather.views import CreateCityView from users.views import CreateUserView, UserFullListView, UserListView from .views import UserManageView, CityManageView, FavouriteManageView ''' Struktura je posložena tako da okupi managere na istom endpointu, uz managere idu i ostali API koji imaju različite endpointove. Kreiranje gradova prima ime grada (kw='name') i njegov API id (kw='api_id') s OpenWeatherMap API-ja. Kreiranje korisnika prima username, email i password (kw:'username', 'email', 'password'). Lista korisnika daje osnovne, nesenzitivne (relativno) podatke o korisnicima, dostupna svima. Full lista korisnika daje sve podatke o korisnicima, dostupna samo admin/superuser korisnicima. ''' urlpatterns = [ path('users/<int:pk>/', UserManageView.as_view()), path('cities/<int:pk>/', CityManageView.as_view()), path('fav/<int:api_id>/<str:name>/', FavouriteManageView.as_view()), path('cities/create/', CreateCityView.as_view()), path('users/create/', CreateUserView.as_view()), path('users/list/', UserListView.as_view()), path('users/full/', UserFullListView.as_view()), ]
url( r'^token/refresh$', refresh_jwt_token, name='refresh_token' ), url( r'^token/verify$', verify_jwt_token, name='verify_token' ), url( r'^$', CreateUserView.as_view(), name="user_create" ), url( r'^address$', AddressListCreateView.as_view(), name="address_list_create" ), url( r'^address/(?P<address_slug>\w{22})$', AddressRetrieveUpdateDestroyView.as_view(), name="address_retrieve_update_destroy" ), # url(
from django.conf.urls import include, url from django.contrib import admin from rest_framework.routers import DefaultRouter from rest_framework_jwt.views import obtain_jwt_token from tasks.views import TaskViewSet from users.views import ActivateUser, CreateUserView, UserViewSet router = DefaultRouter() router.register(r'tasks', TaskViewSet) router.register(r'users', UserViewSet) urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^', include(router.urls)), url(r'^api-auth/', obtain_jwt_token), url('^api-register/$', CreateUserView.as_view()), url( '^api-activate/(?P<token>.+?)/$', ActivateUser.as_view(), name='activate-user' ), ]
from django.urls import path from users.views import (CreateUserView, LoginView, logout_view, ProfileView) urlpatterns = [ path('signup/', CreateUserView.as_view(), name='signup'), path('login/', LoginView.as_view(), name='login'), path('logout/', logout_view, name='logout'), path('profile/', ProfileView.as_view(), name='profile'), ]
from django.conf.urls.static import static from datasets.views import (MainView, AddNewExpressionView, DeleteExpressionView, MessagesView, StatsView, AllExpressionsView, EditExpressionView, AddExpressionView) from learning.views import (TrainingView, LearningView, NextExpressionsView, NextExpressionTrainView) from users.views import (LoginView, CreateUserView, logoutUser) urlpatterns = [ path('admin/', admin.site.urls), url(r'^$', MainView.as_view(), name="index"), url(r'^login', LoginView.as_view()), url(r'^logout', logoutUser), url(r'^create_user', CreateUserView.as_view()), url(r'^create_expression', AddNewExpressionView.as_view()), url(r'^delete_expression/(?P<expression_id>(\d)+)$', DeleteExpressionView.as_view()), url(r'^learn', LearningView.as_view()), url(r'^training', TrainingView.as_view()), url(r'^messages', MessagesView.as_view()), url(r'^stats', StatsView.as_view()), url(r'^all_expressions', AllExpressionsView.as_view()), url(r'^next_expression_train', NextExpressionTrainView.as_view()), url(r'^next_expression', NextExpressionsView.as_view()), url(r'^edit_expression/(?P<pk>(\d)+)$', EditExpressionView.as_view()), url(r'^add_expression', AddExpressionView.as_view()), ] if settings.DEBUG:
from users.forms import CreateUserForm from django.urls import path from users.views import ListUsersView, CreateUserView urlpatterns = [ path('', ListUsersView.as_view(), name='users'), path('create/', CreateUserView.as_view(), name='create'), ]
1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.urls import path from rest_framework.routers import DefaultRouter from events.views import EventManagementViewSet, EventViewSet from tickets.views import OrderViewSet from users.views import CreateUserView, ObtainAuthToken router = DefaultRouter() router.register(r"admin/events", EventManagementViewSet, basename="admin_events") router.register(r"events", EventViewSet, basename="events") router.register(r"orders", OrderViewSet, basename="orders") urlpatterns = [ path("register/", CreateUserView.as_view(), name="register"), path("login/", ObtainAuthToken.as_view(), name="login"), ] urlpatterns += router.urls
from django.urls import path from users.views import CreateUserView, UserDetailView, AuthenticateView, index urlpatterns = [ path('users', CreateUserView.as_view()), path('users/<int:pk>', UserDetailView.as_view()), path('login', AuthenticateView.as_view()), path('', index), ]
2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin from django.urls import path, include from .views import Home, error_404 from django.conf import settings from django.conf.urls.static import static from users.views import DashboardUserView, LoginUserView, logout, CreateUserView urlpatterns = [ path('users', include('users.urls')), path('dashboard', DashboardUserView.as_view(), name='dashboard'), path('', LoginUserView.as_view(), name='home'), path('logout', logout, name='logout'), path('create-user', CreateUserView.as_view(), name='create_user'), path('admin/', admin.site.urls), ] handle404 = error_404 # if the DEBUG is on in settings, then append the urlpatterns as below if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
from django.conf.urls import url from users.views import CreateUserView, DeleteUserView, EditUserViewForm, UsersListView app_name = 'users' urlpatterns = [ url(r'^$', UsersListView.as_view(), name='index', ), url(r'^create/', CreateUserView.as_view(), name='create', ), url(r'^delete/(?P<pk>\d+)', DeleteUserView.as_view(), name="delete", ), url(r'^edit/(?P<pk>\d+)', EditUserViewForm.as_view(), name="edit") ]
from django.urls import path from users.views import CreateUserView app_name = "users" urlpatterns = [ path("registration/", CreateUserView.as_view(), name="registration"), ]
from django.conf.urls import include, url from django.contrib import admin from rest_framework.routers import DefaultRouter from rest_framework_jwt.views import obtain_jwt_token from tasks.views import TaskViewSet from users.views import ActivateUser, CreateUserView, UserViewSet router = DefaultRouter() router.register(r'tasks', TaskViewSet) router.register(r'users', UserViewSet) urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^', include(router.urls)), url(r'^api-auth/', obtain_jwt_token), url('^api-register/$', CreateUserView.as_view()), url('^api-activate/(?P<token>.+?)/$', ActivateUser.as_view(), name='activate-user'), ]
from django.contrib.auth import views as auth_views API_PREFIX = 'api/' urlpatterns = [ path('admin/', admin.site.urls), path('', home, name='home'), path(API_PREFIX + 'gardens/<str:name>/', GardenAPIView.as_view(), name='api-garden'), path(API_PREFIX + 'gardens/<str:name>/watering-stations/', WateringStationAPIView.as_view(), name='api-watering-stations'), path('login/', LoginView.as_view(), name='login'), path('logout/', LogoutView.as_view(), name='logout'), path('register/', CreateUserView.as_view(), name='register'), path('reset_password/', PasswordResetView.as_view(template_name='reset_password.html'), name='reset_password'), path('reset_password_sent/', auth_views.PasswordResetDoneView.as_view( template_name='reset_password_sent.html'), name='password_reset_done'), path('reset/<uidb64>/<token>/', PasswordResetConfirmView.as_view( template_name='reset_password_confirm.html'), name='password_reset_confirm'), path('reset_password_complete/', auth_views.PasswordResetCompleteView.as_view( template_name='reset_password_complete.html'), name='password_reset_complete'),
from django.urls import path from users.views import CreateUserView, AddProfileView, MakeStaffView, FullOwnInfoView, DeleteUserView, \ UpdateUserByUserView, ListUsersView, UpdateByStaffView urlpatterns = [ path('/create', CreateUserView.as_view()), path('/list', ListUsersView.as_view()), path('/<int:pk>/profile', AddProfileView.as_view()), path('/info', FullOwnInfoView.as_view()), path('/<int:pk>/make_staff', MakeStaffView.as_view()), path('/<int:pk>/delete', DeleteUserView.as_view()), path('/update_myself', UpdateUserByUserView.as_view()), path('/<int:pk>/update_by_staff', UpdateByStaffView.as_view()) ]