-
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 #73 from geislern/feature-signup
Signup
- Loading branch information
Showing
18 changed files
with
264 additions
and
49 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 |
---|---|---|
|
@@ -158,4 +158,10 @@ | |
KEEP_COMMENTS_ON_MINIFYING = True | ||
|
||
LOGIN_URL = "/accounts/login/" | ||
LOGIN_REDIRECT_URL = "/" | ||
LOGIN_REDIRECT_URL = "/intern/" | ||
|
||
# Emails | ||
SEND_MAILS = True | ||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | ||
ADMIN_MAILS = ['[email protected]'] | ||
DEFAULT_FROM_EMAIL = '[email protected]' |
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
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,49 @@ | ||
from betterforms.multiform import MultiModelForm | ||
from django.contrib.auth.forms import UserCreationForm | ||
from django.forms import ModelForm, TextInput | ||
|
||
from dachor_internal.models import Profile | ||
|
||
|
||
class DateInput(TextInput): | ||
input_type = 'date' | ||
|
||
|
||
class UserForm(UserCreationForm): | ||
class Meta(UserCreationForm.Meta): | ||
fields = ['email', 'first_name', 'last_name', 'username'] | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(UserForm, self).__init__(*args, **kwargs) | ||
self.fields['email'].required = True | ||
self.fields['first_name'].required = True | ||
|
||
|
||
class ProfileForm(ModelForm): | ||
class Meta: | ||
model = Profile | ||
exclude = ['user'] | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(ProfileForm, self).__init__(*args, **kwargs) | ||
self.fields['birthday'].widget = DateInput() | ||
|
||
|
||
class SignupForm(MultiModelForm): | ||
form_classes = { | ||
'user': UserForm, | ||
'profile': ProfileForm | ||
} | ||
|
||
def save(self, commit=True): | ||
objects = super(SignupForm, self).save(commit=False) | ||
|
||
if commit: | ||
user = objects['user'] | ||
user.is_active = False | ||
user.save() | ||
profile = objects['profile'] | ||
profile.user = user | ||
profile.save() | ||
|
||
return objects |
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
12 changes: 12 additions & 0 deletions
12
dachor_internal/templates/dachor_internal/base_internal.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,12 @@ | ||
{% extends 'dachor_website/base.html' %} | ||
|
||
{% load bootstrap4 %} | ||
|
||
{% block content %} | ||
<div class="mt-2"> | ||
{% bootstrap_messages %} | ||
</div> | ||
|
||
{% block content_internal %} | ||
{% endblock %} | ||
{% endblock %} |
13 changes: 13 additions & 0 deletions
13
dachor_internal/templates/dachor_internal/edit_profile.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,13 @@ | ||
{% extends 'dachor_internal/base_internal.html' %} | ||
|
||
{% load bootstrap4 %} | ||
|
||
{% block content_internal %} | ||
<h1>Profil bearbeiten</h1> | ||
|
||
<form method="post" class="post-form"> | ||
{% csrf_token %} | ||
{% bootstrap_form form %} | ||
<input type="submit" class="btn btn-outline-custom float-right" value="Aktualisieren"> | ||
</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,9 @@ | ||
{% extends 'dachor_internal/base_internal.html' %} | ||
|
||
{% load bootstrap4 %} | ||
|
||
{% block content_internal %} | ||
<h1>Interner Bereich</h1> | ||
|
||
<p class="text-center">Hallo {{ user.first_name }}</p> | ||
{% endblock %} |
17 changes: 17 additions & 0 deletions
17
dachor_internal/templates/dachor_internal/not_confirmed.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,17 @@ | ||
{% extends 'dachor_internal/base_internal.html' %} | ||
|
||
{% load bootstrap4 %} | ||
|
||
{% block content_internal %} | ||
<h1>Interner Bereich</h1> | ||
|
||
<div class="alert alert-warning"> | ||
<h4 class="alert-heading">Zugang noch nicht bestätigt</h4> | ||
<p class="mb-0"> | ||
Dein Zugang zum internen Bereich muss noch überprüft und freigeschaltet werden. | ||
Hab bitte noch ein bisschen Geduld. | ||
</p> | ||
</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,14 @@ | ||
{% extends 'dachor_internal/base_internal.html' %} | ||
|
||
{% load bootstrap4 %} | ||
|
||
{% block content_internal %} | ||
<h1>Freischaltung für internen Bereich beantragen</h1> | ||
|
||
<form method="post" class="post-form"> | ||
{% csrf_token %} | ||
{% bootstrap_form form.user %} | ||
{% bootstrap_form form.profile %} | ||
<input type="submit" class="btn btn-outline-custom float-right" value="Registrieren"> | ||
</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 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,8 +1,12 @@ | ||
from django.urls import path, include | ||
from django.urls import path | ||
|
||
from . import views | ||
|
||
app_name = 'internal' | ||
|
||
urlpatterns = [ | ||
path('', views.StartView.as_view(), name='start'), | ||
path('signup/', views.SignupView.as_view(), name='signup'), | ||
path('not-confirmed/', views.NotConfirmedView.as_view(), name='not-confirmed'), | ||
path('profile/edit/', views.ProfileEditView.as_view(), name='profile-edit'), | ||
] |
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,3 +1,41 @@ | ||
from django.shortcuts import render | ||
from django.contrib import messages | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
from django.urls import reverse_lazy | ||
from django.views.generic import TemplateView, CreateView, FormView | ||
|
||
# Create your views here. | ||
from dachor_internal.forms import SignupForm, ProfileForm | ||
from dachor_website.views import NavbarHighlightMixin | ||
|
||
|
||
class StartView(NavbarHighlightMixin, LoginRequiredMixin, TemplateView): | ||
template_name = 'dachor_internal/index.html' | ||
navbar_active = 'internal' | ||
|
||
|
||
class NotConfirmedView(NavbarHighlightMixin, TemplateView): | ||
template_name = 'dachor_internal/not_confirmed.html' | ||
navbar_active = 'internal' | ||
|
||
|
||
class SignupView(NavbarHighlightMixin, CreateView): | ||
form_class = SignupForm | ||
template_name = 'dachor_internal/signup.html' | ||
success_url = reverse_lazy('internal:not-confirmed') | ||
navbar_active = 'internal' | ||
|
||
|
||
class ProfileEditView(NavbarHighlightMixin, FormView): | ||
form_class = ProfileForm | ||
template_name = 'dachor_internal/edit_profile.html' | ||
success_url = reverse_lazy('internal:profile-edit') | ||
navbar_active = 'internal' | ||
|
||
def get_form_kwargs(self): | ||
kwargs = super().get_form_kwargs() | ||
kwargs.update(instance=self.request.user.profile) | ||
return kwargs | ||
|
||
def form_valid(self, form): | ||
form.save() | ||
messages.add_message(self.request, messages.SUCCESS, "Informationen aktualisiert") | ||
return super().form_valid(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
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
Oops, something went wrong.