Skip to content

Commit

Permalink
registering error sohwing work now
Browse files Browse the repository at this point in the history
  • Loading branch information
Arsalankarimzad committed Aug 7, 2020
1 parent f53af56 commit 5c67e14
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 15 deletions.
4 changes: 2 additions & 2 deletions account/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class UserRegistrationForm(UserCreationForm):

def clean_email(self):
if User.objects.filter(email=self.cleaned_data['email']).exists():
raise forms.ValidationError("")
raise forms.ValidationError("this email is already registered")
return self.cleaned_data['email']

def clean_username(self):
if User.objects.filter(username=self.cleaned_data['username']).exists():
raise forms.ValidationError("")
raise forms.ValidationError("this username is already registered")
return self.cleaned_data['username']

class Meta:
Expand Down
1 change: 1 addition & 0 deletions account/static/account/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$('.help-block').addClass('alert alert-danger')
3 changes: 3 additions & 0 deletions account/static/account/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ul {
list-style-type: none !important;
}
40 changes: 27 additions & 13 deletions account/templates/account/register.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{% extends "base.html" %}
{% load humanize %}
{% load static %}
{% load widget_tweaks %}
{% block title %} | Register {% endblock %}
{% load crispy_forms_tags %}
{% block content %}

<link rel="stylesheet" href={% static "account/styles.css" %}>
<section id="register" class="bg-light py-5">
<div class="container">
<div class="row">
Expand All @@ -18,48 +20,59 @@ <h4>
{% include "partials/alerts.html" %}
<form action="{% url 'register' %}" method="POST">
{% csrf_token %}
{% if form.errors.first_name | length >= 0 %}
<div class="alert alert-danger">{{ form.errors.first_name }}</div>
{% if form.errors %}
<ul>
{% for error in form.errors %}
<li>{{ error.errors }}</li>
{% endfor %}
</ul>
{% endif %}
{% if form.first_name.errors.keys.count > 0 %}
<div class="alert alert-danger">{{ form.first_name.errors }}</div>
{% endif %}
<div class="form-group">
<label for="first_name">First Name</label>
{# <input type="text" name="first_name" class="form-control" required>#}
{{ form.first_name|as_crispy_field }}
</div>
{% if form.errors.last_name | length >= 0 %}
<div class="alert alert-danger">{{ form.errors.last_name }}</div>
{% if form.last_name.errors.keys.count > 0 %}
<div class="alert alert-danger">{{ form.last_name.errors }}</div>
{% endif %}
<div class="form-group">
<label for="last_name">Last Name</label>
{# <input type="text" name="last_name" class="form-control" required>#}
{{ form.last_name|as_crispy_field }}
</div>
{% if form.errors.username | length >= 0%}
<div class="alert alert-danger">{{ form.errors.username }}</div>
{% if form.username.errors.keys.count > 0 %}

<div class="alert alert-danger">{{ form.username.errors }}</div>
{% endif %}
<div class="form-group">
<label for="username">Username</label>
{# <input type="text" name="user_name" class="form-control" required>#}
{{ form.username|as_crispy_field }}
</div>
{% if form.errors.email | length >= 0%}
<div class="alert alert-danger">{{ form.errors.email }}</div>
{% if form.email.errors.keys.count > 0 %}

<div class="alert alert-danger">{{ form.email.errors }}</div>
{% endif %}
<div class="form-group">
<label for="email">Email</label>
{# <input type="email" name="email" class="form-control" required>#}
{{ form.email|as_crispy_field }}
</div>
{% if form.errors.password1 | length >= 0%}
<div class="alert alert-danger">{{ form.errors.password1 }}</div>
{% if form.password1.errors.keys.count > 0 %}

<div class="alert alert-danger">{{ form.password1.errors }}</div>
{% endif %}
<div class="form-group">
<label for="password">Password</label>
{# <input type="password" name="password" class="form-control" required>#}
{{ form.password1|as_crispy_field }}
</div>
{% if form.errors.password2 | length >= 0%}
<div class="alert alert-danger">{{ form.errors.password1 }}</div>
{% if form.password1.errors.keys.count > 0 %}

<div class="alert alert-danger">{{ form.password1.errors }}</div>
{% endif %}
<div class="form-group">
<label for="password2">Confirm Password</label>
Expand All @@ -74,4 +87,5 @@ <h4>
</div>
</div>
</section>
<script src="{% static 'account/main.js' %}"></script>
{% endblock %}
1 change: 1 addition & 0 deletions account/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
'', auth_views.PasswordResetCompleteView.as_view
(template_name='account/password_reset_complete.html'),
name="password_reset_complete"),
# path('activate/<str:uidb64>/<str:token' >, views.activate, name="activate"),

]
2 changes: 2 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<!-- Custom -->
<link rel="stylesheet" href={% static "css/style.css" %}>
<link rel="stylesheet" href={% static "css/lightbox.min.css" %}>
<script type="text/javascript" src="{% static 'js/jquery-3.3.1.min.js' %}">
</script>

<title>BT Real Estate {% block title %}{% endblock %}</title>
</head>
Expand Down

0 comments on commit 5c67e14

Please sign in to comment.