Skip to content

Commit

Permalink
Merge pull request #192 from MithishR/mithish-eventapproval
Browse files Browse the repository at this point in the history
Created an admin page
  • Loading branch information
ojusharma authored Apr 6, 2024
2 parents 8745b58 + f0c4a05 commit 24b7b94
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/running_tests_py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
- name: Run Tests
run: |
cd ./Django/communicado
docker exec communicado_container_test python manage.py test
docker exec communicado_container_test python manage.py test --noinput
8 changes: 8 additions & 0 deletions Django/communicado/pages/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ class Events(models.Model):
category = models.CharField(max_length=50, null=True, blank=True)
artist = models.CharField(max_length=100, null=True, blank=True)
isVerified = models.BooleanField(default=False)
#isVerified=models.IntegerField(default=0)
# IS_VERIFIED_CHOICES = (
# (0, 'Not Checked'),
# (1, 'Approved'),
# (-1, 'Rejected'),
# )
# isVerified = models.IntegerField(choices=IS_VERIFIED_CHOICES, default=0)

adminID = models.ForeignKey(Admin, on_delete=models.CASCADE, null=True, blank=True,db_column= "adminID")
eventOrganizerID = models.ForeignKey(EventOrganizer, on_delete=models.CASCADE, null=True, blank=True,db_column="eventOrganizerID")
imageURL = models.CharField(max_length=100, null=True, blank=True)
Expand Down
113 changes: 113 additions & 0 deletions Django/communicado/pages/templates/pages/admin_actions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Organizer Account</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #0c0808;
margin: 0;
padding: 0;
display: flex;
justify-content: center; /* Center horizontally */
align-items: center; /* Center vertically */
height: 100vh; /* Make body fill entire viewport height */
}

.container {
background-color: #0e0101;
border: 2px solid #fff;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
padding: 20px;
width: 300px;
display: flex;
flex-direction: column; /* Stack items vertically */
align-items: center; /* Center items horizontally */
}

input[type="submit"] {
width: 100%;
background-color: transparent;
color: #fff;
padding: 14px 20px;
margin: 8px 0;
border: 2px solid #fff;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s, border-color 0.3s, color 0.3s;
font-size: 16px;
}

input[type="submit"]:hover {
background-color: #fff;
border-color: #fff;
color: #000;
}

h2 {
color: #fff;
text-align: center;
margin-bottom: 20px;
font-size: 24px;
}

input[type="submit"]:focus {
background-color: #fff;
border-color: #0e0101;
color: #000;
}

header {
background-color: rgba(0, 0, 0, 0.7);
color: #fff;
padding: 10px;
text-align: right;
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 1000;
}

header a {
color: #fff;
margin: 0 10px;
text-decoration: none;
}

header a:hover {
text-decoration: underline;
}
</style>
</head>
<body>

<header>
<p style="position: absolute; top: 0; left: 50%; transform: translateX(-50%); color: white;">Logged in as {{ request.session.user_id }}</p>
<a href="login">Login</a>
<a href="signup">Signup</a>
<a href="#">View Cart</a>
<a href="admin">Admin Panel</a>
</header>

<div class="container">
<h2>Administrator Portal</h2>

<form action="{% url 'pending' %}" method="get">
<input type="submit" value="View events pending approval">
</form>

<form action="{% url 'rejected' %}" method="get">
<input type="submit" value="View rejected events">
</form>

<form action="{% url 'events' %}" method="get">
<input type="submit" value="View all Events">
</form>

</div>
</body>
</html>
9 changes: 9 additions & 0 deletions Django/communicado/pages/templates/pages/pending.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>Pending Events</title>
</head>
<body>
<h1>Pending Events</h1>
</body>
</html>
9 changes: 9 additions & 0 deletions Django/communicado/pages/templates/pages/rejected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Rejected</h1>
</body>
</html>
2 changes: 1 addition & 1 deletion Django/communicado/pages/templates/pages/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ <h1>Signup</h1>
<p><label for="name">Name:</label><input type="text" id="name" name="name" required></p>
<p><label for="email">Email:</label><input type="email" id="email" name="email" required></p>
<p><label for="address">Address:</label><input type="text" id="address" name="address" required></p>
<p><label for="phoneNumber">Phone Number (Event organizer only):</label><input type="text" id="phoneNumber" name="phoneNumber" required></p>
<p><label for="phoneNumber">Phone Number (Event organizer only):</label><input type="text" id="phoneNumber" name="phoneNumber"></p>
<p><label for="role">Role:</label><select id="role" name="role"><option value="customer">Customer</option><option value="EventOrganizer">Event Organizer</option></select></p>
<p><input type="submit" value="Sign Up"></p>
</form>
Expand Down
3 changes: 3 additions & 0 deletions Django/communicado/pages/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
path('userbookinfo',views.userbookeventinfo , name = 'userbookeventinfo'),
path('add_to_cart/<int:event_ID>/', views.add_to_cart, name='add_to_cart'),
path('payment', views.payment, name='payment'),
path('admin_actions', views.admin_actions, name='admin_actions'),
path('pending', views.pending, name='pending'),
path('rejected', views.rejected, name='rejected'),


]
19 changes: 18 additions & 1 deletion Django/communicado/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from unicodedata import numeric
from django.shortcuts import render,redirect,get_object_or_404
from django.contrib.auth.hashers import make_password,check_password
from .models import users, EventOrganizer, Events
from .models import *
from django.contrib import messages
from django.shortcuts import render, redirect, get_object_or_404
from .models import Events , BookedEvent
Expand Down Expand Up @@ -30,6 +30,8 @@ def login(request):
success_message = "Welcome " + user.name + ", userid:"+ str(user.userID) # Accessing name from the user object
messages.success(request, success_message)
return redirect('organizer_actions')
elif user.role == 'Admin':
return redirect('admin_actions')

else:
success_message = "Welcome " + user.name + ", userid:"+ str(user.userID) # Accessing name from the user object
Expand Down Expand Up @@ -60,6 +62,7 @@ def signup(request):
if role.__eq__('EventOrganizer'):
event_organizer = EventOrganizer(user=user, phoneNumber=phoneNumber)
event_organizer.save()

success_message = "User Account Created for: " + user.name
return render(request, 'pages/login.html', {'success_message': success_message})

Expand Down Expand Up @@ -292,4 +295,18 @@ def payment(request):

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

def admin_actions(request):
userData = users.objects.all()
context = {"userData": userData, }
return render (request,"pages/admin_actions.html",context)

def pending(request):
userData = users.objects.all()
context = {"userData": userData, }
return render (request,"pages/pending.html",context)

def rejected(request):
userData = users.objects.all()
context = {"rejected": userData, }
return render (request,"pages/rejected.html",context)

0 comments on commit 24b7b94

Please sign in to comment.