Пример #1
0
 def test_profile_view_with_no_user_name_not_logged_in_redirets_home(self):
     """Test profile_view with no user name not logged in redirets."""
     from imager_profile.views import ProfileView
     request = self.request.get('')
     request.user = AnonymousUser()
     view = ProfileView(request=request, kwargs={'username': ''})
     response = view.get(request)
     self.assertEqual(response.status_code, 302)
Пример #2
0
 def test_profile_view_with_logged_in_user_gets_user_profile(self):
     """Test profile_view with logged in user gets user profile."""
     from imager_profile.views import ProfileView
     request = self.request.get('')
     request.user = self.bob
     view = ProfileView(request=request, kwargs={'username': ''})
     response = view.get(request)
     response.render()
     self.assertIn(b'I photograph things all the time.', response.content)
Пример #3
0
 def test_profile_view_with_user_name_gets_user_profile_even_with_slash(self):
     """Test that the p_view function returns a page with user profile."""
     from imager_profile.views import ProfileView
     request = self.request.get('')
     request.user = AnonymousUser()
     view = ProfileView(request=request, kwargs={'username': '******'})
     response = view.get(request)
     response.render()
     self.assertIn(b'I photograph things all the time.', response.content)
Пример #4
0
 def test_profile_view_get_context_has_view_photos_and_albums_for_non_owner(self):
     """Test that the context from ProfileView has all properties."""
     from imager_profile.views import ProfileView
     request = self.request.get('')
     request.user = AnonymousUser()
     view = ProfileView(request=request, object='')
     data = view.get_context_data(object=ImagerProfile.objects.first())
     self.assertIn('view', data)
     self.assertIn('photos', data)
     self.assertIn('albums', data)
     self.assertFalse(data['owner'])
Пример #5
0
 def test_profile_view(self):
     """Test profile view status code."""
     from imager_profile.views import ProfileView
     req = self.request.get(reverse_lazy('profile'))
     some_user = UserFactory.create()
     req.user = some_user
     view = ProfileView.as_view()
     response = view(req)
     self.assertEqual(response.status_code, 200)
Пример #6
0
"""Imagersite URL Configuration.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.10/topics/http/urls/
Examples:
Function views
    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. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from imager_profile.views import ProfileView, UserProfileView

urlpatterns = [
    url(r'^$', ProfileView.as_view(), name="profile"),
    url(r'^(?P<username>\w+)/$',
        UserProfileView.as_view(),
        name="user_profile")
]
Пример #7
0
"""Urls for profile related views."""
from django.conf.urls import url
from imager_profile.views import (
    ProfileView,
    PublicProfileView,
    ProfileEdit
)

urlpatterns = [
    url(r'^$', ProfileView.as_view(), name='profile'),
    url(r'^edit/$', ProfileEdit.as_view(), name='profile_edit'),
    url(r'^(?P<request_username>\w+)/$', PublicProfileView.as_view(),
        name='public_profile'),
]
Пример #8
0
"""URLS for profile routes."""
from django.conf.urls import url
from imager_profile.views import ProfileView, ProfileUserView, EditProfileView

urlpatterns = [
    url(r'edit/$', EditProfileView.as_view(), name='edit_profile'),
    url(r'(?P<slug>\w+)/$', ProfileView.as_view(), name='profile'),
    url(r'^$', ProfileUserView.as_view(), name='profile_user'),
]
Пример #9
0
"""."""
from django.conf.urls import url
from imager_profile.views import ProfileView, ProfileEditView

urlpatterns = [
    url(r'^edit$', ProfileEditView.as_view(), name='profile_edit'),
    url(r'^(?P<username>.*)$', ProfileView.as_view(), name='profile')
]
Пример #10
0
"""URL managment for profile based pages."""
from django.conf.urls import url
from imager_profile.views import (ProfileView, PublicProfileView,
                                  ProfileEditView)
from django.contrib.auth.decorators import login_required

urlpatterns = [
    url(r'^$', login_required(ProfileView.as_view()), name='profile'),
    url(r'^edit/$', ProfileEditView.as_view(), name='profile_edit'),
    url(r'^(?P<request_username>\w+\d*)/$',
        PublicProfileView.as_view(),
        name='public_profile'),
]
Пример #11
0
from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from imager_profile.views import ProfileView, profile_edit_view


urlpatterns = [
    url(
        r'^$',
        login_required(
            ProfileView.as_view()
        ),
        name='profile'
    ),
    url(
        r'^edit/$',
        login_required(
            profile_edit_view,
        ),
        name='profile_edit'
    )
]
Пример #12
0
"""Imager profile app urls."""
from django.conf.urls import url

from imager_profile.views import GuestView, ProfileView, UpdateProfile

urlpatterns = [
    url(r'^$',
        ProfileView.as_view(template_name='imager_profile/profile.html'),
        name='profile'),
    url(r'^(?P<username>\w+)/$',
        GuestView.as_view(template_name='imager_profile/guest_profile.html'),
        name='user_profile'),
    url(r'^edit/(?P<pk>\d+)$', UpdateProfile.as_view(), name='update_profile')
]
Пример #13
0
"""Routes for user profiles."""
from django.conf.urls import url
from imager_profile.views import ProfileView

urlpatterns = [
    url(r'^$', ProfileView.as_view(), name='user_profile'),
    url(r'^(?P<username>\w+)/$', ProfileView.as_view(), name='profile')
]
Пример #14
0
"""URL for the application imager_profile."""
from django.conf.urls import url
from imager_profile.views import ProfileView, EditProfileView, MyprofileView

urlpatterns = [
    url(r'^$', MyprofileView.as_view(), name='my_profile'),
    url(r'edit$', EditProfileView.as_view(), name='edit_profile'),
    url(r'^(?P<username>\w+)', ProfileView.as_view(), name='profile'),
]