from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from apps.user.views import RegisterView, ActiveView, LoginView, LogoutView, UserInfoView, UserOrderView, AddressView

urlpatterns = [
    # url(r'^register$', views.register, name='register'), # 注册
    # url(r'^register_handle$', views.register_handle, name='register_handle'), # 注册处理

    url(r'^register$', RegisterView.as_view(), name='register'), # 注册
    url(r'^active/(?P<token>.*)$', ActiveView.as_view(), name='active'), # 用户激活

    url(r'^login$', LoginView.as_view(), name='login'), # 登录
    url(r'^logout$', LogoutView.as_view(), name='logout'), # 注销登录

    # url(r'^$', login_required(UserInfoView.as_view()), name='user'), # 用户中心-信息页
    # url(r'^order$', login_required(UserOrderView.as_view()), name='order'), # 用户中心-订单页
    # url(r'^address$', login_required(AddressView.as_view()), name='address'), # 用户中心-地址页

    url(r'^$', UserInfoView.as_view(), name='user'), # 用户中心-信息页
    url(r'^order/(?P<page>\d+)$', UserOrderView.as_view(), name='order'), # 用户中心-订单页
    url(r'^address$', AddressView.as_view(), name='address'), # 用户中心-地址页
]
Exemple #2
0
from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from apps.user.views import RegisterView, ActiveView, LoginView, LogoutView, UserInfoView, UserOrderView, AddressView

urlpatterns = [
    # url(r'^register$', register, name='register'), # 注册
    # url(r'^register_handle$', register_handle, name='register_handle'), # 注册处理

    url(r'^register$', RegisterView.as_view(), name='register'), # 注册
    url(r'^active/(?P<token>.*)$', ActiveView.as_view(), name='active'), # 激活

    url(r'^login$', LoginView.as_view(), name='login'), # 登录
    url(r'^logout$', LogoutView.as_view(), name='logout'), # 退出登录


    # 在url配置的时候,调用login_required装饰器,相当于配置的函数是login_required的返回值
    # url(r'^$', login_required(UserInfoView.as_view()), name='user'), # 用户中心-信息页
    # url(r'^order$', login_required(UserOrderView.as_view()), name='order'), # 用户中心-订单页
    # url(r'^address$', login_required(AddressView.as_view()), name='address'), # 用户中心-地址页

    url(r'^$', UserInfoView.as_view(), name='user'), # 用户中心-信息页
    url(r'^order$', UserOrderView.as_view(), name='order'), # 用户中心-订单页
    url(r'^address$', AddressView.as_view(), name='address'), # 用户中心-地址页

]
Exemple #3
0
from django.urls import include, re_path, path
from . import views
from apps.user.views import RegisterView, ActiveView, LoginView, UserInfoView, UserOrderView, AddressView, LogoutView
from django.contrib.auth.decorators import login_required  # 登陆认证,装饰器

app_name = 'user'
urlpatterns = [
    # path('register/', views.register, name='register'), # 通过method来判断显示用户注册并处理注册
    path('register/', RegisterView.as_view(), name='register'),
    re_path('active/(?P<token>.*)/', ActiveView.as_view(), name='active'),
    path('login/', LoginView.as_view(), name='login'),
    # path('', login_required(UserInfoView.as_view()), name='user'),  未使用Mixin
    path('', UserInfoView.as_view(), name='user'),  # 使用Mixin
    re_path('order/(?P<page>\d+)/', UserOrderView.as_view(), name='order'),
    path('address/', AddressView.as_view(), name='address'),
    path('logout/', LogoutView.as_view(), name='logout')

]
Exemple #4
0
from django.conf.urls import url
from apps.user.views import RegisterView, LoginView, ActiveView, LogoutView, UserInfoView, UserOrderView, AddressView, UserHistoryView

