-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] User Creation and Login #16
Open
Dru94
wants to merge
5
commits into
pykla:develop
Choose a base branch
from
Dru94:andru_m
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,5 @@ | ||
#IDE files | ||
.idea/ | ||
|
||
#environment files | ||
env/ |
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,2 +1,5 @@ | ||
# pykla-web | ||
The official website for Python Kampla (PyKla) | ||
|
||
Login for pykla website. Django version 2.1.3. | ||
To get reset password email, use the following command in the shell. python -m smtpd -n -c DebuggingServer localhost:1025 |
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,6 @@ | ||
from django.contrib import admin | ||
from .models import UserProfile | ||
|
||
# Register your models here. | ||
|
||
admin.site.register(UserProfile) |
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,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AccountsConfig(AppConfig): | ||
name = 'accounts' |
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,32 @@ | ||
from django import forms | ||
from django.contrib.auth.forms import UserCreationForm, UserChangeForm | ||
from django.contrib.auth.models import User | ||
|
||
class RegForm(UserCreationForm): | ||
email = forms.EmailField(required=True) | ||
|
||
class Meta: | ||
model = User | ||
fields = [ | ||
'username','first_name','last_name','email','password1', 'password2' | ||
] | ||
|
||
def save(self, commit=True): | ||
user = super(RegForm, self).save(commit=False) | ||
user.first_name = forms.cleaned_data('first_name') | ||
user.last_name = forms.cleaned_data('last_name') | ||
user.email = forms.cleaned_data('email') | ||
|
||
|
||
if commit: | ||
user.save() | ||
|
||
return user | ||
|
||
#edit user profile | ||
class EditProfile(UserChangeForm): | ||
class Meta: | ||
model = User | ||
fields = [ | ||
'username', 'first_name', 'last_name','password' | ||
] |
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,29 @@ | ||
# Generated by Django 2.1.3 on 2019-01-14 13:39 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='UserProfile', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('first_name', models.CharField(max_length=20)), | ||
('last_name', models.CharField(max_length=20)), | ||
('username', models.CharField(max_length=20)), | ||
('tel', models.IntegerField(default=0)), | ||
('email', models.EmailField(max_length=254)), | ||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
] |
Empty file.
Binary file not shown.
Binary file not shown.
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,23 @@ | ||
from django.db import models | ||
from django.contrib.auth.models import User | ||
from django.db.models.signals import post_save | ||
|
||
# user profile model | ||
class UserProfile(models.Model): | ||
user = models.OneToOneField(User, on_delete=models.CASCADE) | ||
first_name = models.CharField(max_length=20) | ||
last_name = models.CharField(max_length=20) | ||
username = models.CharField(max_length=20) | ||
tel = models.IntegerField(default=0) | ||
email = models.EmailField() | ||
|
||
def __str__(self): | ||
return '%s - %s - %s' %(self.username, self.first_name, self.tel) | ||
|
||
# method creating user profile. Uses django signal to save user after being created | ||
def create_profile(sender, **kwargs ): | ||
if kwargs['created']: | ||
UserProfile.objects.create(user=kwargs['instance']) | ||
|
||
post_save.connect(create_profile, sender=User) | ||
|
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,16 @@ | ||
{%extends 'base.html'%} | ||
|
||
{%block body%} | ||
<div class="container"> | ||
<h1>Password reset</h1> | ||
<p> | ||
Forgotten your password? Enter your email address below, and we'll email instructions for setting a new one. | ||
</p> | ||
<form method="post"> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
<button type="submit">Reset password</button> | ||
</form> | ||
</div> | ||
|
||
{% endblock%} |
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,10 @@ | ||
{%extends 'base.html'%} | ||
|
||
{% block body%} | ||
<form method="POST"> | ||
{%csrf_token%} | ||
{{form.as_p}} | ||
<button class="btn btn-primary" type="submit">Submit</button> | ||
</form> | ||
|
||
{% endblock%} |
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,11 @@ | ||
{% extends 'base.html'%} | ||
|
||
{% block body%} | ||
<div> | ||
<form method="post"> | ||
{% csrf_token %} | ||
{{form.as_p}} | ||
<button type="submit">Login</button> | ||
</form> | ||
</div> | ||
{%endblock%} |
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,7 @@ | ||
{% extends 'base.html'%} | ||
|
||
{% block body%} | ||
<h2> | ||
Logged out!!! | ||
</h2> | ||
{% endblock %} |
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,14 @@ | ||
{% extends 'base.html'%} | ||
|
||
{%block body%} | ||
<div> | ||
<form method="POST"> | ||
{% csrf_token%} | ||
{{form.as_p}} | ||
<button class="btn btn-primary" type="submit">Request Password Reset</button> | ||
|
||
</form> | ||
|
||
</div> | ||
|
||
{%endblock%} |
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,8 @@ | ||
{% extends 'base.html'%} | ||
|
||
{% block body %} | ||
<div class="alert alert-info">Your password has been reset</div> | ||
|
||
<a href="{% url 'login'%}">Sign in here</a> | ||
|
||
{% endblock %} |
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,10 @@ | ||
{%extends 'base.html'%} | ||
|
||
{%block body%} | ||
<form method="POST"> | ||
{% csrf_token%} | ||
{{form.as_p}} | ||
<button class="btn btn-outline-info" type="submit">Reset Password</button> | ||
</form> | ||
|
||
{%endblock%} |
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,6 @@ | ||
{% extends 'base.html'%} | ||
|
||
{% block body %} | ||
<div class="alert alert-info">A PASSWORD RESET CODE HAS BEEN SENT TO YOUR EMAIL</div> | ||
|
||
{% endblock %} |
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,15 @@ | ||
{% extends 'base.html'%} | ||
|
||
{% block body%} | ||
<div class="container"> | ||
<p> | ||
|
||
{{user}} | ||
{{user.first_name}} | ||
{{user.last_name}} | ||
|
||
</p> | ||
<a href="{%url 'edit_profile'%}">EDIT</a> | ||
</div> | ||
|
||
{% endblock%} |
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,10 @@ | ||
{% extends 'base.html'%} | ||
|
||
{% block body%} | ||
<form method="post"> | ||
{%csrf_token%} | ||
{{form.as_p}} | ||
<button type="submit">Submit</button> | ||
</form> | ||
|
||
{% endblock%} |
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,65 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> | ||
|
||
{% block head%} | ||
<meta charset="UTF-8"> | ||
|
||
<title>Pykla</title> | ||
|
||
{% endblock %} | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<nav class="navbar navbar-expand-lg navbar-light" style="background-color: #e3f2fd;"> | ||
<a class="navbar-brand" href="{% url 'index'%}">Pykla</a> | ||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
|
||
<div class="collapse navbar-collapse" id="navbarSupportedContent"> | ||
{% if user.is_authenticated%} | ||
<ul class="navbar-nav mr-auto"> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="{% url 'index'%}">HOME <span class="sr-only"></span></a> | ||
</li> | ||
<li> | ||
<a class="nav-link" href="{%url 'profile'%}">PROFILE</a> | ||
</li> | ||
<li> | ||
<a class="nav-link" href="{% url 'edit_pass'%}">EDIT PASSWORD</a> | ||
</li> | ||
<li> | ||
<a class="nav-link" href="{% url 'logout'%}">LOGOUT</a> | ||
</li> | ||
</ul> | ||
{%else%} | ||
|
||
<ul class="navbar-nav mr-auto nav-right"> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="{% url 'index'%}">HOME <span class="sr-only"></span></a> | ||
</li> | ||
<li> | ||
<a class="nav-link" href="{% url 'login'%}">LOGIN</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="{% url 'register'%}">REGISTER</a> | ||
</li> | ||
</ul> | ||
{%endif%} | ||
|
||
</div> | ||
</nav> | ||
|
||
<div class=""> | ||
{% block body%} | ||
<h2>Home</h2> | ||
{% endblock%} | ||
</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,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. | ||
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,31 @@ | ||
from django.urls import path | ||
from django.conf.urls import url | ||
from . import views | ||
from django.contrib.auth.views import LoginView,LogoutView, PasswordResetView, PasswordResetDoneView, \ | ||
PasswordResetConfirmView, PasswordResetCompleteView | ||
|
||
urlpatterns=[ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Dru94 what do you think about using social login instead, I'm thinking maybe GitHub and Google. I suggest you use Django Allauth but you can suggest any other package that does the same thing |
||
path('', views.index, name='index'), | ||
path('register/', views.reg, name='register'), | ||
path('login/', LoginView.as_view(template_name='acc/login.html'), name='login'), | ||
|
||
path('logout/', LogoutView.as_view(template_name='acc/logout.html'),name='logout'), | ||
|
||
path('profile/', views.profile, name='profile'), | ||
|
||
path('profile/edit', views.edit_profile, name='edit_profile'), | ||
|
||
path('edit_password/', views.edit_pass, name='edit_pass'), | ||
|
||
path('password/', PasswordResetView.as_view(template_name='acc/pass_reset.html'),name='pass_reset'), | ||
|
||
url(r'^reset-password/confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$', PasswordResetConfirmView.as_view(), | ||
{'template_name': 'accounts/reset_password_confirm.html', | ||
'post_reset_redirect': 'accounts:password_reset_complete'}, name='password_reset_confirm'), | ||
|
||
path('password-reset/done/',PasswordResetDoneView.as_view(template_name='acc/password_reset_done.html'), | ||
name='password_reset_done'), | ||
|
||
path('password-reset-complete/', PasswordResetCompleteView.as_view(template_name='acc/password_reset_complete.html'), | ||
name='password_reset_complete'), | ||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dru94 could you add a few tests