Exemplo n.º 1
0
    def test_get_queryset_calls_helper(self, mock_helper):
        # Given a mock that returns a sentinel
        mock_helper.return_value = sentinel.activities

        # and a view user
        view = UserView()
        view.user = sentinel.user
        view.request = Mock(user=sentinel.other)

        # When getting the queryset
        activities = view.get_queryset()

        # Then the sentinel is returned, via the helper
        assert activities == sentinel.activities
        mock_helper.assert_called_once_with(sentinel.user, sentinel.other)
Exemplo n.º 2
0
    def test_get_adds_user_to_view(self, mock_get_user_model, get_mock):
        # Given a mock that returns a sentinel user
        users_mock = Mock()
        users_mock.objects.get.return_value = sentinel.user
        mock_get_user_model.return_value = users_mock

        get_mock.return_value = sentinel.response

        view = UserView()
        view.kwargs = dict(username=sentinel.username)

        # When getting the view
        response = view.get(sentinel.request)

        # Then the sentinel user is returned, via the mock
        assert view.user == sentinel.user
        users_mock.objects.get.assert_called_with(username=sentinel.username)
        assert response == sentinel.response
        get_mock.assert_called_once_with(sentinel.request)
Exemplo n.º 3
0
    def test_get_context_data_populates_correctly(self, super_mock,
                                                  mock_helper):
        # Given a mock that returns a sentinel summary
        mock_helper.return_value = sentinel.summary
        super_mock.return_value = dict(super=sentinel.super)

        # and a mock queryset that returns a sentinel
        view = UserView()
        view.user = sentinel.user
        view.get_queryset = Mock(return_value=sentinel.activity_query_set)

        # When getting the context data
        context = view.get_context_data()

        # Then the context contains the sentinel summary, via the mock
        assert context['summaries'] == sentinel.summary
        assert context['view_user'] == sentinel.user
        assert context['super'] == sentinel.super
        mock_helper.assert_called_once_with(sentinel.activity_query_set)
