Skip to content

Commit e5f6a3d

Browse files
committed
feature/aahq-29-events-registration-flow
1 parent d3908c4 commit e5f6a3d

13 files changed

+374
-294
lines changed

src/haps/admin.py

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class EventAdmin(admin.ModelAdmin):
2323
"end_time",
2424
"accept_reg",
2525
"show_on_home",
26+
"content",
2627
]
2728

2829

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 4.2.1 on 2023-12-30 14:50
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("haps", "0002_alter_event_slug"),
9+
]
10+
11+
operations = [
12+
migrations.AddField(
13+
model_name="eventregistration",
14+
name="datetime",
15+
field=models.DateTimeField(auto_now_add=True, null=True),
16+
),
17+
]
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Generated by Django 4.2.1 on 2024-01-01 13:52
2+
3+
import ckeditor_uploader.fields
4+
from django.db import migrations
5+
6+
7+
class Migration(migrations.Migration):
8+
dependencies = [
9+
("haps", "0003_eventregistration_datetime"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="event",
15+
name="content",
16+
field=ckeditor_uploader.fields.RichTextUploadingField(
17+
blank=True, null=True
18+
),
19+
),
20+
]

src/haps/models.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from django.utils.html import format_html
44
from utils.images import upload_image_to
55
from utils.slugs import generate_unique_slug
6+
from ckeditor_uploader.fields import RichTextUploadingField
67

78
User = get_user_model()
89

@@ -17,9 +18,10 @@ class Event(models.Model):
1718
end_time = models.DateField(null=True, blank=True)
1819
accept_reg = models.BooleanField(verbose_name="Accepting registrations ?")
1920
show_on_home = models.BooleanField(verbose_name="Show on Home Page ?")
21+
content = RichTextUploadingField(null=True, blank=True)
2022

2123
def __str__(self):
22-
return self.name + str(self.start_time)
24+
return self.name + " (" + str(self.start_time) + ")"
2325

2426
def save(self, *args, **kwargs):
2527
if self.slug == "":
@@ -30,12 +32,16 @@ def get_absolute_url(self):
3032
return f"/events/{self.slug}"
3133

3234
def event_page(self):
33-
return format_html(f'<a href="{self.get_absolute_url()}" target="_blank">View Page</a>')
35+
return format_html(
36+
f'<a href="{self.get_absolute_url()}" target="_blank">View Page</a>'
37+
)
3438

3539

3640
class EventRegistration(models.Model):
3741
event = models.ForeignKey(Event, on_delete=models.CASCADE)
3842
user = models.ForeignKey(User, on_delete=models.CASCADE)
43+
datetime = models.DateTimeField(auto_now_add=True, null=True, blank=True)
44+
# regno = models.CharField(unique=True)
3945

4046
def __str__(self) -> str:
4147
return self.user.__str__() + "%" + self.event.__str__()

