from __future__ import absolute_import
import json
import uuid
from datetime import timedelta
import django
from django import forms
from django.conf import settings
from django.contrib.auth.models import AbstractUser, AnonymousUser
from django.contrib.sites.models import Site
from django.core import mail, validators
from django.core.exceptions import ValidationError
from django.db import models
from django.test.client import Client, RequestFactory
from django.test.utils import override_settings
from django.utils.timezone import now
from allauth.account.forms import BaseSignupForm, SignupForm
from allauth.account.models import (
EmailAddress,
EmailConfirmation,
EmailConfirmationHMAC,
)
from allauth.tests import Mock, TestCase, patch
from allauth.utils import get_user_model, get_username_max_length
from . import app_settings
from ..compat import is_authenticated, reverse
from .adapter import get_adapter
from .auth_backends import AuthenticationBackend
from .signals import user_logged_out
from .utils import (
filter_users_by_username,
url_str_to_user_pk,
user_pk_to_url_str,
user_username,
)
test_username_validators = [
validators.RegexValidator(
regex=r'^[a-c]+$',
message='not abc',
flags=0)]
@override_settings(
ACCOUNT_DEFAULT_HTTP_PROTOCOL='https',
ACCOUNT_EMAIL_VERIFICATION=app_settings.EmailVerificationMethod.MANDATORY,
ACCOUNT_AUTHENTICATION_METHOD=app_settings.AuthenticationMethod.USERNAME,
ACCOUNT_SIGNUP_FORM_CLASS=None,
ACCOUNT_EMAIL_SUBJECT_PREFIX=None,
LOGIN_REDIRECT_URL='/accounts/profile/',
ACCOUNT_ADAPTER='allauth.account.adapter.DefaultAccountAdapter',
ACCOUNT_USERNAME_REQUIRED=True)
class AccountTests(TestCase):
def setUp(self):
if 'allauth.socialaccount' in settings.INSTALLED_APPS:
# Otherwise ImproperlyConfigured exceptions may occur
from ..socialaccount.models import SocialApp
sa = SocialApp.objects.create(name='testfb',
provider='facebook')
sa.sites.add(Site.objects.get_current())
@override_settings(
ACCOUNT_AUTHENTICATION_METHOD=app_settings.AuthenticationMethod
.USERNAME_EMAIL)
def test_username_containing_at(self):
user = get_user_model().objects.create(username='@raymond.penners')
user.set_password('psst')
user.save()
EmailAddress.objects.create(user=user,
email="raymond.penners@example.com",
primary=True,
verified=True)
resp = self.client.post(reverse('account_login'),
{'login': '@raymond.penners',
'password': 'psst'})
self.assertRedirects(resp,
settings.LOGIN_REDIRECT_URL,
fetch_redirect_response=False)
def test_signup_same_email_verified_externally(self):
user = self._test_signup_email_verified_externally("john@example.com",
"john@example.com")
self.assertEqual(EmailAddress.objects.filter(user=user).count(),
1)
EmailAddress.objects.get(verified=True,
email="john@example.com",
user=user,
primary=True)
def test_signup_other_email_verified_externally(self):
"""
John is invited on john@example.org, but signs up via john@example.com.
E-mail verification is by-passed, their home e-mail address is
used as a secondary.
"""
user = self._test_signup_email_verified_externally("john@example.com",
"john@example.org")
self.assertEqual(EmailAddress.objects.filter(user=user).count(),
2)
EmailAddress.objects.get(verified=False,
email="john@example.com",
user=user,
primary=False)
EmailAddress.objects.get(verified=True,
email="john@example.org",
user=user,
primary=True)
def _test_signup_email_verified_externally(self, signup_email,
verified_email):
username = 'johndoe'
request = RequestFactory().post(reverse('account_signup'),
{'username': username,
'email': signup_email,
'password1': 'johndoe',
'password2': 'johndoe'})
# Fake stash_verified_email
from django.contrib.messages.middleware import MessageMiddleware
from django.contrib.sessions.middleware import SessionMiddleware
SessionMiddleware().process_request(request)
MessageMiddleware().process_request(request)
request.user = AnonymousUser()
request.session['account_verified_email'] = verified_email
from .views import signup
resp = signup(request)
self.assertEqual(resp.status_code, 302)
self.assertEqual(resp['location'],
get_adapter().get_login_redirect_url(request))
self.assertEqual(len(mail.outbox), 0)
return get_user_model().objects.get(username=username)
@override_settings(
ACCOUNT_USERNAME_REQUIRED=True,
ACCOUNT_SIGNUP_PASSOWRD_ENTER_TWICE=True)
def test_signup_password_twice_form_error(self):
resp = self.client.post(
reverse('account_signup'),
data={
'username': 'johndoe',
'email': 'john@example.org',
'password1': 'johndoe',
'password2': 'janedoe'})
self.assertFormError(
resp,
'form',
'password2',
'You must type the same password each time.'
)
@override_settings(
ACCOUNT_USERNAME_REQUIRED=True,
ACCOUNT_SIGNUP_EMAIL_ENTER_TWICE=True)
def test_signup_email_twice(self):
request = RequestFactory().post(reverse('account_signup'),
{'username': 'johndoe',
'email': 'john@example.org',
'email2': 'john@example.org',
'password1': 'johndoe',
'password2': 'johndoe'})
from django.contrib.messages.middleware import MessageMiddleware
from django.contrib.sessions.middleware import SessionMiddleware
SessionMiddleware().process_request(request)
MessageMiddleware().process_request(request)
request.user = AnonymousUser()
from .views import signup
signup(request)
user = get_user_model().objects.get(username='johndoe')
self.assertEqual(user.email, "john@example.org")
def _create_user(self, username='john', password='doe'):
user = get_user_model().objects.create(
username=username,
is_active=True)
if password:
user.set_password(password)
else:
user.set_unusable_password()
user.save()
return user
def _create_user_and_login(self, usable_password=True):
password = 'doe' if usable_password else False
user = self._create_user(password=password)
self.client_force_login(user)
return user
def test_redirect_when_authenticated(self):
self._create_user_and_login()
c = self.client
resp = c.get(reverse('account_login'))
self.assertRedirects(
resp, "/accounts
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
这是一个使用**Django框架**的社交网络网站。 该网站拥有以下功能: 1. **身份验证**:包括用户注册、登录和密码重置等身份验证功能。同时支持使用其他社交媒体账号进行登录,如Facebook、Google等。 2. **新闻动态**:用户可以在主页上浏览最新的新闻动态,包括他们自己和他们关注的人的帖子。这个功能类似于传统社交媒体网站的主页动态。 3. **个人资料页面**:用户可以创建和编辑自己的个人资料页面。在个人资料页面上,可以添加个人信息、个人照片和简介等信息。 4. **帖子的点赞和评论**:用户可以在帖子上进行点赞,并发表评论。这促进了用户之间的互动和交流。 5. **用户间的消息功能**:用户之间可以发送消息进行私密交流。 6. **通知**:用户可以收到关于帖子点赞、评论以及其他用户交互的通知。 7. **用户搜索**:用户可以通过用户名或其他关键词搜索其他用户,以便查找和关注他们。 8. **Meme生成器**:用户可以使用内置的Meme生成器创建和分享Meme图片。 9. **RSS订阅**:该系统具
资源推荐
资源详情
资源评论
收起资源包目录
Django框架的社交网络网站.zip (796个子文件)
bootstrap.css 143KB
bootstrap.css 143KB
bootstrap.min.css 118KB
bootstrap.min.css 118KB
style5.css 4KB
style5.css 4KB
blog.css 834B
home_style.css 641B
profile.css 193B
style.css 0B
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
base.html 6KB
base.html 6KB
base1.html 5KB
base.html 5KB
profile.html 4KB
home.html 4KB
meme_gen.html 4KB
email.html 2KB
post_list.html 2KB
post_detail.html 2KB
contact.html 1KB
login.html 1KB
notifications.html 1KB
connections.html 1KB
search_result.html 1KB
profile_list.html 1KB
auth.html 1KB
view.html 1KB
headers.html 1KB
base1.html 1005B
inbox.html 989B
password_reset_from_key.html 942B
email_confirm.html 927B
trash.html 896B
outbox.html 827B
password_reset.html 805B
verified_email_required.html 797B
signup.html 771B
provider_list.html 663B
signup.html 634B
base.html 521B
logout.html 518B
edit_profile.html 483B
password_reset_done.html 474B
login_cancelled.html 444B
verification_sent.html 437B
password_change.html 436B
new_message.html 432B
password_set.html 421B
login.html 357B
authentication_error.html 324B
add_comment.html 322B
notice.html 302B
post_edit.html 301B
compose.html 284B
signup_closed.html 264B
password_reset_from_key_done.html 251B
notice.html 249B
account_inactive.html 243B
notice.html 240B
notice.html 236B
fbconnect.html 223B
already_logged_in.html 204B
notice.html 173B
notice.html 171B
login_extra.html 51B
base.html 40B
base.html 34B
news_feed.html 0B
login.html 0B
about.html 0B
logged_out.html 0B
triple_sss-worldlink-53f3b53baadf.iml 722B
IMG_20160813_130831_RFkV5Xn.jpg 940KB
IMG_20160813_130831_WDQBSlh.jpg 940KB
IMG_20160813_130831_XN8zBvr.jpg 940KB
IMG_20160813_130831_bjIngB3.jpg 940KB
IMG_20160813_130831_TtlFHoq.jpg 940KB
IMG_20160813_130831_i81cvxw.jpg 940KB
IMG_20160813_130831_nrs2eFP.jpg 940KB
IMG_20160813_130831_Be1N8Ei.jpg 940KB
IMG_20160813_130831_FwwSlVw.jpg 940KB
IMG_20160813_130831_SpAXbdg.jpg 940KB
IMG_20160813_130831_uK6esKz.jpg 940KB
IMG_20160813_130831_SqINshe.jpg 940KB
IMG_20160813_130831_HH8iM7S.jpg 940KB
IMG_20160813_130831_zlFuEzq.jpg 940KB
IMG_20160813_130831_RmRw7R7.jpg 940KB
IMG_20160813_130831_09EVivy.jpg 940KB
IMG_20160813_130831_bkfMHo0.jpg 940KB
IMG_20160813_130831_muAFgZX.jpg 940KB
IMG_20160813_130831_kgkTdYM.jpg 940KB
IMG_20160813_130831_CnqtJxa.jpg 940KB
IMG_20160813_130831_zJL6IN8.jpg 940KB
IMG_20160813_130831.jpg 940KB
IMG_20160813_130831_YkpzNEq.jpg 940KB
IMG_20160813_130831_YqQHvb8.jpg 940KB
IMG_20160813_130831_xzJfqiU.jpg 940KB
共 796 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
竹山全栈
- 粉丝: 2134
- 资源: 257
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于c++的个人收支管理系统设计
- docker一键安装包
- Screenshot_20240430_144340_com.ss.android.ugc.live.jpg
- 回到山沟沟.mp3
- 基于matlab实现自适应波束形成RLS及LMS算法仿真源程序1.rar
- 基于matlab实现自己编写的基于卡尔曼滤波的利用加速度传感器的计步器,测试数据是传感器放在腰部和手臂 .rar
- 基于matlab实现阵列信号处理,波束形成.rar
- 111111111111111111
- 基于matlab实现计步器编程;对当前的计步器装置的数值算法模拟 .rar
- Mdb学习查看PW;access;mdb;pw;password;patch
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功