urlpatterns = [
    #用户注册
    url(r'^register', RegisterView.as_view()),
    #用户登录
    url(r'^login', LoginView.as_view()),
    #用户登出
    url(r'^logout', LogoutView.as_view()),
    # 用户激活
    url(r'^active', ActiveView.as_view()),
    # 用户中心-信息页
    url(r'^user_center', UserInfoView.as_view()),
    # 用户中心-订单页
    url(r'^order', UserOrderView.as_view()),
    # 用户中心-地址页
    url(r'^address', AddressView.as_view()),
    # 添加用户历史记录
    url(r'^add_his', UserHistoryView.as_view()),
]
Exemple #5
0
from django.urls import path, re_path
from apps.user.views import RegisterView, ActiveView, LoginView, LogoutView, UserInfoView, UserOrderView, AddressView

app_name = 'user'
urlpatterns = [
    path('register', RegisterView.as_view(), name='register'), # 注册
    path('login', LoginView.as_view(), name='login'), # 登录
    path('logout', LogoutView.as_view(), name='logout'), # 注销登录
    re_path('active/(?P<token>.*)', ActiveView.as_view(), name='active'), # 用户激活

    path('', UserInfoView.as_view(), name='user'), # 用户中心-信息页
    re_path('order/(?P<page>\d+)', UserOrderView.as_view(), name='order'), # 用户中心-订单页
    path('address', AddressView.as_view(), name='address'), # 用户中心-地址页
]
Exemple #6
0
from django.urls import path
from django.contrib.auth.decorators import login_required
from apps.user.views import RegisterView, ActiveView, LoginView, UserInfoView, UserOrderView, AddressView, LogoutView, \
    UpdateAddressView, SetDefaultAddressView

urlpatterns = [
    path("register", RegisterView.as_view(), name="register"),
    path("active/<path:token>", ActiveView.as_view(), name="active"),
    path("login", LoginView.as_view(), name="login"),
    path("logout", LogoutView.as_view(), name="logout"),
    # path("", login_required(UserInfoView.as_view()), name="user"),
    # path("order", login_required(UserOrderView.as_view()), name="order"),
    # path("address", login_required(AddressView.as_view()), name="address"),
    path("", UserInfoView.as_view(), name="user"),
    path("order/<int:page>", UserOrderView.as_view(), name="order"),
    path("order", UserOrderView.as_view(), name="order"),
    path("address", AddressView.as_view(), name="address"),
    path("address/update", UpdateAddressView.as_view(), name="update_address"),
    path("address/set_default",
         SetDefaultAddressView.as_view(),
         name="set_default_address"),
]
Exemple #7
0
from django.conf.urls import url

# from apps.user import views
# from django.contrib.auth.decorators import login_required

from apps.user.views import (RegisterView, ActiveView, LoginView, UserInfoView,
                             UserOrderView, AddressView, LogoutView, TestView)

urlpatterns = [
    url(r"^register/$", RegisterView.as_view(),
        name='register'),  # 将注册改为类视图的使用模式
    # url(r"^register/$", views.register, name='register'),
    # url(r"^register_handle/$", views.register_handle, name='register_handle'),

    # url(r"^active/(?P<token>.*)$", ActiveView.as_view(), name='active'),    # 用户激活 拼接 url 的模式
    url(r"^active/$", ActiveView.as_view(),
        name='active'),  # 用户激活 将 token 作为参数进行传递
    url(r"^login/$", LoginView.as_view(), name='login'),  # 用户登录
    url(r"^logout/$", LogoutView.as_view(), name='logout'),  # 用户登出

    # login_required 要在视图函数上使用 as_view() 的返回值是函数 所以我们要在这里手动调用一次
    # url(r"^$", login_required(UserInfoView.as_view()), name='info'),    # info
    # url(r"^order/$", login_required(UserOrderView.as_view()), name='order'),    # order
    # url(r"^site/$", login_required(AddressView.as_view()), name='site'),    # site
    url(r"^$", UserInfoView.as_view(), name='info'),  # info
    url(r"^order/$", UserOrderView.as_view(), name='order'),  # order
    url(r"^site/$", AddressView.as_view(), name='site'),  # site
    url(r"^test/$", TestView.as_view(), name='test'),  # test
]
Exemple #8
0
from apps.user.views import RegisterView, ActiveView, LoginView, LoginoutView, UserInfoView, UserOrderView, AddressView
from django.urls import re_path