src/haps/templates/haps/item.html

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{% extends "commons.html" %}
2+
{% block title %} {{hap.name}} {% endblock title %}
3+
{%block content %}
4+
<link rel="stylesheet"
5+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
6+
7+
<section class="bg-white dark:bg-gray-900">
8+
<div class="max-w-3xl flex px-4 py-8 mx-auto justify-around flex-wrap">
9+
<div>
10+
<img class="my-4 h-auto md:max-w-2xl sm:max-w-xl rounded-lg shadow-xl dark:shadow-gray-800"
11+
src="{{hap.cover_image.url}}" alt="image description">
12+
</div>
13+
14+
<div class="my-4 place-self-center text-center">
15+
<h1
16+
class="my-2 max-w-2xl mb-4 text-4xl font-extrabold tracking-tight leading-none md:text-5xl xl:text-6xl dark:text-white">
17+
{{hap.name}}
18+
</h1>
19+
20+
21+
<p class="mt-4 max-w-2xl mb-2 font-light text-gray-500 lg:mb-8 md:text-lg lg:text-xl dark:text-gray-400">
22+
{{hap.description}}
23+
</p>
24+
25+
26+
<div class="md:text-lg lg:text-xl mb-8 text-gray-500 dark:text-gray-400 align-middle">
27+
28+
<div class="align-middle">
29+
<span class="material-symbols-outlined">
30+
event
31+
</span>
32+
<span> {{hap.start_time}}</span>
33+
</div>
34+
35+
<div class="align-middle">
36+
<span class="material-symbols-outlined">
37+
location_on
38+
</span>
39+
<span class="">
40+
{{hap.venue}}
41+
</span>
42+
</div>
43+
</div>
44+
45+
<a href="{{hap.slug}}/register"
46+
class="inline-flex items-center justify-center px-5 py-3 mr-3 text-base font-medium text-center text-white rounded-lg bg-primary-700 hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 dark:focus:ring-primary-900">
47+
Register Now
48+
<svg class="w-5 h-5 ml-2 -mr-1" fill="currentColor" viewBox="0 0 20 20"
49+
xmlns="http://www.w3.org/2000/svg">
50+
<path fill-rule="evenodd"
51+
d="M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z"
52+
clip-rule="evenodd">
53+
</path>
54+
</svg>
55+
</a>
56+
<a href="#"
57+
class="inline-flex items-center justify-center px-5 py-3 text-base font-medium text-center text-gray-900 border border-gray-300 rounded-lg hover:bg-gray-100 focus:ring-4 focus:ring-gray-100 dark:text-white dark:border-gray-700 dark:hover:bg-gray-700 dark:focus:ring-gray-800">
58+
Contact us
59+
</a>
60+
</div>
61+
62+
63+
64+
65+
66+
</div>
67+
68+
<div class="px-4 py-8 w-full flex justify-center">
69+
<div class="format format-lg w-full">
70+
{{hap.content | safe}}
71+
</div>
72+
</div>
73+
74+
75+
76+
</section>
77+
78+
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{% extends "commons.html" %}
2+
3+
{% block title %} {{ event.name }} {% endblock title %}
4+
5+
6+
{% block content %}
7+
8+
<div class="bg-gray-100 h-screen">
9+
<div class="bg-white p-6 md:mx-auto">
10+
<svg viewBox="0 0 24 24" class="text-green-600 w-16 h-16 mx-auto my-6">
11+
<path fill="currentColor"
12+
d="M12,0A12,12,0,1,0,24,12,12.014,12.014,0,0,0,12,0Zm6.927,8.2-6.845,9.289a1.011,1.011,0,0,1-1.43.188L5.764,13.769a1,1,0,1,1,1.25-1.562l4.076,3.261,6.227-8.451A1,1,0,1,1,18.927,8.2Z">
13+
</path>
14+
</svg>
15+
<div class="text-center">
16+
<h3 class="md:text-2xl text-base text-gray-900 font-semibold text-center">Registration Done!</h3>
17+
<p class="text-gray-600 my-2">Thank you for completing your registration for event</p>
18+
<p> Looking forward to see you in the event! </p>
19+
20+
</div>
21+
22+
23+
<div class="flex justify-center my-4">
24+
<div class="max-w-2xl text-center">
25+
<table class="w-full text-lg text-left rtl:text-right text-gray-500 dark:text-gray-400">
26+
27+
<tbody>
28+
<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
29+
<th scope="row"
30+
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
31+
Event
32+
</th>
33+
<td class="px-6 py-4">
34+
{{event.name}}
35+
</td>
36+
37+
</tr>
38+
<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
39+
<th scope="row"
40+
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
41+
Name
42+
</th>
43+
<td class="px-6 py-4">
44+
{{user.first_name}} {{user.last_name}}
45+
</td>
46+
47+
</tr>
48+
<tr class="bg-white border-b dark:bg-gray-800">
49+
<th scope="row"
50+
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
51+
Email
52+
</th>
53+
<td class="px-6 py-4">
54+
{{user.email}}
55+
</td>
56+
57+
</tr>
58+
59+
<tr class="bg-white border-b dark:bg-gray-800">
60+
<th scope="row"
61+
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
62+
Date
63+
</th>
64+
<td class="px-6 py-4">
65+
{{event.start_time}}
66+
</td>
67+
68+
</tr>
69+
70+
<tr class="bg-white border-b dark:bg-gray-800">
71+
<th scope="row"
72+
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
73+
Venue
74+
</th>
75+
<td class="px-6 py-4">
76+
{{event.venue}}
77+
</td>
78+
79+
</tr>
80+
{# show registration date time #}
81+
</tbody>
82+
</table>
83+
</div>
84+
85+
86+
87+
</div>
88+
89+
<div class="my-4 flex justify-center">
90+
<a href="{{hap.slug}}">
91+
<button type="button"
92+
class="my-4 text-white bg-primary-700 hover:bg-primary-600 focus:ring-4 focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-primary-600 dark:hover:bg-primary-700 focus:outline-none dark:focus:ring-primary-800">
93+
Print PDF
94+
</button>
95+
</a>
96+
97+
</div>
98+
99+
100+
101+
</div>
102+
</div>
103+
104+
{% endblock content %}

src/haps/urls.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
urlpatterns = [
88
path("", views.haps_list, name="events"),
99
path("<slug>", views.haps_item, name="event_item"),
10+
path("<slug>/register", views.register_for_event, name="event_register"),
1011
]

src/haps/views.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from django.shortcuts import render
22
from django.http import HttpRequest, Http404
3-
from .models import Event
3+
from .models import Event, EventRegistration
4+
from django.contrib.auth.decorators import login_required
45
import logging
56

7+
68
log = logging.getLogger(__name__)
79

810

@@ -14,6 +16,17 @@ def haps_list(request: HttpRequest):
1416

1517
def haps_item(request: HttpRequest, slug: str):
1618
event = Event.objects.get(slug=slug)
17-
context = {"event": event}
19+
context = {"hap": event}
1820

1921
return render(request, "haps/item.html", context=context)
22+
23+
24+
@login_required(login_url="/users/login")
25+
def register_for_event(request: HttpRequest, slug: str):
26+
event = Event.objects.get(slug=slug)
27+
registration = EventRegistration.objects.get_or_create(
28+
event=event, user=request.user
29+
)
30+
31+
context = {"event": event, "user": request.user, "reg": registration}
32+
return render(request, "haps/register_success.html", context=context)

src/users/forms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class UserRegistrationForm(forms.Form):
4848
address = forms.CharField(max_length=1024)
4949
profession = forms.CharField(max_length=256)
5050
whatsapp_number = forms.CharField(max_length=15)
51-
email = forms.CharField(max_length=128)
51+
email = forms.EmailField(max_length=128)
5252

5353
def clean_password2(self):
5454
# Check that the two password entries match

0 commit comments

Comments
 (0)