Skip to content

Update Homepage to Link to Sponsorship Form #67 #68

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Binary file modified .gitignore
Binary file not shown.
9 changes: 6 additions & 3 deletions portal/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.1/ref/settings/
"""
from dotenv import load_dotenv
load_dotenv()


import os
from pathlib import Path
Expand All @@ -28,9 +31,7 @@
# 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(",")
ALLOWED_HOSTS = ['localhost', '127.0.0.1']

# Application definition

Expand All @@ -46,6 +47,7 @@
"allauth",
"allauth.account",
"portal",
'sponsorship',
"volunteer",
"portal_account",
]
Expand Down Expand Up @@ -104,6 +106,7 @@
"PORT": os.environ.get("SQL_PORT", "5432"),
}
}



# Password validation
Expand Down
2 changes: 2 additions & 0 deletions portal/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@
path("admin/", admin.site.urls),
path("accounts/", include("allauth.urls")),
path("portal_account/", include("portal_account.urls", namespace="portal_account")),
path("sponsorship/", include("sponsorship.urls", namespace="sponsorship")),

]
3 changes: 3 additions & 0 deletions portal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ def index(request):
):
return redirect("portal_account:portal_profile_new")
return render(request, "portal/index.html", context)

def sponsorship_success(request):
return render(request, "sponsorship/success.html")
Binary file added sponsor_logos/profile_pic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sponsor_logos/profile_pic_7PndQTg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sponsor_logos/profile_pic_bgoVC7M.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sponsor_logos/profile_pic_cgKn54c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added sponsorship/__init__.py
Empty file.
15 changes: 15 additions & 0 deletions sponsorship/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.contrib import admin
from .models import SponsorshipProfile, SponsorshipTier

# Register your models here.
@admin.register(SponsorshipTier)
class SponsorshipTierAdmin(admin.ModelAdmin):
list_display = ('name', 'amount')
search_fields = ('name',)
ordering = ('amount',)

@admin.register(SponsorshipProfile)
class SponsorshipProfileAdmin(admin.ModelAdmin):
list_display = ('sponsor_organization_name', 'main_contact','sponsorship_type', 'application_status')
list_filter = ('sponsorship_type', 'application_status', 'sponsorship_tier')
search_fields = ('sponsor_organization_name', 'main_contact__username')
6 changes: 6 additions & 0 deletions sponsorship/apps.py
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'
20 changes: 20 additions & 0 deletions sponsorship/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django import forms
from .models import SponsorshipProfile

class SponsorshipProfileForm(forms.ModelForm):
class Meta:
model = SponsorshipProfile
fields = [
'main_contact',
'additional_contacts',
'sponsor_organization_name',
'sponsorship_type',
'sponsorship_tier',
'logo',
'company_description',
'application_status',
]
widgets = {
'additional_contacts': forms.CheckboxSelectMultiple(attrs={'class': 'form-control'}),
'company_description': forms.Textarea(attrs={'rows': 4,}),
}
41 changes: 41 additions & 0 deletions sponsorship/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated by Django 5.1.7 on 2025-03-29 05:58

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='SponsorshipTier',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('amount', models.DecimalField(decimal_places=2, max_digits=10)),
('name', models.CharField(max_length=100)),
('description', models.TextField()),
],
),
migrations.CreateModel(
name='SponsorshipProfile',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sponsor_organization_name', models.CharField(max_length=255)),
('sponsorship_type', models.CharField(choices=[('individual', 'Individual'), ('organization', 'Organization/Company')], max_length=20)),
('logo', models.ImageField(upload_to='sponsor_logos/')),
('company_description', models.TextField()),
('application_status', models.CharField(choices=[('pending', 'Pending'), ('approved', 'Approved'), ('rejected', 'Rejected'), ('cancelled', 'Cancelled')], default='pending', max_length=20)),
('additional_contacts', models.ManyToManyField(blank=True, related_name='additional_sponsorship_contacts', to=settings.AUTH_USER_MODEL)),
('main_contact', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='main_contact_for', to=settings.AUTH_USER_MODEL)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='sponsorship_profile', to=settings.AUTH_USER_MODEL)),
('sponsorship_tier', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='sponsorship.sponsorshiptier')),
],
),
]
Empty file.
45 changes: 45 additions & 0 deletions sponsorship/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from django.db import models
from django.contrib.auth.models import User

class SponsorshipTier(models.Model):
amount = models.DecimalField(max_digits=10, decimal_places=2)
name = models.CharField(max_length=100)
description = models.TextField()

def __str__(self):
return self.name


class SponsorshipProfile(models.Model):
INDIVIDUAL = 'individual'
ORGANIZATION = 'organization'

SPONSORSHIP_TYPE_CHOICES = [
(INDIVIDUAL, 'Individual'),
(ORGANIZATION, 'Organization/Company'),
]

APPLICATION_PENDING = 'pending'
APPLICATION_APPROVED = 'approved'
APPLICATION_REJECTED = 'rejected'
APPLICATION_CANCELLED = 'cancelled'

APPLICATION_STATUS_CHOICES = [
(APPLICATION_PENDING, 'Pending'),
(APPLICATION_APPROVED, 'Approved'),
(APPLICATION_REJECTED, 'Rejected'),
(APPLICATION_CANCELLED, 'Cancelled'),
]

user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='sponsorship_profile')
main_contact = models.OneToOneField(User, on_delete=models.CASCADE, related_name='main_contact_for')
additional_contacts = models.ManyToManyField(User, blank=True, related_name='additional_sponsorship_contacts')
sponsor_organization_name = models.CharField(max_length=255)
sponsorship_type = models.CharField(max_length=20, choices=SPONSORSHIP_TYPE_CHOICES)
sponsorship_tier = models.ForeignKey(SponsorshipTier, on_delete=models.SET_NULL, null=True)
logo = models.ImageField(upload_to='sponsor_logos/')
company_description = models.TextField()
application_status = models.CharField(max_length=20, choices=APPLICATION_STATUS_CHOICES, default=APPLICATION_PENDING)

def __str__(self):
return self.sponsor_organization_name
29 changes: 29 additions & 0 deletions sponsorship/templates/sponsorship/profile_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% extends "portal/base.html" %}
{% load static %}

{% block content %}
<div class="container mt-5">
<h2>Create Sponsorship Profile</h2>

{% if form.errors %}
<div class="alert alert-danger">
<ul>
{% for field in form %}
{% for error in field.errors %}
<li><strong>{{ field.label }}:</strong> {{ error }}</li>
{% endfor %}
{% endfor %}
{% for error in form.non_field_errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
</div>
{% endif %}

<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
{% endblock %}
9 changes: 9 additions & 0 deletions sponsorship/templates/sponsorship/success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends "portal/base.html" %}

{% block content %}
<div class="container mt-5">
<h2>🎉 Thank you for your sponsorship submission!</h2>
<p>Your sponsorship profile has been submitted successfully. We will review it and get back to you soon.</p>
<a class="btn btn-primary mt-3" href="/">Return to Home</a>
</div>
{% endblock %}
3 changes: 3 additions & 0 deletions sponsorship/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
11 changes: 11 additions & 0 deletions sponsorship/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from . import views
from django.urls import path, include


app_name = 'sponsorship'

urlpatterns = [
path('profile/new/', views.create_sponsorship_profile, name='create'),
path('profile/success/', views.sponsorship_success, name='success'),

]
26 changes: 26 additions & 0 deletions sponsorship/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from django.shortcuts import render, redirect
from .forms import SponsorshipProfileForm
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse

# Create your views here.

@login_required
def create_sponsorship_profile(request):
if request.method == 'POST':
form = SponsorshipProfileForm(request.POST, request.FILES)
if form.is_valid():
sponsorship_profile = form.save(commit=False)
sponsorship_profile.user = request.user # Assuming the user is logged in
sponsorship_profile.save()
form.save_m2m() # Save many-to-many relationships
return redirect('sponsorship:success') # Redirect to a success page or profile page
else:
form = SponsorshipProfileForm()
return render(request, 'portal/sponsorship/create_sponsorship_profile.html', {'form': form})

def success(request):
return HttpResponse("Sponsorship profile created successfully!")

def sponsorship_success(request):
return render(request, "sponsorship/success.html")
10 changes: 5 additions & 5 deletions templates/portal/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ <h3 class="fs-2 text-body-emphasis">Volunteer</h3>
<i class="fa-solid fa-hand-holding-dollar"></i>
</div>
<h3 class="fs-2 text-body-emphasis">Sponsor Us</h3>
<p>Sponsorship package is coming soon!</p>
{# <a href="#" class="icon-link">#}
{# Call to action#}
{# <svg class="bi"><use xlink:href="#chevron-right"></use></svg>#}
{# </a>#}
<p>Want to become a sponsor? Fill out your sponsorship profile and we'll follow up with details!</p>
<a href="{% url 'sponsorship:create' %}" class="icon-link">
Become a sponsor!
<i class="fa-solid fa-chevron-right"></i>
</a>
</div>
<div class="feature col">
<div class="d-inline-flex align-items-center justify-content-center fa-3x mb-3">
Expand Down
13 changes: 13 additions & 0 deletions templates/portal/sponsorship/create_sponsorship_profile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "portal/base.html" %}
{% load static %}

{% block content %}
<div class="container mt-5">
<h2>Create Sponsorship Profile</h2>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
{% endblock %}
Loading