10# created user profile update form
This commit is contained in:
parent
e3140edfd4
commit
f8c4829d55
86
templates/users/update.html
Normal file
86
templates/users/update.html
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load static %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="hero-wrap js-fullheight" style="background-image: url('{% static 'images/bg_2.jpg' %}');" data-stellar-background-ratio="0.5"> <div class="overlay"></div>
|
||||||
|
<div class="container">
|
||||||
|
<div class="row no-gutters slider-text js-fullheight align-items-end justify-content-start" data-scrollax-parent="true">
|
||||||
|
<div class="col-md-8 ftco-animate text-center text-md-left mb-5" data-scrollax=" properties: { translateY: '70%' }">
|
||||||
|
<p class="breadcrumbs" data-scrollax="properties: { translateY: '30%', opacity: 1.6 }"><span class="mr-3"><a href="index.html">Home <i class="ion-ios-arrow-forward"></i></a></span> <span>Login</span></p>
|
||||||
|
<h1 class="mb-3 bread" data-scrollax="properties: { translateY: '30%', opacity: 1.6 }">Login</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ftco-section bg-light">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col-md-12 col-lg-8 mb-5">
|
||||||
|
{% if user.is_employee %}
|
||||||
|
<form action="#" class="p-5 bg-white" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{% if form.errors %}
|
||||||
|
<div class="alert alert-danger alert-dismissible" role="alert">
|
||||||
|
<div id="form_errors">
|
||||||
|
{% for key, value in form.errors.items %}
|
||||||
|
<span class="fieldWrapper">
|
||||||
|
{{ key }}: {{ value }}
|
||||||
|
</span>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<button type="button" class="close" data-dismiss="alert" aria_hidden="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% for field in form.visible_fields|slice:"3" %}
|
||||||
|
<div class="row form-group">
|
||||||
|
<div class="col-md-12 mb-3 mb-md-0">
|
||||||
|
<label class="font-weight-bold" for="fullname">{{ field.label }}</label>
|
||||||
|
<input type="{{ field.field.widget.input_type }}" id="fullname" class="form-control" placeholder="{{ field.label }}" name="{{ field.html_name }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
<div class="row form-group">
|
||||||
|
<div class="col-md-12 mb-3 mb-md-0"><h5>Resume</h5>
|
||||||
|
{{ form.media }}
|
||||||
|
{{ form.resume }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row form-group">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<input type="submit" value="Login" class="btn btn-primary py-2 px-5">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<div class="p-4 mb-3 bg-white">
|
||||||
|
<h3 class="h5 text-black mb-3">Contact Info</h3>
|
||||||
|
<p class="mb-0 font-weight-bold">Address</p>
|
||||||
|
<p class="mb-4">203 Fake St. Mountain View, San Francisco, California, USA</p>
|
||||||
|
|
||||||
|
<p class="mb-0 font-weight-bold">Phone</p>
|
||||||
|
<p class="mb-4"><a href="#">+1 232 3235 324</a></p>
|
||||||
|
|
||||||
|
<p class="mb-0 font-weight-bold">Email Address</p>
|
||||||
|
<p class="mb-0"><a href="#"><span class="__cf_email__" data-cfemail="671e081215020a060e0b2703080a060e094904080a">[email protected]</span></a></p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="p-4 mb-3 bg-white">
|
||||||
|
<h3 class="h5 text-black mb-3">More Info</h3>
|
||||||
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa ad iure porro mollitia architecto hic consequuntur. Distinctio nisi perferendis dolore, ipsa consectetur</p>
|
||||||
|
<p><a href="#" class="btn btn-primary py-2 px-4">Learn More</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -1,6 +1,6 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib.auth.forms import UserCreationForm
|
from django.contrib.auth.forms import UserCreationForm
|
||||||
from users.models import Account
|
from users.models import Account, Profile
|
||||||
|
|
||||||
|
|
||||||
class AccountRegisterForm(UserCreationForm):
|
class AccountRegisterForm(UserCreationForm):
|
||||||
@ -10,3 +10,13 @@ class AccountRegisterForm(UserCreationForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = Account
|
model = Account
|
||||||
fields = ['email', 'first_name', 'last_name']
|
fields = ['email', 'first_name', 'last_name']
|
||||||
|
|
||||||
|
|
||||||
|
class UserUpdateForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Profile
|
||||||
|
exclude = ('user',)
|
||||||
|
|
||||||
|
widgets = {
|
||||||
|
'birthday': forms.DateInput(attrs={'type': 'date'})
|
||||||
|
}
|
||||||
|
@ -6,4 +6,5 @@ urlpatterns = [
|
|||||||
path('register/', UserRegisterView.as_view(), name='register'),
|
path('register/', UserRegisterView.as_view(), name='register'),
|
||||||
path('login/', UserLoginView.as_view(), name='login'),
|
path('login/', UserLoginView.as_view(), name='login'),
|
||||||
path('logout/', UserLogoutView.as_view(), name='logout'),
|
path('logout/', UserLogoutView.as_view(), name='logout'),
|
||||||
|
path('update/<int:pk>/', UserUpdateView.as_view(), name='update'),
|
||||||
]
|
]
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
from django.contrib.auth.views import LoginView, LogoutView
|
from django.contrib.auth.views import LoginView, LogoutView
|
||||||
from django.contrib.messages.views import SuccessMessageMixin
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.views.generic import CreateView
|
from django.views.generic import CreateView, UpdateView
|
||||||
|
|
||||||
from users.forms import AccountRegisterForm
|
from users.forms import AccountRegisterForm, UserUpdateForm
|
||||||
|
from users.models import Profile
|
||||||
|
|
||||||
|
|
||||||
class UserRegisterView(SuccessMessageMixin, CreateView):
|
class UserRegisterView(SuccessMessageMixin, CreateView):
|
||||||
@ -31,3 +32,10 @@ class UserLoginView(LoginView):
|
|||||||
|
|
||||||
class UserLogoutView(LogoutView):
|
class UserLogoutView(LogoutView):
|
||||||
template_name = 'users/login.html'
|
template_name = 'users/login.html'
|
||||||
|
|
||||||
|
|
||||||
|
class UserUpdateView(SuccessMessageMixin, UpdateView):
|
||||||
|
model = Profile
|
||||||
|
success_message = "You updated your profile!"
|
||||||
|
template_name = 'users/update.html'
|
||||||
|
form_class = UserUpdateForm
|
||||||
|
Loading…
Reference in New Issue
Block a user