Finally a nice singup form
This commit is contained in:
parent
daa4be5b14
commit
ee6845c5b0
|
@ -1,20 +0,0 @@
|
|||
<form {% if form_enctype %}enctype="{{form_enctype}}"{% endif %} method="post" class="pure-form pure-form-aligned">
|
||||
{% csrf_token %}
|
||||
|
||||
{% for field in form %}
|
||||
<div class="field is-danger">
|
||||
<label class="label" for="{{field.name}}">{{field.label}}</label>
|
||||
<p class="control">
|
||||
{{ field }}
|
||||
</p>
|
||||
<p class="help is-danger">
|
||||
{{ field.errors.as_text}}
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="field is-grouped">
|
||||
<p class="control">
|
||||
<button class="button is-primary">{{button_text}}</button>
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
|
@ -4,18 +4,12 @@ from django.forms import ModelForm
|
|||
from users.models import User
|
||||
|
||||
class UserCreateForm(ModelForm):
|
||||
password1 = forms.CharField(label='Password', widget=forms.PasswordInput(attrs={'class': 'input'}))
|
||||
password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput(attrs={'class': 'input'}))
|
||||
password1 = forms.CharField(label='Passwort')
|
||||
password2 = forms.CharField(label='Passwort bestätigen')
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ['username', 'email', 'twitter', 'github']
|
||||
widgets = {
|
||||
'username' : forms.TextInput(attrs={'class': 'input'}),
|
||||
'email' : forms.TextInput(attrs={'class': 'input'}),
|
||||
'twitter' : forms.TextInput(attrs={'class': 'input'}),
|
||||
'github' : forms.TextInput(attrs={'class': 'input'}),
|
||||
}
|
||||
|
||||
|
||||
def clean_password2(self):
|
||||
|
|
|
@ -2,5 +2,5 @@ from django.db import models
|
|||
from django.contrib.auth.models import AbstractUser
|
||||
|
||||
class User(AbstractUser):
|
||||
github = models.CharField('github handle', max_length=128, blank=True)
|
||||
twitter = models.CharField('twitter handle', max_length=128, blank=True)
|
||||
github = models.CharField('github', max_length=128, blank=True)
|
||||
twitter = models.CharField('twitter', max_length=128, blank=True)
|
||||
|
|
|
@ -1,20 +1,183 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
|
||||
{% block title %} Sign up{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div class="rom-overview">
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<div class="box">
|
||||
<h1 class="title is-1">Registrieren</h1>
|
||||
{% if user.is_authenticated %}
|
||||
You are alerady logged in, why in the world would you want to sign up ?
|
||||
{% else %}
|
||||
{% include 'form.html' with button_text='sign up' %}
|
||||
{% endif %}
|
||||
{% if user.is_authenticated %}
|
||||
Was zur Hölle machst du bitte hier?<br/>
|
||||
Du bist eingeloggt und willst du dich registrieren.<br/>
|
||||
Geh heim du bist besoffen!
|
||||
{% else %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<div class="field is-horizontal">
|
||||
<div class="field-label is-normal">
|
||||
<label class="label" for="{{form.username.id_for_label}}">{{form.username.label}}</label>
|
||||
</div>
|
||||
<div class="field-body">
|
||||
<div class="field is-narrow">
|
||||
<div class="control has-icons-left has-icons-right">
|
||||
<input class="input {% if form.username.errors %}is-danger{% endif %} is-primary"
|
||||
type="text" name="{{form.username.html_name}}"
|
||||
id="{{form.username.id_for_label}}" value="{{form.username.value|default_if_none:''}}" />
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fa fa-user"></i>
|
||||
</span>
|
||||
<span class="icon is-small is-right">
|
||||
{% if form.username.errors %}
|
||||
<i class="fa fa-warning"></i>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<p class="help is-danger">
|
||||
{{form.username.errors.as_text}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field is-horizontal">
|
||||
<div class="field-label is-normal">
|
||||
<label class="label" for="{{form.email.id_for_label}}">{{form.email.label}}</label>
|
||||
</div>
|
||||
<div class="field-body">
|
||||
<div class="field is-narrow">
|
||||
<div class="control has-icons-left has-icons-right">
|
||||
<input class="input {% if form.email.errors %}is-danger{% endif %} is-primary"
|
||||
type="text" name="{{form.email.html_name}}"
|
||||
id="{{form.email.id_for_label}}" value="{{form.email.value|default_if_none:''}}" />
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fa fa-envelope"></i>
|
||||
</span>
|
||||
<span class="icon is-small is-right">
|
||||
{% if form.email.errors %}
|
||||
<i class="fa fa-warning"></i>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<p class="help is-danger">
|
||||
{{form.email.errors.as_text}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field is-horizontal">
|
||||
<div class="field-label is-normal">
|
||||
<label class="label" for="{{form.password1.id_for_label}}">{{form.password1.label}}</label>
|
||||
</div>
|
||||
<div class="field-body">
|
||||
<div class="field is-narrow">
|
||||
<div class="control has-icons-left has-icons-right">
|
||||
<input class="input {% if form.password1.errors %}is-danger{% endif %} is-primary"
|
||||
type="password" name="{{form.password1.html_name}}"
|
||||
id="{{form.password1.id_for_label}}" value="{{form.password1.value|default_if_none:'' }}" />
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fa fa-unlock-alt"></i>
|
||||
</span>
|
||||
<span class="icon is-small is-right">
|
||||
{% if form.password1.errors %}
|
||||
<i class="fa fa-warning"></i>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<p class="help is-danger">
|
||||
{{form.password1.errors.as_text}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field is-horizontal">
|
||||
<div class="field-label is-normal">
|
||||
<label class="label" for="{{form.password2.id_for_label}}">{{form.password2.label}}</label>
|
||||
</div>
|
||||
<div class="field-body">
|
||||
<div class="field is-narrow">
|
||||
<div class="control has-icons-left has-icons-right">
|
||||
<input class="input {% if form.password2.errors %}is-danger{% endif %} is-primary"
|
||||
type="password" name="{{form.password2.html_name}}"
|
||||
id="{{form.password2.id_for_label}}" value="{{form.password2.value|default_if_none:'' }}" />
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fa fa-unlock"></i>
|
||||
</span>
|
||||
<span class="icon is-small is-right">
|
||||
{% if form.password2.errors %}
|
||||
<i class="fa fa-warning"></i>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<p class="help is-danger">
|
||||
{{form.password2.errors.as_text}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field is-horizontal">
|
||||
<div class="field-label is-normal">
|
||||
<label class="label" for="{{form.twitter.id_for_label}}">{{form.twitter.label}}</label>
|
||||
</div>
|
||||
<div class="field-body">
|
||||
<div class="field is-narrow">
|
||||
<div class="control has-icons-left has-icons-right">
|
||||
<input class="input {% if form.twitter.errors %}is-danger{% endif %}"
|
||||
type="text" name="{{form.twitter.html_name}}"
|
||||
id="{{form.twitter.id_for_label}}" value="{{form.twitter.value|default_if_none:'' }}" />
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fa fa-twitter"></i>
|
||||
</span>
|
||||
<span class="icon is-small is-right">
|
||||
{% if form.twitter.errors %}
|
||||
<i class="fa fa-warning"></i>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<p class="help is-danger">
|
||||
{{form.twitter.errors.as_text}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field is-horizontal">
|
||||
<div class="field-label is-normal">
|
||||
<label class="label" for="{{form.github.id_for_label}}">{{form.github.label}}</label>
|
||||
</div>
|
||||
<div class="field-body">
|
||||
<div class="field is-narrow">
|
||||
<div class="control has-icons-left has-icons-right">
|
||||
<input class="input {% if form.github.errors %}is-danger{% endif %}"
|
||||
type="text" name="{{form.github.html_name}}"
|
||||
id="{{form.github.id_for_label}}" value="{{form.github.value|default_if_none:'' }}" />
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fa fa-github"></i>
|
||||
</span>
|
||||
<span class="icon is-small is-right">
|
||||
{% if form.github.errors %}
|
||||
<i class="fa fa-warning"></i>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<p class="help is-danger">
|
||||
{{form.github.errors.as_text}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field is-grouped">
|
||||
<p class="control">
|
||||
<button class="button is-primary">Registrieren</button>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue