From 4fb83ac4ab9cbb75f09dedab89570b0e3d6659b2 Mon Sep 17 00:00:00 2001 From: MithishR Date: Sat, 6 Apr 2024 14:08:28 -0700 Subject: [PATCH 1/2] Created an admin page --- Django/communicado/pages/models.py | 8 ++ .../pages/templates/pages/admin_actions.html | 113 ++++++++++++++++++ .../pages/templates/pages/pending.html | 9 ++ .../pages/templates/pages/rejected.html | 9 ++ .../pages/templates/pages/signup.html | 2 +- Django/communicado/pages/urls.py | 3 + Django/communicado/pages/views.py | 19 ++- 7 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 Django/communicado/pages/templates/pages/admin_actions.html create mode 100644 Django/communicado/pages/templates/pages/pending.html create mode 100644 Django/communicado/pages/templates/pages/rejected.html diff --git a/Django/communicado/pages/models.py b/Django/communicado/pages/models.py index 1f2ea114..b7bc0e91 100644 --- a/Django/communicado/pages/models.py +++ b/Django/communicado/pages/models.py @@ -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) diff --git a/Django/communicado/pages/templates/pages/admin_actions.html b/Django/communicado/pages/templates/pages/admin_actions.html new file mode 100644 index 00000000..4552a2c0 --- /dev/null +++ b/Django/communicado/pages/templates/pages/admin_actions.html @@ -0,0 +1,113 @@ + + + + + + Organizer Account + + + + +
+

Logged in as {{ request.session.user_id }}

+ Login + Signup + View Cart + Admin Panel +
+ +
+

Administrator Portal

+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + diff --git a/Django/communicado/pages/templates/pages/pending.html b/Django/communicado/pages/templates/pages/pending.html new file mode 100644 index 00000000..f1ef3b76 --- /dev/null +++ b/Django/communicado/pages/templates/pages/pending.html @@ -0,0 +1,9 @@ + + + + Pending Events + + +

Pending Events

+ + \ No newline at end of file diff --git a/Django/communicado/pages/templates/pages/rejected.html b/Django/communicado/pages/templates/pages/rejected.html new file mode 100644 index 00000000..f716c6af --- /dev/null +++ b/Django/communicado/pages/templates/pages/rejected.html @@ -0,0 +1,9 @@ + + + + Page Title + + +

Rejected

+ + \ No newline at end of file diff --git a/Django/communicado/pages/templates/pages/signup.html b/Django/communicado/pages/templates/pages/signup.html index e7863454..1a8148e1 100644 --- a/Django/communicado/pages/templates/pages/signup.html +++ b/Django/communicado/pages/templates/pages/signup.html @@ -153,7 +153,7 @@

Signup

-

+

diff --git a/Django/communicado/pages/urls.py b/Django/communicado/pages/urls.py index 86b4fcfd..671d6a05 100644 --- a/Django/communicado/pages/urls.py +++ b/Django/communicado/pages/urls.py @@ -16,6 +16,9 @@ path('userbookinfo',views.userbookeventinfo , name = 'userbookeventinfo'), path('add_to_cart//', 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'), ] diff --git a/Django/communicado/pages/views.py b/Django/communicado/pages/views.py index bf9a6b03..8b14440c 100644 --- a/Django/communicado/pages/views.py +++ b/Django/communicado/pages/views.py @@ -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 @@ -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 @@ -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}) @@ -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) + \ No newline at end of file From f0c4a05db61b08d017b43a17ed6cdbec022936ea Mon Sep 17 00:00:00 2001 From: Ojus Sharma <112976298+ojusharma@users.noreply.github.com> Date: Sat, 6 Apr 2024 14:19:22 -0700 Subject: [PATCH 2/2] Fixed "EOF" Error in Testing - Testing workflow was throwing an error for database deletion - Added noinput to sidestep this error --- .github/workflows/running_tests_py.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/running_tests_py.yml b/.github/workflows/running_tests_py.yml index b4b57dde..67ea451b 100644 --- a/.github/workflows/running_tests_py.yml +++ b/.github/workflows/running_tests_py.yml @@ -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