urlpatterns = [
    re_path(r'^register$', RegisterView.as_view(), name='register'),  # 注册
    re_path(r'^active/(?P<token>.*)$', ActiveView.as_view(),
            name='active'),  # 用户激活
    re_path(r'^login$', LoginView.as_view(), name='login'),  # 登录
    re_path(r'^loginout$', LoginoutView.as_view(), name='loginout'),  # 注销登录
    re_path(r'^$', UserInfoView.as_view(), name='user'),  # 用户中心-信息页
    re_path(r'^$', UserOrderView.as_view(), name='order'),  # 用户中心-订单页
    re_path(r'^$', AddressView.as_view(), name='address'),  # 用户中心-地址页
]
Exemple #9
0
from django.urls import path, re_path, include
#django自带的登录装饰器
from apps.user.views import LogoutView, RegisterView, ActiveView, LoginView, UserInfoView, UserOrderView, AddressView
# from django.contrib.auth.decorators import login_required
urlpatterns = [
    re_path(r'^register$', RegisterView.as_view(), name='register'),  #注册
    re_path(r'^active/(?P<token>.*)$', ActiveView.as_view(),
            name='active'),  #激活
    re_path(r'^login$', LoginView.as_view(), name='login'),  #登录
    re_path(r'^logout$', LogoutView.as_view(), name='logout'),  #退出

    # re_path(r'^order$',login_required(UserOrderView.as_view()),name='order'),
    # re_path(r'^address$',login_required(AddressView.as_view()),name='address'),
    # re_path(r'^$',login_required(UserInfoView.as_view()),name='user'), #用户中心信息页
    re_path(r'^order$', UserOrderView.as_view(), name='order'),
    re_path(r'^address$', AddressView.as_view(), name='address'),
    re_path(r'^$', UserInfoView.as_view(), name='user'),
]
Exemple #10
0
from django.conf.urls import url
# from apps.user import views
from apps.user.views import RegisterView, ActiveView, LoginView, LogoutView, UserInfoView, UserOrderView, AddressView
from django.contrib.auth.decorators import login_required

urlpatterns = [

    # url(r'^register$', views.register, name='register'),  # 显示注册页面  # 显示注册页面和处理注册用户请求
    # url(r'^register_handle$', views.register_handle, name='register_handle'),  # 显示注册页面
    url(r'^register$', RegisterView.as_view(),
        name='register'),  # 使用类视图处理用户注册请求
    url(r'^active/(?P<token>.*)$', ActiveView.as_view(),
        name='active'),  # 使用类视图处理用户激活
    url(r'^login$', LoginView.as_view(), name='login'),  # 使用类视图处理用户登陆
    url(r'^logout$', LogoutView.as_view(), name='logout'),  # 使用类视图处理用户退出

    # 用户中心页面需要用户登陆后才能访问,可以使用django内置的login_required登陆装饰器
    # url(r'^$', login_required(UserInfoView.as_view()), name='user'),  # 使用类视图处理用户中心-信息页
    # url(r'^order$', login_required(UserOrderView.as_view()), name='order'),  # 使用类视图处理用户中心-订单页
    # url(r'^address$', login_required(AddressView.as_view()), name='address'),  # 使用类视图处理用户中心-地址页

    # 用户中心页面需要用户登陆后才能访问,可以编写utilt.LoginRequiredMixin类来继承实现
    url(r'^$', UserInfoView.as_view(), name='user'),  # 使用类视图处理用户中心-信息页
    url(r'^order$', UserOrderView.as_view(), name='order'),  # 使用类视图处理用户中心-订单页
    url(r'^address$', AddressView.as_view(),
        name='address'),  # 使用类视图处理用户中心-地址页
]
Exemple #11
0
from django.urls import re_path
from apps.user.views import RegisterView, ActiveView, LoginView, LogoutView, UserInfoView, UserOrderView, AddressView

app_name = 'user'