Exemplo n.º 4
0
urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', post_list, name="post_list"),
    url(r'^blogs/$', blog_list, name="blog_list"),
    url(r'^blogs/(?P<user_name>[a-zA-Z0-9]+)/$', user_posts,
        name="user_posts"),
    url(r'^blogs/(?P<user_name>[a-zA-Z0-9]+)/(?P<post_pk>[0-9]+)/$',
        post_detail,
        name="post_detail"),
    url(r'^new-post/$', NewPostView.as_view(), name="post_new"),

    #Users
    url(r'^login$', LoginView.as_view(), name="login"),
    url(r'^logout$', logout, name="logout"),
    url(r'^signup$', UserView.as_view(), name="signup"),

    #API Users. Me permiten. La primera consultar los usuarios, y la segunda ver el detalle, borrar o actualizar el usuario con ese id.
    url(r'^api/1.0/users/$', UsersAPI.as_view(), name="users_api"),
    url(r'^api/1.0/users/(?P<pk>[0-9]+)/$',
        UserDetailAPI.as_view(),
        name="user_detail"),

    #API Blogs. Endpoints para listado de blogs, leer articulos de un blog y para crear, modificar y borrar posts.
    url(r'^api/1.0/blogs/$', BlogListAPI.as_view(), name="bloglist_api"),
    url(r'^api/1.0/blogs/(?P<pk>[0-9]+)/$',
        PostListAPI.as_view(),
        name="postlist_api"),
    url(r'^api/1.0/newposts/$', NewPostAPI.as_view(), name="newpost_api"),
    url(r'^api/1.0/postdetail/(?P<pk>[0-9]+)/$',
        PostDetailAPI.as_view(),
Exemplo n.º 5
0
from django.conf.urls import include, url,patterns
from django.contrib import admin
from users.views import RegisterView, IndexView,LoginView,UserView,LogoutView
from django.views.generic import View


urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'project.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),
    url(r'^$',IndexView.as_view()),

    url(r'^register$', RegisterView.as_view()),

    url(r'^login$', LoginView.as_view()),

    url(r'^logout$',LogoutView.as_view()),

    url(r'^(?P<username>[\w\-]+)$', UserView.as_view()),
)
Exemplo n.º 6
0
from django.urls import path
from tasks.views import TaskView
from categories.views import CategoryView
from users.views import UserView
from rest_auth.views import LoginView
from rest_auth.registration.views import RegisterView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('signin', LoginView.as_view(), name='rest_login'),
    path('signup', RegisterView.as_view(), name='rest_register'),
    path(
        'user/<int:pk>',
        UserView.as_view({
            'get': 'retrieve',
            'put': 'update',
            'delete': 'destroy'
        })),
    path('task/create', TaskView.as_view({'post': 'create'})),
    path(
        'task/<int:pk>',
        TaskView.as_view({
            'get': 'retrieve',
            'put': 'update',
            'delete': 'destroy'
        })),
    path('task>', TaskView.as_view({'get': 'list'})),
    path(
        'category/<int:pk>',
        CategoryView.as_view({
            'get': 'retrieve',
Exemplo n.º 7
0
from django.conf.urls.defaults import *
from piston.resource import Resource
from users.views import UserView, UserViewRoot

urlpatterns = patterns(
    '',
    url(r'^(?P<user_id>[^/]+)$', UserView.as_view(), name='user'),
    url(r'^$', UserViewRoot.as_view(), name='user_root'),
)
Exemplo n.º 8
0
from django.conf.urls import patterns, include, url
from django.contrib import admin
from users.views import MainView, LogInView, RegisterView, UserView

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'web_trader.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),
    url(r'^$', MainView.as_view(),name='index'),
    url(r'^log_in/', LogInView.as_view(),name='log_in'),
    url(r'^register/', RegisterView.as_view(),name='register'),
    url(r'^home/', UserView.as_view(),name='home'),
)
Exemplo n.º 9
0
from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter
from users.views import UsernameCountView,MobileCountView,UserView,SMSCodeToKenView,PasswordTokenView,\
    PasswordView,UserDetailView,EmailView,EmailVerifyView,AddressViewSet,UserBrowsingHistoryView,\
    UserAuthorizationView

urlpatterns = [
    url(r'^usernames/(?P<username>\w{5,20})/count/$', UsernameCountView.as_view()),#注册时判断用户名是否存在
    url(r'^mobiles/(?P<mobile>1[3-9]\d{9})/count/$', MobileCountView.as_view()),#注册时判断手机号码是否存在
    url(r'^users/$', UserView.as_view()),#注册表单提交
    url(r'^authorizations/$', UserAuthorizationView.as_view()),#注册成功后,用jwt的token,直接登陆成功,登陆页面直接请求
    url(r'^accounts/(?P<account>\w{4,20})/sms/token/$',SMSCodeToKenView.as_view()),#忘记密码找回密码需要发送短信
    url(r'^accounts/(?P<account>\w{4,20})/password/token/$',PasswordTokenView.as_view()),#忘记密码找回密码需要修改密码的token
    url(r'^users/(?P<pk>\d+)/password/$', PasswordView.as_view()),#忘记密码找回密码需要修改密码
    url(r'^user/$', UserDetailView.as_view()),#用户个人中心接口
    url(r'^emails/$', EmailView.as_view()),#邮箱验证
    url(r'^emails/verification/$', EmailVerifyView.as_view()),#邮箱激活
    url(r'^browse_histories/$', UserBrowsingHistoryView.as_view()),#历史浏览记录保存


]

router = DefaultRouter()
router.register(r'addresses', AddressViewSet, base_name='addresses')

urlpatterns += router.urls
# POST /addresses/ 新建  -> create
# PUT /addresses/<pk>/ 修改  -> update
# GET /addresses/  查询  -> list
# DELETE /addresses/<pk>/  删除 -> destroy
Exemplo n.º 10
0
from django.urls import path
from users.views import UserView, LoginView

urlpatterns = [
    path("", UserView.as_view()),
    path("/log-in", LoginView.as_view()),
]
Exemplo n.º 11
0
from django.conf.urls import url

from users.views import UserView
from rest_framework.authtoken import views

urlpatterns = [
    url(r'^$', UserView.as_view(), name="admins"),
    url(r'^(?P<user_id>\w+)$', UserView.as_view(), name="get_admins"),
    url(r'^api-token-auth/', views.obtain_auth_token),
]
Exemplo n.º 12
0
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, re_path
from rest_framework_jwt.views import obtain_jwt_token
from users.views import UserView

urlpatterns = [
    re_path('login', obtain_jwt_token),
    re_path('getinfo', UserView.as_view()),
    path('admin/', admin.site.urls),
    path('auth/', include('rest_framework.urls')),
    path('group/', include('groups.urls')),
    path('project/', include('projects.urls')),
    path('envs/', include('envs.urls')),
    path('api/', include('apis.urls')),
    path('task/', include('tasks.urls')),
    path('func/', include('funcs.urls')),
]
Exemplo n.º 13
0
Arquivo: urls.py Projeto: RA-MPR/mpr
from django.urls import re_path, path

from rest_framework.authtoken.views import obtain_auth_token
from users.views import UserOrderView, UserCreateView, UserView, UserEventView, UserCompanyView, UserAdminView, UserContactView, UserIdCompany

urlpatterns = [
    re_path(r"^$", UserView.as_view(), name="user"),
    path(r"<id>", UserIdCompany.as_view(), name="user_id_company"),
    re_path(r"^register/", UserCreateView.as_view(), name="user_registration"),
    re_path(r"^login/", obtain_auth_token, name="user_login"),
    re_path(r"^admin/", UserAdminView.as_view(), name="user_admin"),
    re_path(r"^events/", UserEventView.as_view(), name="user_event"),
    re_path(r"^companies/", UserCompanyView.as_view(), name="user_company"),
    re_path(r"^contacts/",  UserContactView.as_view(), name="user_contacts"),
    re_path(r"^orders/", UserOrderView.as_view(), name="user_orders")
]
Exemplo n.º 14
0
from django.urls import path

from users.views import UserListView, UserRoleView, UserRolesView, RegisterUserView, confirm_user, UserView, become_cook

urlpatterns = [
    path('register', RegisterUserView.as_view()),
    path('confirm/<str:email>/<str:token>', confirm_user),
    path('roles/', UserRolesView.as_view()),
    path('become-cook/', become_cook),
    path('role/<int:pk>', UserRoleView.as_view()),
    path('<int:pk>', UserView.as_view()),
    path('', UserListView.as_view()),
]
Exemplo n.º 15
0
from django.conf.urls import url, include
from django.contrib import admin

from users.views import UserView

urlpatterns = [
    url(r'^$', UserView.as_view(), name='users'),
    url(r'^edit/', UserView.as_view(), name='edit'),
    url(r'^admin/', include(admin.site.urls)),
]
Exemplo n.º 16
0
from django.urls import path
from users.views import UserView

urlpatterns = [
    path('users/', UserView.as_view(), name='user-view'),
]
Exemplo n.º 17
0
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
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
from django.contrib import admin

from question.views import QuestionsListView, QuestionView, QuestionAdd, like, AnswerAdd, popularTags, popularUsers
from users.views import LoginRequest, MyUserRegistration, LogoutRequest, UsersListView, UserView

urlpatterns = [
    url(r"^admin/", include(admin.site.urls)),
    url(r"^questions/$", QuestionsListView.as_view(), name="question-list"),
    url(r"^questions/(?P<pk>\d+)/$", QuestionView.as_view(), name="question"),
    url(r"^login/", LoginRequest, name="login"),
    url(r"^registration/", MyUserRegistration, name="registration"),
    url(r"^logout/", LogoutRequest, name="logout"),
    url(r"^question_add/", QuestionAdd, name="question_add"),
    url(r"^comment_add/$", AnswerAdd, name="comment_add"),
    url(r"^users/$", UsersListView.as_view(), name="users-list"),
    url(r"^users/(?P<pk>\d+)/$", UserView.as_view(), name="user"),
    url(r"^like/$", like, name="like"),
    url(r"^populartags/$", popularTags, name="populartags"),
    url(r"^popularusers/$", popularUsers, name="popularusers"),
]
Exemplo n.º 18
0
from users.views import UserView, UserAdminView, CustomUserCreate
from rest_framework.routers import DefaultRouter
from django.urls import path

app_name = 'users'

urlpatterns = [
    path('profile/', UserView.as_view(), name='profile'),
    path('register/', CustomUserCreate.as_view(), name='registration'),
]

router = DefaultRouter()
router.register(r'users', UserAdminView, basename='users')

urlpatterns += router.urls
Exemplo n.º 19
0
from django.contrib import admin
from django.urls import path

from users.views import UserView
from rest_framework_simplejwt.views import (
    TokenObtainPairView,
    TokenRefreshView,
    TokenVerifyView,
)

urlpatterns = [
    path("admin/", admin.site.urls),
    path("api/", UserView.as_view(graphiql=True)),
    path("auth/token/obtain/", TokenObtainPairView.as_view()),
    path("auth/token/refresh/", TokenRefreshView.as_view()),
    path("auth/token/verify/", TokenVerifyView.as_view()),
]
Exemplo n.º 20
0
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 rest_framework.routers import DefaultRouter

from authentication.views import UserAuthorization
from games.views import CurrentGameInitView, MiniGameViewSet
from users.views import UserView

router = DefaultRouter()
router.register(r'mini_game', MiniGameViewSet)

urlpatterns = [
    path('admin/', admin.site.urls),
    path('login/', UserAuthorization.as_view()),
    path('users/', UserView.as_view()),
    path('users/<int:pk>', UserView.as_view()),
    path('games/init/<int:pk>', CurrentGameInitView.as_view()),
    path('', include(router.urls)),
]
Exemplo n.º 21
0
from users.views import AccountViewSet, UserView
from base import views as base_views

router = routers.SimpleRouter(trailing_slash=False)
router.register(r'users', AccountViewSet)
router.register(r'posts', PostViewSet)
router.register(r'collections', CollectionViewSet)

urlpatterns = [
    # posts
    url(r'^api/v1/', include(router.urls)),
    url(r'^api/v1/posts/(?P<post_pk>[0-9]+)/collect',
        PostCollectorView.as_view()),
    url(r'^api/v1/posts/(?P<post_pk>[0-9]+)/uncollect',
        PostUnCollectorView.as_view()),
    # accounts
    url(r'^api/v1/me', UserView.as_view()),
    # admin
    url(r'^admin/', include(admin.site.urls)),
    # users
    url(r'^', include('users.urls')),
    # app
    url(r'^api/v1/getdata',
        base_views.ProtectedDataView.as_view(),
        name='protected_data'),
    url(r'',
        cache_page(settings.PAGE_CACHE_SECONDS)(
            base_views.IndexView.as_view()),
        name='index'),
]
Exemplo n.º 22
0
# Django
from django.contrib import admin
from django.conf import settings
from django.views.static import serve
from django.conf.urls import url, include
from . import views
from .views import *

# Local Django
from users.views import UserView, IndexView, DetailView

urlpatterns = [
    # Admin
    url(r'^admin/', admin.site.urls),
    # Pages
    url(r'^$', UserView.as_view(), name='register'),
    url(r'index/$', IndexView.as_view(), name='index'),
    url(r'^(?P<pk>[0-9]+)/$', DetailView.as_view(), name='detail'),
    url(r'^(?P<pk>[-\w]+)/comments/$', views.post_new, name='edit'),
    url(r'^activation/(?P<key>.+)$', views.activation, name='activation'),
    url(r'^logout/', views.user_logout),
    url(r'^password_change/$', views.change_password, name='password_change'),
]
Exemplo n.º 23
0
    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 django.urls import include
from django.views.generic import TemplateView

from rest_framework.routers import DefaultRouter

from users.views import EmailTokenView, JWTgetView, UserViewSet, UserView, UserMeView

router = DefaultRouter()

router.register(r'', UserViewSet, basename='users')

urlpatterns = [
    path('admin/', admin.site.urls),
    path('redoc/',
         TemplateView.as_view(template_name='redoc.html'),
         name='redoc'),
    path('api/v1/', include('api.urls')),
    path('api/v1/auth/email/', EmailTokenView.as_view()),
    path('api/v1/auth/token/', JWTgetView.as_view()),
    path('api/v1/users/me/', UserMeView.as_view()),
    path('api/v1/users/<str:username>/', UserView.as_view()),
    path('api/v1/users/', include(router.urls)),
]
Exemplo n.º 24
0
from django.urls import path, include
from django.contrib.auth import views as auth_views
from django.contrib.auth.decorators import login_required

from users.views import UserView, signup

app_name = 'users'

urlpatterns = [
    path('login/', auth_views.LoginView.as_view(template_name='login.html'), name='login'),
    path('logout/', auth_views.LogoutView.as_view(next_page='/accounts/login'), name='logout'),
    path('profile/',  login_required(UserView.as_view()), name='profile'),
    path('signup/', signup, name='signup')
]
Exemplo n.º 25
0
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from rest_auth.views import LoginView
from rest_auth.registration.views import RegisterView
from posts.views import PostView, CommentView, LikesView, PostLikesView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('signin', LoginView.as_view(), name='rest_login'),
    path('signup', RegisterView.as_view(), name='rest_register'),
    path('', PostView.as_view({'get': 'list'})),
    path('silk/', include('silk.urls', namespace='silk')),
    path('posts/create', PostView.as_view({'post': 'create'})),
    path('posts/<int:pk>/likes', PostLikesView.as_view()),
    path('user/<int:pk>', UserView.as_view({
        'get': 'retrieve',
        'put': 'update'
    })),
    path('user/<int:pk>/favorites', UserFavoritesView.as_view()),
    path('comment/', CommentView.as_view({'post': 'create'})),
    path('comment/<int:pk>',
         CommentView.as_view({
             'put': 'update',
             'delete': 'destroy'
         })),
    path('like/<int:pk>', LikesView.as_view()),
    path('favorites/<int:pk>', FavoritesView.as_view()),
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Exemplo n.º 26
0
from django.conf.urls import url

from users.views import UserView


urlpatterns = [
    url(r'(?P<username>[\w.@+-]+)/$', UserView.as_view(), name='user'),
]
Exemplo n.º 27
0
from django.conf.urls import url
from users.views import (
    UserView,
    UsersView,
)

from urls import ROUTER

ROUTER_URL = 'https://%s/v1/'.format(ROUTER)

urlpatterns = [
    url(r'^users/(?P<uid>[\w-]+)', UserView.as_view()),
    url(r'^users', UsersView.as_view()),
]
Exemplo n.º 28
0
from django.contrib import admin
from django.urls import path, include

from users.views import UserView, UserDetail
from rest_framework.authtoken import views

from rest_framework_swagger.views import get_swagger_view

urlpatterns = [
    path("", include("users.urls")),
    path('admin/', admin.site.urls),
    path('api/users/', UserView.as_view()),
    path('api/users/<int:pk>/', UserDetail.as_view()),
    path('api/token/', views.obtain_auth_token),
    path('api/accounts/', include("orders.urls")),
]
schema_view = get_swagger_view(
    title="Markets API",
    patterns=urlpatterns,
)

urlpatterns += [path('swagger/', schema_view)]
Exemplo n.º 29
0
from django.conf.urls import url

from users.views import UserView

urlpatterns = [
    url(r'(?P<username>[\w.@+-]+)/$', UserView.as_view(), name='user'),
]
Exemplo n.º 30
0
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 django.views.generic import TemplateView
from noti.views import NotiView
from users.views import UserView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('notifications /', include('notifications.urls', namespace='notifications')),
    path('my_notifications/', NotiView.as_view(), name='my_notifications'),
    path('', TemplateView.as_view(template_name="log.html"), name="log"),
    path('index/', UserView.as_view(), name="index"),
    path('delete_my_read_notifications/', NotiView.delete_my_read_notifications, name='delete_my_read_notifications'),
    path('send_notification/', NotiView.send_notification, name="send_notification"),
    path('get_user_notification/', NotiView.get_user_notification, name="get_user_notification"),
    path('my_notifications/', NotiView.my_notifications, name="my_notifications")
]
Exemplo n.º 31
0
from django.urls import path

from users.views import login, logout, registration, UserView, user_required

urlpatterns = [
    path('me/', user_required(UserView.as_view()), name='me'),
    path('registration/', registration, name='registration'),
    path('login/', login, name='login'),
    path('logout/', logout, name='logout'),
]
Exemplo n.º 32
0
 def test_includes_upload_form_mixin(self):
     # Expect the view to have the upload form in the hierarchy
     view = UserView()
     assert isinstance(view, UploadFormMixin)
Exemplo n.º 33
0
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Add an import:  from blog import urls as blog_urls
    2. Import the include() function: from django.conf.urls import url, include
    3. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
from django.views.generic import TemplateView
from django.conf import settings
from django.conf.urls.static import static

from formulario.views import Get_skills
from users.views import UserView

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    # Python Social Auth URLs
    url('', include('social.apps.django_app.urls', namespace='social')),
    # Home URL
    url(r'^$', TemplateView.as_view(template_name="home/landing.html"), name="landing"),
    url(r'^forma/$', Get_skills.as_view(), name="formulario"),
    url(r'^cuvitae/(?P<user>\w+)/$', UserView.as_view(), name="User"),
    # Logout URL
    url(r'^users/logout/$','django.contrib.auth.views.logout',{'next_page': '/'},name="user-logout"),
    ]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Exemplo n.º 34
