Skip to content

Commit

Permalink
Merge pull request #230 from MithishR/sparsh(usereditacc)
Browse files Browse the repository at this point in the history
Edit Account Personal Details
  • Loading branch information
mahigangal authored Apr 12, 2024
2 parents d0b0d1e + 1040513 commit 0624fd7
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 4 deletions.
74 changes: 74 additions & 0 deletions Django/communicado/pages/templates/pages/edit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en">
{% load static %}
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Account Confirmation</title>
<style>
body {
font-family: 'Montserrat', sans-serif;
background-color: #0c0808;
background-image: url('{% static "bg1.jpg" %}');
background-size: cover;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center; /* Center horizontally */
justify-content: flex-start; /* Align content to the top */
height: 100vh;
color: white;
}

.content {
text-align: center;
margin-top: 50px;
}

.image-container {
margin-top: 30px;
}

img {
width: 500px;
height: auto;
}
</style>

</head>
{% include './header.html' %}
<body>
<div class="content" >
<h1>Account Edit Confirmation</h1>
<p>You have successfully edited your account .</p>
<p>Redirecting to User account Page <span id="countdown">5</span> seconds...</p>
</div>



<script>
function countdownRedirect()
{
var countdown = 5;
var countdownDisplay = document.getElementById('countdown');

var countdownInterval = setInterval(function()
{
countdownDisplay.textContent = countdown;
countdown--;
if (countdown < 0)
{
clearInterval(countdownInterval);
window.location.href = "useracc";
}
}, 1000);
}

window.onload = function()
{
countdownRedirect();
};
</script>
</body>
</html>
106 changes: 106 additions & 0 deletions Django/communicado/pages/templates/pages/editacc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit User Account</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #0f0101;
color: #fff; /* Set text color to white */
}

.center {
max-width: 800px;
margin: 20px auto;
padding: 20px;
background-color: #080000;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
border: 2px solid #000;
text-align: center;
}

h1 {
text-align: center;
margin-bottom: 20px;
font-size: 24px;
}

form {
text-align: left;
max-width: 400px;
margin: 0 auto;
}

label {
display: block;
margin-bottom: 10px;
}

textarea {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
}

.btn-container {
text-align: center;
}

.btn {
display: inline-block;
padding: 10px 20px;
font-size: 18px;
background-color: transparent;
color: #fff;
text-decoration: none;
border: 2px solid #f4f5f7;
border-radius: 5px;
margin-top: 20px;
transition: background-color 0.3s, border-color 0.3s, color 0.3s;
text-align: center;
}

.btn:hover {
background-color: #fff;
border-color: #fff;
color: #000;
}
</style>
</head>
<body>
{% include './header.html' %}
<div class="center">
<h1>Edit Your Account Details</h1>
<form action="{% url 'edit' %}" method="POST">
{% csrf_token %}
<label for="role">Role:</label>
<input type="text" id="role" name="role" value="{{ user.role }}" readonly>


<label for="username">Username:</label>
<input type="text" id="username" name="username" value="{{ user.username }}" readonly>
<label for="name">Name:</label>
<input type="text" id="name" name="name" value="{{ user.name }}" >

<label for="email">Email:</label>
<input type="email" id="email" name="email" value="{{ user.email }}">

<label for="address">Address:</label>
<textarea id="address" name="address">{{ user.address }}</textarea>

<div class="btn-container">
<input type="submit" class="btn" value="Save">
<a href="useracc" class="btn">Back</a>
</div>
</form>
</div>
</body>
</html>
2 changes: 1 addition & 1 deletion Django/communicado/pages/templates/pages/useraccount.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h1>Your Account Information</h1>
<li><strong>Address:</strong> {{ user.address }}</li>
</ul>
</div>
<a href="#" class="btn">Edit Account Details</a>
<a href="editacc" class="btn">Edit Account Details</a>
<a href="userbookinfo" class="btn">Booking History</a>
{% endif %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion Django/communicado/pages/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def test_user_account_page(self):
self.assertContains(response, '<strong>Username:</strong> {}'.format(user.username))
self.assertContains(response, '<strong>Email:</strong> {}'.format(user.email))
self.assertContains(response, '<strong>Address:</strong> {}'.format(user.address))
self.assertContains(response, '<a href="#" class="btn">Edit Account Details</a>')
self.assertContains(response, '<a href="editacc" class="btn">Edit Account Details</a>')
self.assertContains(response, '<a href="userbookinfo" class="btn">Booking History</a>')
self.assertContains(response, '<li><strong>Role:</strong> Admin</li>', html=True)
self.assertContains(response, '<li><strong>Username:</strong> testuser</li>', html=True)
Expand Down
3 changes: 2 additions & 1 deletion Django/communicado/pages/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
path('logout/', views.logout, name='logout'),
path('delete/<int:event_ID>/', views.delete, name='delete'),
path('remove',views.remove, name='remove'),

path('editacc',views.editacc, name = 'editacc'),
path('edit',views.edit,name = 'edit')



Expand Down
20 changes: 19 additions & 1 deletion Django/communicado/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,22 @@ def delete(request, event_ID):

def remove(request):
remove = Events.objects.filter(isVerified=1)
return render(request, 'pages/remove.html', {'remove': remove})
return render(request, 'pages/remove.html', {'remove': remove})
def editacc(request):
user_id = request.session.get('userID')
user = users.objects.get(userID=user_id)
return render(request , 'pages/editacc.html',{'user':user})
def edit(request):
user_id = request.session.get('userID')
user = get_object_or_404(users, userID = user_id)


if request.method == 'POST':
user.name = request.POST.get('name')
user.username = request.POST.get('username')
user.email = request.POST.get('email')
user.address = request.POST.get('address')
user.save()


return render (request,'pages/edit.html')

0 comments on commit 0624fd7

Please sign in to comment.