Skip to content

Commit

Permalink
Edit profile change
Browse files Browse the repository at this point in the history
  • Loading branch information
mamtoraah committed Feb 8, 2019
1 parent e56815b commit 83de1d1
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 92 deletions.
Binary file modified accounts/__pycache__/forms.cpython-36.pyc
Binary file not shown.
Binary file modified accounts/__pycache__/views.cpython-36.pyc
Binary file not shown.
16 changes: 13 additions & 3 deletions accounts/templates/accounts/change_password.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@
visibility: hidden;
}
</style>
<div align="center">
<form method="post">
<div class="container text-center">
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<table align='center'>
{% for field in form %}
<tr>
<td>{{ field.label_tag }}</td><td>{{ field }}</td>
{% for error in field.errors %}
<p style="color: red">{{ error }}</p>
{% endfor %}
</tr>
<tr><td>&nbsp;</td></tr>
{% endfor %}
</table>
<button type="submit">Submit</button>
</form>
</div>
Expand Down
27 changes: 21 additions & 6 deletions accounts/templates/accounts/editprofile.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
{%extends 'base.html'%}
{%block head%}<title>Edit Profile Page</title>{%endblock%}
{%block body%}
<div align="center">
<form method="post">
<div class="container text-center">
<h2>Sign up</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<br>
<button type="submit">Update</button>
</form>
<table align='center'>
{% for field in form %}
<tr>
{% if field.name != 'password'%}
<td>{{ field.label_tag }}</td><td>{{ field }}</td>

{% for error in field.errors %}
<p style="color: red">{{ error }}</p>
{% endfor %}
{% else %}
<td>Password:</td> <td><a href="{%url 'change_password'%}">Click here </a> to change password</td>
{%endif%}
</tr>
<tr><td>&nbsp;</td></tr>
{% endfor %}
</table>
<button type="submit">Submit</button>
</form>
</div>
{%endblock%}
112 changes: 54 additions & 58 deletions accounts/templates/accounts/profile.html
Original file line number Diff line number Diff line change
@@ -1,79 +1,75 @@
{%extends 'base.html'%}
{%block head%}<title>User Profile</title>{%endblock%}
{%block body%}
<div id="main">
<div class="container" style="width:70%">
<div class="container">
<div class="container" align="center">
<h2>Welcome {{ user.get_full_name}} </h2>
<p style="font-size: 35px"><b>Profile Details</b></p>
</div>
<br>
<div class="form-group">
<br><br><br><br>
<b><label class="control-label col-sm-2" for="UID" style="font-size:25px">UID:</label></b>

<div class="col-sm-10">
<input type="text" class="form-control" id="email" placeholder="UID of Student" name="UID" value="{{ UID }}"
style="font-size: 18px">
<br><br>
</div>
<h2>Welcome {{ user.get_full_name}} </h2>
<p style="font-size: 35px">Profile Details</p>
</div>
<div class="form-group">
<br><br>
<label class="control-label col-sm-2" for="UID" style="font-size:25px">UID:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="email" placeholder="UID of Student" name="UID" value="{{ UID }}"
style="font-size: 18px">
<br><br>
</div>
<div class="form-group">
<b><label class="control-label col-sm-2" for="stuusername" style="font-size:25px">Username:</label></b>
</div>
<div class="form-group">
<b><label class="control-label col-sm-2" for="stuusername" style="font-size:25px">Username:</label></b>
<br><br>
<div class="col-sm-10">
<input type="text" class="form-control" id="stuusername" placeholder="Username of Student" name="stuusername"
value='{{ user.username}}' style="font-size: 18px">
<br><br>
<div class="col-sm-10">
<input type="text" class="form-control" id="stuusername" placeholder="Username of Student" name="stuusername"
value='{{ user.username}}' style="font-size: 18px">
<br><br>
</div>
</div>
</div>