0
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
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
from django.contrib import admin

from question.views import QuestionsListView, QuestionView, QuestionAdd, like, AnswerAdd, popularTags, popularUsers
from users.views import LoginRequest, MyUserRegistration, LogoutRequest, UsersListView, UserView

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'^questions/$', QuestionsListView.as_view(), name='question-list'),
    url(r'^questions/(?P<pk>\d+)/$', QuestionView.as_view(), name='question'),
    url(r'^login/', LoginRequest, name='login'),
    url(r'^registration/', MyUserRegistration, name='registration'),
    url(r'^logout/', LogoutRequest, name='logout'),
    url(r'^question_add/', QuestionAdd, name='question_add'),
    url(r'^comment_add/$', AnswerAdd, name='comment_add'),
    url(r'^users/$', UsersListView.as_view(), name='users-list'),
    url(r'^users/(?P<pk>\d+)/$', UserView.as_view(), name='user'),
    url(r'^like/$', like, name='like'),
    url(r'^populartags/$', popularTags, name='populartags'),
    url(r'^popularusers/$', popularUsers, name='popularusers'),
]
Exemplo n.º 35
0
Arquivo: urls.py Projeto: fox1s/hw_3
from django.urls import path

from users.views import UserView

urlpatterns = [
    path('', UserView.as_view())
]
Exemplo n.º 36
0
from django.conf.urls import url
from users.views import UserView, create_user
from rest_framework_jwt.views import obtain_jwt_token

