forked from narrowfail/django-channels-chat
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
175 additions
and
499 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
from django.contrib import admin | ||
from django.urls import path, include | ||
from django.contrib.auth import views as auth_views | ||
from core.signup import SignUpView | ||
|
||
urlpatterns = [ | ||
|
||
path('admin/', admin.site.urls), | ||
|
||
path('', include('core.urls')), | ||
|
||
path('signup/', SignUpView.as_view(), name='signup'), | ||
path('login/', auth_views.LoginView.as_view(), name='login'), | ||
|
||
path('logout/', auth_views.LogoutView.as_view(), {'next_page': '/'}, | ||
name='logout') | ||
|
||
path('logout/', auth_views.LogoutView.as_view(next_page='/'), name='logout'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from django import forms | ||
from django.core.exceptions import ValidationError | ||
from django.contrib.auth.models import User | ||
from django.contrib.auth.forms import UserCreationForm | ||
from django.views.generic import CreateView | ||
from django.urls import reverse | ||
|
||
class SignUpForm(UserCreationForm): | ||
email = forms.EmailField(required=True) | ||
|
||
def uniqueemailvalidator(self, value): | ||
if User.objects.filter(email__iexact=value).exists(): | ||
raise ValidationError('User with this Email already exists.') | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.fields['email'].validators.append(self.uniqueemailvalidator) | ||
|
||
class Meta(UserCreationForm.Meta): | ||
model = User | ||
fields = ['username', 'email', 'password1','password2'] | ||
|
||
def save(self, commit=True): | ||
user = super().save(commit=False) | ||
user.email = self.cleaned_data["email"] | ||
if commit: | ||
user.save() | ||
return user | ||
|
||
class SignUpView(CreateView): | ||
model = User | ||
form_class = SignUpForm | ||
template_name = 'registration/signup.html' | ||
|
||
def get_success_url(self): | ||
return reverse('home') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{% load static %} | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>{% block title %}Django Social Network{% endblock %}</title> | ||
<link rel="icon" type="image/png" href="{% static 'img/favicon.png' %}"> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> | ||
<!-- <link href="{% static 'css/bootcamp.css' %}?v=1" rel="stylesheet"> --> | ||
<!--[if lt IE 9]> | ||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> | ||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> | ||
<![endif]--> | ||
<style type="text/css"> | ||
body { | ||
background-color: #14213d; /* 006389,073b4c */ | ||
margin-top: 60px; | ||
} | ||
.logo { | ||
margin: 0; | ||
font-size: 2em; | ||
font-weight: 200; | ||
font-family: "Audiowide", cursive; | ||
color: #92c35e; | ||
text-align: center; | ||
text-shadow: 1px 1px 0 #333333; | ||
line-height: 70px; | ||
} | ||
|
||
.login-or { | ||
position: relative; | ||
color: #aaa; | ||
margin-top: 10px; | ||
margin-bottom: 10px; | ||
padding-top: 10px; | ||
padding-bottom: 10px; | ||
} | ||
.span-or { | ||
display: block; | ||
position: absolute; | ||
left: 50%; | ||
top: -2px; | ||
margin-left: -25px; | ||
background-color: #fff; | ||
width: 50px; | ||
text-align: center; | ||
} | ||
.hr-or { | ||
height: 1px; | ||
margin-top: 0px !important; | ||
margin-bottom: 0px !important; | ||
} | ||
</style> | ||
|
||
</head> | ||
<body> | ||
<a href="https://github.com/suhailvs/django-whatsapp"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/e7bbb0521b397edbd5fe43e7f760759336b5e05f/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png"></a> | ||
|
||
<div class="container"> | ||
<div class="row"> | ||
<div class="{% block col_class %}col-md-4 col-sm-8 col-12 offset-md-4{% endblock col_class %}"> | ||
<p class="logo">Django Whatsapp</p> | ||
<div class="card"> | ||
<h4 class="card-header">{% block cardheader %}Log in{% endblock cardheader %}</h4> | ||
<div class="card-body"> | ||
{% if form.non_field_errors %} | ||
<div class="alert alert-danger alert-dismissible fade show" role="alert"> | ||
{% for error in form.non_field_errors %} | ||
<p{% if forloop.last %} class="mb-0"{% endif %}>{{ error }}</p> | ||
{% endfor %} | ||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
{% endif %} | ||
{% block form %}{% endblock form %} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{% extends 'registration/base.html' %} | ||
|
||
{% load crispy_forms_tags %} | ||
|
||
{% block form %} | ||
<form method="post" novalidate> | ||
{% csrf_token %} | ||
<input type="hidden" name="next" value="{{ next }}"> | ||
{{ form.username|as_crispy_field }} | ||
{{ form.password|as_crispy_field }} | ||
<button type="submit" class="btn btn-primary btn-block">Log in</button> | ||
<div class="login-or"> | ||
<hr class="hr-or"> | ||
<span class="span-or">or</span> | ||
</div> | ||
<p class="text-center">Don't have account? <a href="{% url 'signup' %}">Sign up here</a></p> | ||
|
||
</form> | ||
{% endblock form %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{% extends 'registration/base.html' %} | ||
|
||
{% load crispy_forms_tags %} | ||
|
||
{% block col_class %}col-md-6 col-sm-12 offset-md-3{% endblock col_class %} | ||
{% block cardheader %}Sign up{% endblock cardheader %} | ||
|
||
{% block form %} | ||
<form method="post" novalidate> | ||
{% csrf_token %} | ||
<input type="hidden" name="next" value="{{ next }}"> | ||
{{ form|crispy }} | ||
<button type="submit" class="btn btn-success btn-block">Create an account</button> | ||
<div class="login-or"> | ||
<hr class="hr-or"> | ||
<span class="span-or">or</span> | ||
</div> | ||
<p class="text-center"><a href="{% url 'login' %}">Already have an account?</a></p> | ||
</form> | ||
{% endblock form %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ django-filter | |
channels | ||
channels-redis | ||
Django | ||
django-crispy-forms |