Exemplo n.º 1
0
    def test_authenticated(self, user: User, rf: RequestFactory):
        request = rf.get("/fake-url/")
        request.user = UserFactory()

        response = UserDetailView.as_view()(request, username=user.username)

        assert response.status_code == 200
Exemplo n.º 2
0
    def test_not_authenticated(self, user: User, rf: RequestFactory):
        request = rf.get("/fake-url/")
        request.user = AnonymousUser()  # type: ignore

        response = UserDetailView.as_view()(request, username=user.username)

        assert response.status_code == 302
        assert response.url == "/accounts/login/?next=/fake-url/"
Exemplo n.º 3
0
from django.urls import path

from user.views import LogoutView, SignInView, SignUpView, UserDetailView

app_name = 'user'

urlpatterns = [
    path('logout', LogoutView.as_view(), name='logout'),
    path('sign-in/', SignInView.as_view(), name='sign-in'),
    path('sign-up/', SignUpView.as_view(), name='sign-up'),
    path('detail/<slug:username>/', UserDetailView.as_view(), name='detail'),
]
Exemplo n.º 4
0
from django.urls import path
from user.views import UserListView,UserCreateView,UserDeleteView,UserUpdateView,UserDetailView,UserLoginView,UserLogoutView
app_name = 'user'

urlpatterns = [
     path('usuarios',UserListView.as_view(),name = 'listar_usuarios'),
     path('criarusuario',UserCreateView.as_view(),name = 'criar_usuario'),
     path('usuarios/<int:pk>/apagar',UserDeleteView.as_view(),name = 'deletar_usuario'),
     path('usuarios/<int:pk>/editar',UserUpdateView.as_view(),name = 'editar_usuario'),
     path('usuarios/<int:pk>/detalhar',UserDetailView.as_view(),name = 'detalhar_usuario'),
     path('usuarios/login',UserLoginView.as_view(),name='logar_usuario'),
     path('usuarios/logout',UserLogoutView.as_view(),name = 'deslogar_usuario'),
]

Exemplo n.º 5
0
    UserCreateView,
    UserUpdateView,
    UserDetailView
)

app_name = 'user'

urlpatterns = [
    url(
        r'^update/(?P<email>[\w.@+-]+)/$',
        UserUpdateView.as_view(),
        name='update-user'
    ),
    url(
        r'^delete/(?P<email>[\w.@+-]+)/$',
        UserDeleteView.as_view(),
        name='delete-user'
    ),
    url(
        r'^create/$',
        UserCreateView.as_view(),
        name='create-user'
    ),
    url(
        r'^(?P<email>[\w.@+-]+)/$',
        UserDetailView.as_view(),
        name='get-user'
    ),
    url(r'^$', UserListView.as_view(), name='users-list'),
]
Exemplo n.º 6
0
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Filename: 'urls.py'
"""Documentation"""

from django.conf.urls import include, url
from user.views import UserDetailView, UserBasicView, UserPasswordView

urlpatterns = [
    url(r'^$', UserDetailView.as_view(), name="user_detail"),
    url(r'^basic/', UserBasicView.as_view(), name="user_basic"),
    url(r'^password/', UserPasswordView.as_view(), name="user_password"),
]

if __name__ == "__main__":
    pass