urlpatterns = [
    re_path('^register/$', RegisterView.as_view(), name='register'),
    re_path('^active/(?P<token>.*)/$', ActiveView.as_view(), name='active'),
    re_path('^login/$', LoginView.as_view(), name='login'),
    re_path('^logout/$', LogoutView.as_view(), name='logout'),
    re_path('^$', UserInfoView.as_view(), name='user'),  #用户中心
    re_path('^order/(?P<page>\d+)/$', UserOrderView.as_view(),
            name='order'),  #订单页面
    re_path('^address/$', AddressView.as_view(), name='address'),  #地址页面
]
Exemple #12
0
app_name = 'user'
urlpatterns = [
    re_path(r'^register$', RegisterView.as_view(), name='register'),  # 注册
    re_path(r'^active/(?P<token>.*)$', ActiveView.as_view(),
            name='active'),  # active user account
    re_path(r'^login/$', LoginView.as_view(), name='login'),  # 登陆页面
    re_path(r'^logout/$', LogoutView.as_view(), name='logout'),  # 注销 登录

    # re_path(r'^register$', views.register, name='register'),  # 用户注册页面url
    # re_path(r'^register_handle$', views.register_handle, name='register_handle'),     # 注册处理

    ################################################################################################
    ###### 访问一个地址时:如果 用户未登录(session中没有该用户信息),
    ###### login_required会(根据配置LOGIN_URL = '/user/login/') 跳转到 登陆页面。
    ###### 并且 在登陆页面的地址后 添加next参数。next参数 是 之前访问的地址 的 路径
    ###### 如果 用户已经登陆(session中 有该用户信息),执行login_required包裹的 视图view
    ######
    ###### 这样写(login_required(UserInfoView.as_view()))显得有些啰嗦,
    ###### 将login_required(as_view)封装在LoginRequiredMixin中,
    ###### 并让UserInfoView, UserOrderView, AddressView等 需要登录才能访问的页面,继承LoginRequiredMixin
    ###### (LoginRequiredMixin要在 子类的继承顺序 的 第一位)

    # re_path(r'^$', login_required(UserInfoView.as_view()), name='user'),     # 用户中心 信息页#######################有可能重名。。。
    # re_path(r'^order/$', login_required(UserOrderView.as_view()), name='order'),      # 用户中心 订单页
    # re_path(r'^address/$', login_required(AddressView.as_view()), name='address'),    # 用户中心 地址页
    re_path(r'^$', UserInfoView.as_view(), name='user'),  # 用户中心 信息页
    re_path(r'^order/(?P<page>\d+)$', UserOrderView.as_view(),
            name='order'),  # 用户中心 订单页
    re_path(r'^address/$', AddressView.as_view(), name='address')  # 用户中心 地址页
]
Exemple #13
0
from django.conf.urls import url
from apps.user.views import RegisterView,LoginView,ActiveView,LogoutView,UserInfoView,UserOrderView,AddressView
from django.contrib.auth.decorators import login_required



urlpatterns = [
    # url(r'^register$', views.register, name='register'), # 注册
    # url(r'^register_handle$', views.register_handle, name='register_handle'), # 注册处理

    url(r'^register$', RegisterView.as_view(), name='register'), # 注册
    url(r'^active/(?P<token>.*)$', ActiveView.as_view(), name='active'), # 用户激活
    url(r'^login$', LoginView.as_view(), name='login'), # 登录

    url(r'^logout$',LogoutView.as_view(),name="logout"),
    url(r'^$',UserInfoView.as_view(),name="user"),
    url(r'^order$',UserOrderView.as_view(),name="order"),
    url(r'^address$',AddressView.as_view(),name="address"),


]
Exemple #14
0
from django.urls import path, re_path
from apps.user.views import RegisterView, ActiveView, LoginView, UserInfoView, UserOrderView, AddressView, LogoutView
from django.contrib.auth.decorators import login_required
app_name = "user"

urlpatterns = [
    path('register/', RegisterView.as_view(), name="register"),  #注册
    re_path(r'^active/(.*)$', ActiveView.as_view(), name="active"),  #激活用户
    path('login/', LoginView.as_view(), name="login"),  #登录
    path('', UserInfoView.as_view(), name="user"),  #用户中心-信息页
    path('order/', UserOrderView.as_view(), name="order"),  #用户中心-订单页
    path('address/', AddressView.as_view(), name="address"),  #用户中心-地址页
    path('logout/', LogoutView.as_view(), name="logout")
]