Exemplo n.º 1
0
def test_profile_view(login_user, test_student):
    # test without a logged in user
    # it should redirect to the login page
    anonymous_client = Client()
    response = anonymous_client.get(reverse('users:profile'))
    assert response.status_code == 302

    # test if it redirects to the correct page
    response = anonymous_client.get(reverse('users:profile'), follow=True)
    assert response.status_code == 200
    assert response.redirect_chain[0][1] == 302
    assert "login" in response.redirect_chain[0][0]

    # test with a logged in user
    client = login_user
    response = client.get(reverse('users:profile'))
    assert response.status_code == 200
    assertTemplateUsed(response, "users/profile.html")

    view = Profile()
    view.object = test_student
    # Test if there is a title in the context_data which is our custom code
    assert "title" in view.get_context_data().keys()
    # if there is a title, it should have the following value
    assert view.get_context_data()["title"] == _("Profile")
Exemplo n.º 2
0
from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from users.views import Register, Login, logout_view, Profile, Orders, OrderDetail, ReviewProducts
# NewUserProfileView, EditUserProfileView,

urlpatterns = [
    url(r'^login/$', Login.as_view(), name='login'),
    url(r'^logout/$', logout_view, name='logout'),
    url(r'^register/$', Register.as_view(), name='register'),
    url(r'^profile/$', login_required(Profile.as_view()), name='profile'),
    url(r'^orders/$', login_required(Orders.as_view()), name='orders'),
    url(r'^review/products/$',
        login_required(ReviewProducts.as_view()),
        name='review_products'),
    url(r'^(?P<pk>\d+)/order/$',
        login_required(OrderDetail.as_view()),
        name='order_detail'),

    # url(r'^profile/new/$', NewUserProfileView.as_view(), name='profile_new'),
    # url(r'^profile/(?P<pk>\d+)/$', EditUserProfileView.as_view(), name='profile_edit'),
]
Exemplo n.º 3
0
from django.conf.urls import patterns, url

from users.views import Login
from users.views import Logout
from users.views import Profile
from users.views import Registration


urlpatterns = patterns('',
	url(r'^me/$', Profile.as_view()),
	url(r'^registration/$', Registration.as_view()),
	url(r'^login/$', Login.as_view()),
	url(r'^logout/$', Logout.as_view()),
	url(r'^(?P<slug>\w+)/$', Profile.as_view()),
)

Exemplo n.º 4
0
from django.urls import path
from users.views import Login, Profile, Registration, ProfileEdit, Logout, AdminPanel

app_name = 'users'
urlpatterns = [
    path('login/', Login.as_view(), name='login'),
    path('logout/', Logout.as_view(), name='logout'),
    path('registration/', Registration.as_view(), name='registration'),
    path('profile/', Profile.as_view(), name='profile'),
    path('profile_update/', ProfileEdit.as_view(), name='profile_edit'),
    path('admin_panel/', AdminPanel.as_view(), name='admin_panel'),
]
Exemplo n.º 5
0
from django.urls import path
from django.contrib.auth.decorators import login_required
from gen.users.views import logout_view
from users.views import (Register, Login, Profile, Orders, OrderDetail,
                         ReviewProducts)

urlpatterns = [
    path(r'login/', Login.as_view(), name='user_login'),
    path(r'logout/', logout_view, name='logout'),
    path(r'register/', Register.as_view(), name='user_register'),
    path(r'profile/', login_required(Profile.as_view()), name='profile'),
    path(r'orders/', login_required(Orders.as_view()), name='user_orders'),
    path(r'review/products/',
         login_required(ReviewProducts.as_view()),
         name='user_review_products'),
    path(r'<int:pk>/order/',
         login_required(OrderDetail.as_view()),
         name='user_order_detail'),
]
Exemplo n.º 6
0
from django.conf.urls import url

from users.views import Register, LogOut, LogIn, Profile, PassChange

urlpatterns = [
    url(r'^register/$', Register.as_view(), name="register"),
    url(r'^logout/$', LogOut.as_view(), name="logout"),
    url(r'^login/$', LogIn.as_view(), name="login"),
    url(r'^profile/$', Profile.as_view(), name="user_profile"),
    url(r'^profile/passchange$', PassChange.as_view(), name="pass_change"),
]
Exemplo n.º 7
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, patterns
from django.contrib import admin

# from tweets.views import new_tweet,show_tweet, delete_tweet, edit_tweet
from tweets.views import tweet_login, tweet_logout
from users.views import Profile
from tweets import urls as tweets_url
from django.conf import settings

urlpatterns = [
    url(r"^admin/", include(admin.site.urls)),
    url(r"^tweet/", include(tweets_url, namespace="tweets_url")),
    url(r"^tweet/login/$", tweet_login, name="tweet_login"),
    url(r"^tweet/logout/$", tweet_logout, name="tweet_logout"),
    url(r"^tweet/update_profile/(?P<pk>\d{1,})/$", Profile.as_view(), name="update_profile"),
]

if settings.DEBUG:
    import debug_toolbar

    urlpatterns += patterns("", url(r"^__debug__/", include(debug_toolbar.urls)))
Exemplo n.º 8
0
from django.urls import path, reverse_lazy
from django.views.generic.base import RedirectView

from users.views import (Profile, SignIn, SignUp, UserPasswordResetConfirmView,
                         UserPasswordResetView, unlock)

app_name = "users"
urlpatterns = [
    path('login',
         RedirectView.as_view(url=reverse_lazy("users:signin")),
         name="login"),
    path("password_reset",
         UserPasswordResetView.as_view(),
         name="password_reset"),
    path("reset/<uidb64>/<token>/",
         UserPasswordResetConfirmView.as_view(),
         name="password_reset_confirm"),
    path("profile", Profile.as_view(), name="profile"),
    path("signup", SignUp.as_view(), name="signup"),
    path("signin",
         SignIn.as_view(redirect_authenticated_user=True),
         name="signin"),
    path("unlock/<int:pk>", unlock, name="unlock")
]