Skip to content

Commit

Permalink
Add 'first_name', 'last_name' and 'other_info' to registration form.
Browse files Browse the repository at this point in the history
  • Loading branch information
wlorenzetti committed Sep 18, 2023
1 parent 7f26883 commit 65916f0
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 32 deletions.
5 changes: 5 additions & 0 deletions g3w-admin/core/static/css/g3wadmin.css
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,8 @@ input[type=file]::file-selector-button:hover {
a.layer-action {
cursor: pointer;
}

.register-box {
width: 720px;
margin: 7% auto;
}
2 changes: 1 addition & 1 deletion g3w-admin/templates/base_login.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{% endblock %}

{% block body_content %}
<div class="login-box">
<div class="{% block login-box-class %}login-box{% endblock %}">
{% block login_page_logo %}
<div class="login-logo">
<span class="logo-lg">
Expand Down
17 changes: 15 additions & 2 deletions g3w-admin/usersmanage/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
ModelMultipleChoiceField,
ChoiceField,
ModelForm,
ChoiceField
ChoiceField,
CharField,
Textarea
)
from django.utils.datastructures import MultiValueDict
from django.utils.translation import ugettext, ugettext_lazy as _
Expand Down Expand Up @@ -805,7 +807,18 @@ class G3WRegistrationForm(G3WreCaptchaFormMixin, RegistrationForm):
"""
Form custom for user registration form
"""
pass

other_info = CharField(label=_('Other informations'), widget=Textarea(), required=False)

# Add custom data: first and last name etc.
class Meta(RegistrationForm.Meta):
fields = RegistrationForm.Meta.fields + [
'first_name',
'last_name',
'other_info'
]





Expand Down
1 change: 1 addition & 0 deletions g3w-admin/usersmanage/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Userdata(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
department = models.OneToOneField(Department, null=True, blank=True, on_delete=models.DO_NOTHING)
avatar = models.ImageField(_('Avatar'), upload_to='user_avatar', null=True, blank=True)
other_info = models.TextField(_('Other informations'), null=True, blank=True)


USER_BACKEND_TYPES = G3WChoices(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
{% load static %}
{% load i18n %}

{% block login-box-class %}register-box{% endblock %}

{% block login_page_box_body %}
<div class="register-box-body">
<p class="register-box-msg">{% comment %}Put her custom message for registration form{% endcomment %}</p>
Expand All @@ -14,37 +16,63 @@ <h4><i class="icon fa fa-ban"></i> {% trans 'ERROR' %}!</h4>
{% endif %}
<form method="post">
{% csrf_token %}
<div class="form-group has-feedback">
<input type="text" class="form-control" name="{{form.username.name}}" placeholder="{{form.username.label|capfirst}}">
<span class="glyphicon glyphicon-user form-control-feedback"></span>
{% if form.username.help_text %}
<p class="help">{{ form.username.help_text|safe }}</p>
{% endif %}
</div>
<div class="form-group has-feedback">
<input type="text" class="form-control" name="{{form.email.name}}" placeholder="{{form.email.label|capfirst}}">
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
{% if form.email.help_text %}
<p class="help">{{ form.email.help_text|safe }}</p>
{% endif %}
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control" name="{{form.password1.name}}" placeholder="{{form.password1.label|capfirst}}">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
{% if form.password1.help_text %}
<p class="help">{{ form.password1.help_text|safe }}</p>
{% endif %}
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control" name="{{form.password2.name}}" placeholder="{{form.password2.label|capfirst}}">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
{% if form.password2.help_text %}
<p class="help">{{ form.password2.help_text|safe }}</p>
{% endif %}
<div class="row">
<div class="col-md-6 col-xs-12">
<div class="form-group has-feedback">
<input type="text" class="form-control" name="{{form.username.name}}" placeholder="{{form.username.label|capfirst}}">
<span class="glyphicon glyphicon-user form-control-feedback"></span>
{% if form.username.help_text %}
<p class="help">{{ form.username.help_text|safe }}</p>
{% endif %}
</div>
<div class="form-group has-feedback">
<input type="text" class="form-control" name="{{form.email.name}}" placeholder="{{form.email.label|capfirst}}">
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
{% if form.email.help_text %}
<p class="help">{{ form.email.help_text|safe }}</p>
{% endif %}
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control" name="{{form.password1.name}}" placeholder="{{form.password1.label|capfirst}}">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
{% if form.password1.help_text %}
<p class="help">{{ form.password1.help_text|safe }}</p>
{% endif %}
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control" name="{{form.password2.name}}" placeholder="{{form.password2.label|capfirst}}">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
{% if form.password2.help_text %}
<p class="help">{{ form.password2.help_text|safe }}</p>
{% endif %}
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group has-feedback">
<input type="text" class="form-control" name="{{form.first_name.name}}" placeholder="{{form.first_name.label|capfirst}}">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
{% if form.first_lame.help_text %}
<p class="help">{{ form.first_name.help_text|safe }}</p>
{% endif %}
</div>
<div class="form-group has-feedback">
<input type="text" class="form-control" name="{{form.last_name.name}}" placeholder="{{form.last_name.label|capfirst}}">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
{% if form.first_lame.help_text %}
<p class="help">{{ form.last_name.help_text|safe }}</p>
{% endif %}
</div>
<div class="form-group has-feedback">
<textarea style="height: 200px" class="form-control" name="{{form.other_info.name}}" placeholder="{{form.other_info.label|capfirst}}"></textarea>
{% if form.other_info.help_text %}
<p class="help">{{ form.other_info.help_text|safe }}</p>
{% endif %}
</div>
</div>
</div>
{{ form.captcha }}
<div class="row">
<div class="col-xs-4">
<div class="col-md-offset-3 col-md-6 col-xs-offset-0 col-xs-12">
{{ form.captcha }}
<button type="submit" class="btn btn-primary btn-block btn-flat">{% trans 'Sign Up' %}</button>
</div><!-- /.col -->
</div>
Expand Down

0 comments on commit 65916f0

Please sign in to comment.