Пример #1
0
    def test_details(self):
        # Create an instance of a GET request.
        request = self.factory.get('/customer/details')

        # Recall that middleware are not supported. We simulate a
        # logged-in user by setting request.user manually.
        request.user = self.user

        # Simulates an anonymous user by setting request.user to
        # an AnonymousUser instance.
        request.user = AnonymousUser()

        # Used for class-based views.
        response = HomeView.as_view()(request)
        self.assertEqual(response.status_code, 200)
Пример #2
0
from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from photos.views import HomeView, DetailView, CreateView, PhotoListView, UserPhotosView

urlpatterns = [
    #Photo urls
    url(r'^$', HomeView.as_view(), name='photos_home'),
    url(r'^my-photos/$', login_required(UserPhotosView.as_view()), name='user_photos'),
    url(r'^photos/$', PhotoListView.as_view(), name='photos_list'),
    url(r'^photos/(?P<pk>[0-9]+)$', DetailView.as_view(), name='photo_detail'),
    url(r'^photos/new$', CreateView.as_view(), name='create_photo'),
]
Пример #3
0
from django.conf.urls import url
from django.contrib import admin
from django.contrib.auth.decorators import login_required

from photos.api import PhotoDetailAPI, PhotoListAPI
from photos.views import CreateView, DetailView, HomeView, PhotoListView, \
    UserPhotosView
from users.api import UserDetailAPI, UserListAPI
from users.views import LoginView, LogoutView

# r le dice que es una expresion regular  -^ iniciode cadena - $ fin de cadena
urlpatterns = [
    url(r'^admin/', admin.site.urls),

    #Photo URLs
    url(r'^$', HomeView.as_view(), name="photos_home"),
    url(r'^photos/(?P<pk>[0-9]+)/$', DetailView.as_view(),
        name="photo_detail"),
    url(r'^photos/new/$', CreateView.as_view(), name="photo_create"),
    url(r'^photos/$', PhotoListView.as_view(), name="photos_list"),
    url(r'^my-photos/$',
        login_required(UserPhotosView.as_view()),
        name="user_photos"),

    #Photos API URLs
    url(r'^api/1.0/photos/$', PhotoListAPI.as_view(), name='photo_list_api'),
    url(r'^api/1.0/photos/(?P<pk>[0-9]+)/$',
        PhotoDetailAPI.as_view(),
        name='photo_detail_api'),

    #Users URLs
Пример #4
0
from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from photos.views import HomeView, DetailView, CreateView, PhotoListView, UserPhotosView


urlpatterns = [
    # Photos URLs
    url(r'^$', HomeView.as_view(), name='photos_home'),
    url(r'^my-photos/$', login_required(UserPhotosView.as_view()), name='user_photos'),
    url(r'^photos/$', PhotoListView.as_view(), name='photos_list'),
    url(r'^photos/(?P<pk>[0-9]+)$', DetailView.as_view(), name='photo_detail'),
    url(r'photos/new$', CreateView.as_view(), name='create_photo'),
]
Пример #5
0
from django.urls import path
from photos.views import HomeView, PhotoListView, PhotoDetailView, CreateView,  UserPhotosView
from django.contrib.auth.decorators import login_required


urlpatterns = [

    path('', HomeView.as_view(), name='photos_home'),
    path('photos/<int:pk>', PhotoDetailView.as_view(), name='photos_detail'),
    path('photos/new/', CreateView.as_view(), name='create_photo'),
    path('photos/', PhotoListView.as_view(), name='photos_list'),
    path('my-photos/', login_required(UserPhotosView.as_view()), name='user_photos'),


]
Пример #6
0
from django.conf.urls import url
from django.contrib import admin

from users import views as users_views
from photos import views as photos_views
from photos.views import HomeView,DetailView,CreateView,ListView
from users.views import LoginView,LogoutView





urlpatterns = [

    #Photos
    url(r'^admin/', admin.site.urls),
    url(r'^$',HomeView.as_view(),name='home'),
    url(r'^photos/new',CreateView.as_view(),name="create_photo"),

    url(r'^photo/(?P<pk>[0-9]+)$',DetailView.as_view(),name='photo_detail'),
    url(r'^photos/$',ListView.as_view(),name="photos_list"),

    # Users
    url(r'^login$', LoginView.as_view(), name='user_login'),
    url(r'^logout$', LogoutView.as_view(), name='user_logout')




]
Пример #7
0
from django.urls import path

from photos.views import (
    HomeView,
    DetailView,
    CreatePhotoView,
    ListPhotoView,
    UserPhotoView,
)

urlpatterns = [

    # Photos
    path('', HomeView.as_view(), name='home'),
    path('photo/<pk>', DetailView.as_view(), name='detail'),
    path('photo/create/', CreatePhotoView.as_view(), name='photo_create'),
    path('photo/list/', ListPhotoView.as_view(), name='photo_list'),
    path('<username>/my_photos/', UserPhotoView.as_view(), name='user_photos'),
]
Пример #8
0
"""
HOME ULS CONFIGURATIONS
"""

from django.conf.urls import url

from photos.views import HomeView, ServiceView

urlpatterns = [
    url(r'^$', HomeView.as_view(), name='index'),
    url(r'^services$', ServiceView.as_view(), name='services'),
]