Exemplo n.º 7
0
"""patstavigais_darbs_11 URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
    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.contrib import admin
from django.urls import path
from user.views import UserListView, UserDetailView, UserAddView, UserUpdateView, UserDeleteView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', UserListView.as_view()),
    path('get_user/<int:pk>/', UserDetailView.as_view(), name='get_user'),
    path('add_user/', UserAddView.as_view(), name='add_user'),
    path('edit_user/<int:pk>/', UserUpdateView.as_view(), name='edit_user'),
    path('delete_user/<int:pk>/', UserDeleteView.as_view()),
]
Exemplo n.º 8
0
from django.contrib.admin.views.decorators import staff_member_required

from news.views import NewsDetailView, NewsListView
from user.views import UserDetailView, UserSignup, UserLogin, StaffListView, UserLogout
from main.views import ContactView, MainView
from api.views import GetNews

urlpatterns = [
    # Examples:
    # url(r'^$', 'EnerWat.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', MainView.as_view(), name='home'),
    url(r'contact/?', ContactView.as_view(), name='contact'),

    # User views
    url(r'^signup/?', staff_member_required(UserSignup.as_view(), login_url='user_login'), name='user_signup'),
    url(r'^login/?', UserLogin.as_view(), name='user_login'),
    url(r'^staff/?', StaffListView.as_view(), name='user_staff'),
    url(r'^logout/?', UserLogout.as_view(), name='user_logout'),
    url(r'^profile/?', login_required(UserDetailView.as_view()), name='user_detail'),

    # API views
    url(r'^api/get-news/(?P<news_id>\d+)', GetNews.as_view(), name='api_get_news'),

    # News views
    url(r'^news/(?P<pk>\d+)', NewsDetailView.as_view(), name='news_detail'),
    url(r'^news/?$', NewsListView.as_view(), name='news_list'),
]
Exemplo n.º 9
0
from django.contrib import admin
from django.urls import path
from user.views import LoginView, RegisterView, EmailActiveView, MemberListView, LogoutView, UserDataView, UserDetailView
app_name = 'user'
urlpatterns = [
    path('login', LoginView.as_view(), name='login'),  # 登录
    path('register', RegisterView.as_view(), name='register'),  # 注册
    path('emailactive/<token>', EmailActiveView.as_view(),
         name='emailactive'),  # 电邮激活
    # path('active/<user_id>', ActiveView.as_view(), name='active'),# 用户激活
    path('memberlist', MemberListView.as_view(), name='memberlist'),  # 用户管理
    path('logout', LogoutView.as_view(), name='logout'),  # 登出
    path('data', UserDataView.as_view(), name='data'),  # 用户数据接口
    path('userdetail', UserDetailView.as_view(), name='userdetail'),  # 用户权限
]
Exemplo n.º 10
0
""" urls for the user module (/user/*) """
from django.urls import path
from django.urls.conf import include
from django.contrib.auth.views import LoginView, LogoutView, PasswordChangeView
from user.views import UserListView, UserCreateView, UserUpdateView, \
    UserDetailView, UserSettingsView, UserLoginView
from config import settings

urlpatterns = [
    path('', UserListView.as_view(), name='user_list'),
    path('new/', UserCreateView.as_view(), name='user_create'),
    path('<int:pk>/', UserDetailView.as_view(), name='user_detail'),
    path('update/', UserUpdateView.as_view(), name='user_update'),
    path('settings/', UserSettingsView.as_view(), name='user_settings'),
    path('pw/',
         PasswordChangeView.as_view(template_name='user/user_form.html'),
         name='user_pw'),
    path('login/', UserLoginView.as_view(), name='user_login'),
    path('logout/', LogoutView.as_view(), name='user_logout'),
]

if settings.DEBUG:
    import debug_toolbar
    urlpatterns = [
        path('__debug__/', include(debug_toolbar.urls)),
    ] + urlpatterns
Exemplo n.º 11
0
"""practical URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    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.contrib import admin
from django.urls import path, include
from user.views import RegisterView, UserDetailView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('register/', RegisterView.as_view(), name='register'),
    path('user_detail/<int:id>', UserDetailView.as_view(), name='user_detail'),
    path('users/', include('django.contrib.auth.urls')),
]
Exemplo n.º 12
0
"""
from django.contrib import admin
from django.urls import path, include
from user.views import UserDetailView, UserCreateAPIView, UserLoginAPIView, ChatCreateView
from django.conf import settings
from django.conf.urls.static import static
from rest_framework_swagger.views import get_swagger_view
from rest_auth import views as rest_view
from rest_framework.authtoken.views import obtain_auth_token

urlpatterns = [
    path('', include('product.urls')),
    # path('comment/', include('comments.urls')),
    path('rest-auth/', include('rest_auth.urls')),
    path('admin/', admin.site.urls),
    path('profile/<int:pk>/', UserDetailView.as_view(), name='profile'),
    path('chat/', ChatCreateView.as_view(), name='chat'),
    # path('login/', UserLoginAPIView.as_view(), name='login'),
    path('register/', UserCreateAPIView.as_view(), name='register'),
    path('login/', UserLoginAPIView.as_view(), name='login'),
    # path('rest-auth/registration/', include('rest_auth.registration.urls')),
    # path('password-reset-confirm/<uidb64>/<token>/', rest_view.PasswordResetConfirmView.as_view(),
    # 	name='password_reset_confirm'),
    path('api/docs/', get_swagger_view(title='rest')),
]

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT)
    urlpatterns += static(settings.STATIC_URL,
                          document_root=settings.STATIC_ROOT)
Exemplo n.º 13
0
from django.urls import path

from user.views import UserRegistrationView, LoginView, LogoutView, UserDetailView

app_name = 'user'

urlpatterns = [
    path('registration/',
         UserRegistrationView.as_view(),
         name='user_registration'),
    path('login/', LoginView.as_view(), name='user_login'),
    path('logout/', LogoutView.as_view(), name='user_logout'),
    path('detail/', UserDetailView.as_view(), name='detail'),
]
Exemplo n.º 14
0
# coding=utf-8
###############################################################################
# Copyright 2013 Jean-Matthieu BARBIER <*****@*****.**>
###############################################################################
# This file is part of FollowDoc
#
# FollowDoc is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# FollowDoc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with FollowDoc.  If not, see <http://www.gnu.org/licenses/>
###############################################################################

from django.conf.urls import patterns, url
from user.views import UserListView, UserCreateView, UserDetailView, \
    UserLoginView, UserUpdateView
urlpatterns = patterns('',
    url(r'^$', UserListView.as_view(), name='user_list'),
    url(r'^_create/', UserCreateView.as_view(), name='user_create'),
    url(r'^(?P<pk>[\d]+)/$', UserDetailView.as_view(), name='user_detail'),
    url(r'^(?P<pk>[\d]+)/_update/$', UserUpdateView.as_view(), name='user_update'),
    url(r'login/$', UserLoginView.as_view(), name='main_login')
)
 def test_profile_details_url_is_resolved(self):
     resolver = resolve('/user/profile/')
     self.assertEqual(resolver.func.__name__, UserDetailView.as_view().__name__)
Exemplo n.º 16
0
    def test_case_sensitivity(self, rf: RequestFactory):
        request = rf.get("/fake-url/")
        request.user = UserFactory(username="******")

        with pytest.raises(Http404):
            UserDetailView.as_view()(request, username="******")
Exemplo n.º 17
0
app = Sanic(__name__)


@app.middleware('request')
async def add_key(request):
    context.set('request', request)


@app.listener('after_server_start')
async def after_server_start(app, loop):
    if not settings.ASYNC:
        loop.set_task_factory(context.task_factory)


app.add_route(UserListView.as_view(), '/user/users')
app.add_route(UserDetailView.as_view(), '/user/users/<user_id>')


@app.route("/")
async def index(request):
    return json({"hello": "world"})

if __name__ == "__main__":
    if settings.ASYNC:
        asyncio.set_event_loop(uvloop.new_event_loop())
        server = app.create_server(
            host=settings.HOST, port=settings.PORT, return_asyncio_server=True, debug=settings.DEBUG
        )
        loop = asyncio.get_event_loop()
        loop.set_task_factory(context.task_factory)
        task = asyncio.ensure_future(server)
Exemplo n.º 18
0
from django.urls import path, include
from user.views import CreateUserView, login, UserDetailView


urlpatterns = [
    path(
        'register/', 
   CreateUserView.as_view(), 
    ),
    path(
        'login/', login
        ),
    path(
        '<int:pk>/', UserDetailView.as_view(),
    )
]
Exemplo n.º 19
0
from user.views import UserUpdateView


urlpatterns = patterns(
    '',

    url(
        r'^login/$',
        'django.contrib.auth.views.login',
        {
            'authentication_form': CustomAuthenticationForm,
        },
        name='login',
    ),

    url(r'^usuario/$', UserDetailView.as_view(), name='me'),

    url(
        r'^logout/$',
        'django.contrib.auth.views.logout',
        {
            'next_page': reverse_lazy('home'),
        },
        name='logout',
    ),


    url(
        r'^password/reset/$',
        'django.contrib.auth.views.password_reset',
        {