-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Django-Projects-Ls/feature/auth
Feature/auth
- Loading branch information
Showing
13 changed files
with
93 additions
and
182 deletions.
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,10 @@ | ||
from django import forms | ||
from django.contrib.auth.forms import UserCreationForm | ||
from django.contrib.auth.models import User | ||
|
||
class CustomUserCreationForm(UserCreationForm): | ||
email = forms.EmailField(required=True) | ||
|
||
class Meta: | ||
model = User | ||
fields = ("username", "email", "password1", "password2") |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% extends 'home.html' %} | ||
|
||
{% block navbar %} {% endblock %} | ||
|
||
{% block title %} <title> Login Page </title> {% endblock %} | ||
|
||
{% block content %} | ||
<h1>Login Page</h1> | ||
<form method="post"> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
<p> Don't have any account? Create one <a href="/sign-up">here</a>!</p> | ||
<button type="submit">Login</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,15 @@ | ||
{% extends 'home.html' %} | ||
|
||
{% block navbar %} {% endblock %} | ||
|
||
{% block title %} <title> Sign Up Page </title> {% endblock %} | ||
|
||
{% block content %} | ||
<h1>Sign Up Page</h1> | ||
<form method="post"> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
<p> Have an account? Login <a href="/login">here</a>!</p> | ||
<button type="submit">Register</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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,39 @@ | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
from django.views.generic.edit import CreateView | ||
from django.contrib.auth import login | ||
from django.urls import reverse_lazy | ||
|
||
from ..models import Curso, Disciplina, Horario | ||
from ..forms import CustomUserCreationForm | ||
|
||
|
||
class CourseCreateRequestHandler(CreateView): | ||
class UserCreateRequestHandler(CreateView): | ||
form_class = CustomUserCreationForm | ||
template_name = "registration/sign_up.html" | ||
success_url = reverse_lazy("login") | ||
|
||
def form_valid(self, form): | ||
user = form.save() | ||
login(self.request, user) | ||
return super().form_valid(form) | ||
|
||
|
||
class CourseCreateRequestHandler(LoginRequiredMixin, CreateView): | ||
model = Curso | ||
fields = ["nome", "codigo", "disciplinas", "horario"] | ||
template_name = "form.html" | ||
success_url = reverse_lazy("list_courses") | ||
|
||
|
||
class DisciplineCreateRequestHandler(CreateView): | ||
class DisciplineCreateRequestHandler(LoginRequiredMixin, CreateView): | ||
model = Disciplina | ||
fields = ["nome", "codigo", "horario"] | ||
template_name = "form.html" | ||
success_url = reverse_lazy("list_disciplines") | ||
|
||
class ScheduleCreateRequestHandler(CreateView): | ||
|
||
class ScheduleCreateRequestHandler(LoginRequiredMixin,CreateView): | ||
model = Horario | ||
fields = ["dia", "hora_inicio", "hora_fim"] | ||
template_name = "form.html" | ||
success_url = reverse_lazy("list_schedules") | ||
success_url = reverse_lazy("list_schedules") |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
from django.views.generic import TemplateView | ||
|
||
|
||
class HomeRequestHandler(LoginRequiredMixin, TemplateView): | ||
template_name = "home.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
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