-
-
Notifications
You must be signed in to change notification settings - Fork 43
Create variousteams dashboard #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d29cf5a
937ac7d
eefe5ff
02e7173
5328395
e0bd24a
23b72a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ env | |
.coverage | ||
.state | ||
staticroot | ||
__pycache__/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.contrib import admin | ||
from .models import SponsorshipApplication, VolunteerTask, StaffTask | ||
|
||
# Register your models here. | ||
admin.site.register(SponsorshipApplication) | ||
admin.site.register(VolunteerTask) | ||
admin.site.register(StaffTask) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class DashboardConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'dashboard' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generated by Django 5.1.7 on 2025-04-03 15:14 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='SponsorshipApplication', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('company_name', models.CharField(max_length=255)), | ||
('status', models.CharField(choices=[('Pending', 'Pending'), ('Approved', 'Approved'), ('Rejected', 'Rejected')], default='Pending', max_length=10)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='StaffTask', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('title', models.CharField(max_length=255)), | ||
('status', models.CharField(choices=[('Pending', 'Pending'), ('Completed', 'Completed')], default='Pending', max_length=10)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='VolunteerTask', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('title', models.CharField(max_length=255)), | ||
('status', models.CharField(choices=[('Pending', 'Pending'), ('Completed', 'Completed')], default='Pending', max_length=10)), | ||
], | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django.db import models | ||
|
||
#code models for various dashboard implementations | ||
|
||
class SponsorshipApplication(models.Model): | ||
STATUS_CHOICES = [("Pending", "Pending"), ("Approved", "Approved"), ("Rejected", "Rejected")] | ||
company_name = models.CharField(max_length=255) | ||
status = models.CharField(max_length=10, choices=STATUS_CHOICES, default="Pending") | ||
|
||
class VolunteerTask(models.Model): | ||
STATUS_CHOICES = [("Pending", "Pending"), ("Completed", "Completed")] | ||
title = models.CharField(max_length=255) | ||
status = models.CharField(max_length=10, choices=STATUS_CHOICES, default="Pending") | ||
|
||
class StaffTask(models.Model): | ||
STATUS_CHOICES = [("Pending", "Pending"), ("Completed", "Completed")] | ||
title = models.CharField(max_length=255) | ||
status = models.CharField(max_length=10, choices=STATUS_CHOICES, default="Pending") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.urls import path | ||
from .views import staffteam_dashboard, sponsorship_dashboard, volunteer_dashboard | ||
|
||
|
||
app_name = "dashboard" | ||
|
||
urlpatterns = [ | ||
path("dashboard/", staffteam_dashboard, name="team_dashboard"), | ||
path("dashboard/sponsorship/", sponsorship_dashboard, name="sponsorship_dashboard"), | ||
path("dashboard/volunteer/", volunteer_dashboard, name="volunteer_dashboard"), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from django.shortcuts import render, redirect | ||
from django.contrib.auth.decorators import login_required | ||
from django.contrib.auth.models import Group | ||
from .models import SponsorshipApplication, VolunteerTask | ||
|
||
#views functionality | ||
#sample code for functionalities of various dashboards for various teams | ||
@login_required | ||
def staffteam_dashboard(request): | ||
""" Redirect users to their respective team dashboards based on group membership. """ | ||
if request.user.groups.filter(name="Sponsorship Team").exists(): | ||
return redirect("sponsorship_dashboard") | ||
elif request.user.groups.filter(name="Volunteer Team").exists(): | ||
return redirect("volunteer_dashboard") | ||
elif request.user.groups.filter(name="Staff Team").exists(): | ||
return redirect("staff_dashboard") | ||
else: | ||
return render(request, "dashboard/no_access.html") | ||
|
||
@login_required | ||
def sponsorship_dashboard(request): | ||
""" Dashboard for Sponsorship Team. """ | ||
if not request.user.groups.filter(name="Sponsorship Team").exists(): | ||
return render(request, "dashboard/no_access.html") | ||
|
||
total_applications = SponsorshipApplication.objects.count() | ||
approved = SponsorshipApplication.objects.filter(status="Approved").count() | ||
pending = SponsorshipApplication.objects.filter(status="Pending").count() | ||
rejected = SponsorshipApplication.objects.filter(status="Rejected").count() | ||
|
||
context = { | ||
"total_applications": total_applications, | ||
"approved": approved, | ||
"pending": pending, | ||
"rejected": rejected, | ||
} | ||
return render(request, "dashboard/sponsorship_dashboard.html", context) | ||
|
||
@login_required | ||
def volunteer_dashboard(request): | ||
""" Dashboard for Volunteer Management Team. """ | ||
if not request.user.groups.filter(name="Volunteer Team").exists(): | ||
return render(request, "dashboard/no_access.html") | ||
|
||
total_tasks = VolunteerTask.objects.count() | ||
completed_tasks = VolunteerTask.objects.filter(status="Completed").count() | ||
pending_tasks = VolunteerTask.objects.filter(status="Pending").count() | ||
|
||
context = { | ||
"total_tasks": total_tasks, | ||
"completed_tasks": completed_tasks, | ||
"pending_tasks": pending_tasks, | ||
} | ||
return render(request, "dashboard/volunteer_dashboard.html", context) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,20 @@ | |
""" | ||
|
||
import os | ||
import environ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You might have missed adding the dependency for |
||
|
||
env = environ.Env() | ||
environ.Env.read_env() | ||
|
||
ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=["localhost"]) | ||
from pathlib import Path | ||
|
||
import dj_database_url | ||
|
||
# Build paths inside the project like this: BASE_DIR / 'subdir'. | ||
BASE_DIR = Path(__file__).resolve().parent.parent | ||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
|
||
|
||
|
||
|
||
# Quick-start development settings - unsuitable for production | ||
|
@@ -28,9 +36,8 @@ | |
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = bool(os.environ.get("DEBUG", default=0)) | ||
|
||
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS") | ||
if ALLOWED_HOSTS: | ||
ALLOWED_HOSTS = ALLOWED_HOSTS.split(",") | ||
# Ensure ALLOWED_HOSTS is a list | ||
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", "").split(",") | ||
|
||
# Application definition | ||
|
||
|
@@ -48,6 +55,8 @@ | |
"portal", | ||
"volunteer", | ||
"portal_account", | ||
"sponsorship", | ||
"dashboard", | ||
] | ||
|
||
MIDDLEWARE = [ | ||
|
@@ -140,8 +149,10 @@ | |
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/5.1/howto/static-files/ | ||
|
||
STATIC_URL = "static/" | ||
STATIC_ROOT = BASE_DIR / "staticroot" | ||
STATIC_URL = "/static/" | ||
STATIC_ROOT = os.path.join(BASE_DIR, "staticroot") | ||
if not os.path.exists(STATIC_ROOT): | ||
os.makedirs(STATIC_ROOT) | ||
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" | ||
|
||
# Default primary key field type | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class SponsorshipConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'sponsorship' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#model schema creation for more functionality addition to sponsorship portal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see a new model here but no migrations for Steps to add it
after that
and commit the migrations file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alright sir, i'll rectify this as well and get back to you There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hello @Mr-Sunglasses i have removed the pycache/ folder , and made the migrations and migrated for the sponsorship application models and also done the commit as well pls review thank you |
||
from django.db import models | ||
|
||
class SponsorshipApplication(models.Model): | ||
STATUS_CHOICES = [ | ||
("Pending", "Pending"), | ||
("Approved", "Approved"), | ||
("Rejected", "Rejected"), | ||
] | ||
company_name = models.CharField(max_length=255) | ||
email = models.EmailField() | ||
tier = models.CharField(max_length=100) | ||
status = models.CharField(max_length=10, choices=STATUS_CHOICES, default="Pending") | ||
contract_sent = models.BooleanField(default=False) | ||
payment_received = models.BooleanField(default=False) | ||
|
||
def __str__(self): | ||
return f"{self.company_name} - {self.status}" | ||
|
||
class SponsorshipAsset(models.Model): | ||
sponsorship_application = models.ForeignKey(SponsorshipApplication, on_delete=models.CASCADE) | ||
asset_file = models.FileField(upload_to="sponsorship_assets/") | ||
uploaded_at = models.DateTimeField(auto_now_add=True) | ||
|
||
def __str__(self): | ||
return f"Asset for {self.sponsorship_application.company_name}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Content seems to be missing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a new model here but no migrations file for
SponsorshipApplication
,VolunteerTask
,StaffTask
. Please Add it.Steps to add it
after that
and commit the migrations file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright sir , i was actually planning to do all that already as well, i just gave some samples code for you to see.
I'll correct that right away sir and get back to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hello @Mr-Sunglasses made the migrations and migrated for the 3 models and also done the commit as well pls review thank you very much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mr-Sunglasses i saw that you requested a change , please what do you mean, i dont really understand, do you want an access to the files uploaded here