<div class="form-group">
<b><label class="control-label col-sm-2" for="stuname" style="font-size:25px">Name:</label></b>
<div class="form-group">
<b><label class="control-label col-sm-2" for="stuname" style="font-size:25px">Name:</label></b>
<br><br>
<div class="col-sm-10">
<input type="text" class="form-control" id="stuname" placeholder="Name of Student" name="stuname" value='{{ user.get_full_name}}'
style="font-size: 18px">
<br><br>
<div class="col-sm-10">
<input type="text" class="form-control" id="stuname" placeholder="Name of Student" name="stuname" value='{{ user.get_full_name}}'
style="font-size: 18px">
<br><br>
</div>
</div>
<div class="form-group">
<b><label class="control-label col-sm-2" for="stuemail" style="font-size:25px">EmailId:</label></b>
</div>
<div class="form-group">
<b><label class="control-label col-sm-2" for="stuemail" style="font-size:25px">EmailId:</label></b>
<br><br>
<div class="col-sm-10">
<input type="text" class="form-control" id="stuemail" placeholder="Email ID of Student" name="stuemail" value='{{ user.email}}'
style="font-size: 18px">
<br><br>
<div class="col-sm-10">
<input type="text" class="form-control" id="stuemail" placeholder="Email ID of Student" name="stuemail" value='{{ user.email}}'
style="font-size: 18px">
<br><br>
</div>
</div>
<div class="form-group">
<b><label class="control-label col-sm-2" for="branch" style="font-size:25px">Branch:</label></b>
</div>
<div class="form-group">
<b><label class="control-label col-sm-2" for="branch" style="font-size:25px">Branch:</label></b>
<br><br>
<div class="col-sm-10">
<input type="text" class="form-control" id="branch" placeholder="Branch of Student" name="branch" value="{{ branch }}"
style="font-size: 18px">
<br><br>
<div class="col-sm-10">
<input type="text" class="form-control" id="branch" placeholder="Branch of Student" name="branch" value="{{ branch }}"
style="font-size: 18px">
<br><br>
</div>
</div>
<div class="form-group">
<b><label class="control-label col-sm-2" for="year" style="font-size:25px">Year:</label></b>
</div>
<div class="form-group">
<b><label class="control-label col-sm-2" for="year" style="font-size:25px">Year:</label></b>
<br><br>
<div class="col-sm-10">
<input type="text" class="form-control" id="year" placeholder="Year of Student" name="year" value="{{ year }}"
style="font-size: 18px">
<br><br>
<div class="col-sm-10">
<input type="text" class="form-control" id="year" placeholder="Year of Student" name="year" value="{{ year }}"
style="font-size: 18px">
<br><br>
</div>
</div>
<div class="form-group">
<b><label class="control-label col-sm-2" for="contactno" style="font-size:25px">Contact No:</label></b>
</div>
<div class="form-group">
<b><label class="control-label col-sm-2" for="contactno" style="font-size:25px">Contact No:</label></b>
<br><br>
<div class="col-sm-10">
<input type="text" class="form-control" id="contactno" placeholder="Contact No." name="contactno" value="{{ contactno }}"
style="font-size: 18px">
<br><br>
<div class="col-sm-10">
<input type="text" class="form-control" id="contactno" placeholder="Contact No." name="contactno" value="{{ contactno }}"
style="font-size: 18px">
<br><br>
</div>
</div>

</div>
</div>

{%endblock%}
31 changes: 10 additions & 21 deletions accounts/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
z-index: 1;
}

body {
background-color: #84CEEB;
}

.button {
display: inline-block;
padding: 10px 20px;
Expand Down Expand Up @@ -62,38 +58,31 @@
<title>Base</title>
{% endblock %}
</head>
<script>
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px";
document.body.style.backgroundColor = "#84CEEB";
}

function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("main").style.marginLeft = "0";
document.body.style.backgroundColor = "#84CEEB";
}
</script>

<body>
<body class="container">
<nav class="navbar navbar-inverse" style="z-index: 0;background-color: #374785;background: #374785;border-color:#374785 ">
<div class="container-fluid">
<div class="navbar-header">
</div>
</div>
<ul class="nav navbar-nav">
<li><a href="{%url 'home'%}" style="color: #f1f1f1">Lost & Found</a></li>
<li><a href="{%url 'login'%}" style="color: #f1f1f1">Login</a></li>
{%if user.is_authenticated %}
<li><a href="{%url 'profile'%}" style="color: #f1f1f1">My Profile</a></li>
<li><a href="{%url 'edit_profile'%}" style="color: #f1f1f1">Edit Profile</a></li>
<li><a href="{%url 'request_item'%}" style="color: #f1f1f1">Request Item</a></li>
{%else%}
<li><a href="{%url 'login'%}" style="color: #f1f1f1">Login</a></li>
{%endif%}
<li><a href="/admin" style="color: #f1f1f1">Administrator</a></li>
<li><a href="http://www.spit.ac.in/about/" style="color: #f1f1f1"> About us</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
{% if user.is_authenticated %}
<li><a href="{%url 'logout'%}" style="color: #f1f1f1"><span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
{%else%}
<li><a href="{%url 'register'%}" style="color: #f1f1f1"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
<li><a href="{%url 'logout'%}" style="color: #f1f1f1"><span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
{% endif %}
&nbsp;&nbsp;
</ul>
</div>
</nav>
Expand Down
8 changes: 4 additions & 4 deletions accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,21 @@ def editprofile(request):
form = EditProfileForm(request.POST, instance=request.user)
if form.is_valid():
form.save()
return redirect('http://localhost:8000/accounts/profile')
return redirect('accounts/profile')
else:
form = EditProfileForm(instance=request.user)
args = {'form': form}
return render(request,'accounts/editprofile.html',args)
return render(request,'accounts/editprofile.html', args)

def change_password(request):
if request.method == 'POST':
form = PasswordChangeForm(data=request.POST,user=request.user)
if form.is_valid():
form.save()
update_session_auth_hash(request,form.user)
return redirect('http://localhost:8000/accounts/profile')
return redirect('accounts/profile')
else:
return redirect('http://localhost:8000/accounts/change-password/')
return redirect('accounts/change-password')
else:
form = PasswordChangeForm(user=request.user)
args = {'form': form}
Expand Down
Binary file modified db.sqlite3
Binary file not shown.

0 comments on commit 83de1d1

Please sign in to comment.