urlpatterns = [
    url(r'^$', UserView.as_view(), name='user-view'),
    url(r'^create/$', create_user, name='user-create-view'),
    url(r'^api-token-auth/', obtain_jwt_token, name='user-jwt-auth')
]
Exemplo n.º 37
0
from django.conf.urls.defaults import *
from piston.resource import Resource
from users.views import UserView, UserViewRoot

urlpatterns = patterns('',
   url(r'^(?P<user_id>[^/]+)$',
        UserView.as_view(),
        name='user'),
   url(r'^$',
        UserViewRoot.as_view(),
        name='user_root'),
)
Exemplo n.º 38
0
from posts.views import (
    PostViewSet,
    CollectionViewSet,
    PostCollectorView,
    PostUnCollectorView,
)
from users.views import AccountViewSet, UserView
from base import views as base_views


router = routers.SimpleRouter(trailing_slash=False)
router.register(r'users', AccountViewSet)
router.register(r'posts', PostViewSet)
router.register(r'collections', CollectionViewSet)

urlpatterns = [
    # posts
    url(r'^api/v1/', include(router.urls)),
    url(r'^api/v1/posts/(?P<post_pk>[0-9]+)/collect', PostCollectorView.as_view()),
    url(r'^api/v1/posts/(?P<post_pk>[0-9]+)/uncollect', PostUnCollectorView.as_view()),
    # accounts
    url(r'^api/v1/me', UserView.as_view()),
    # admin
    url(r'^admin/', include(admin.site.urls)),
    # users
    url(r'^', include('users.urls')),
    # app
    url(r'^api/v1/getdata', base_views.ProtectedDataView.as_view(), name='protected_data'),
    url(r'', cache_page(settings.PAGE_CACHE_SECONDS)(base_views.IndexView.as_view()), name='index'),
]