Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.views.generic import TemplateView
from django.views.generic import RedirectView
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('', TemplateView.as_view(template_name='index.html'), name='index'),
path(
'',
RedirectView.as_view(url='/home/', permanent=False),
name='index'
),
path('map/', include('map.urls')),
path('home/', include('home.urls')),
]
Expand All @@ -32,4 +36,6 @@
path("__reload__/", include("django_browser_reload.urls")),
]
# media files serving in development
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
)
26 changes: 14 additions & 12 deletions home/templates/home/event_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,27 @@ <h1 class="text-2xl font-bold mb-2">{{ event.title }}</h1>
<p class="text-sm text-neutral-content mb-1">Date & Time</p>
<p class="font-medium">
<i class="fa-regular fa-calendar mr-1"></i>
{{ event.start_time|date:"D, d M Y" }} at {{
event.start_time|time:"g:i A" }} {% if
event.end_time|date:"D, d M Y" ==
event.start_time|date:"D, d M Y" %} - {{
event.end_time|time:"g:i A" }} {% else %} to {{
event.end_time|date:"D, d M Y" }} at {{
event.end_time|time:"g:i A" }} {% endif %}
{{ event.start_time|date:"D, d M Y" }} at {{ event.start_time|time:"g:i A" }}
{% if event.end_time|date:"D, d M Y" == event.start_time|date:"D, d M Y" %}
- {{ event.end_time|time:"g:i A" }}
{% else %}
to {{ event.end_time|date:"D, d M Y" }} at {{ event.end_time|time:"g:i A" }}
{% endif %}
</p>
</div>

<div>
<p class="text-sm text-neutral-content mb-1">Location</p>
<p class="font-medium">
<i class="fa-solid fa-location-dot mr-1"></i>
{% if event.church %} {{ event.church.name }} {% if
event.church.address %}<br />{{ event.church.address
}}{% endif %} {% if event.church.postcode %}, {{
event.church.postcode }}{% endif %} {% else %} {{
event.location }} {% endif %}
{% if event.church %}
{{ event.church.name }}
{% if event.church.address %}
<br><span class="text-sm">{{ event.church.address }}, {{ event.church.postcode }}</span>
{% endif %}
{% else %}
{{ event.location }}
{% endif %}
</p>
</div>
</div>
Expand Down
80 changes: 27 additions & 53 deletions home/templates/home/events.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<!-- filepath: /Users/guns4kids/Documents/vscode-projects/Deanery/home/templates/home/events.html -->
{% extends "base.html" %} {% load static %} {% block content %}
{% extends "base.html" %}
{% load static %}

{% block content %}
<div class="container mx-auto py-8 px-4">
<div class="flex justify-between items-center mb-6">
<h1 class="text-3xl font-bold">Church Events</h1>
Expand All @@ -19,39 +22,25 @@ <h2 class="text-2xl font-bold mb-4">Featured Events</h2>
<div class="card bg-base-100 shadow-xl">
{% if event.image %}
<figure class="h-48">
<img
src="{{ event.image.url }}"
alt="{{ event.title }}"
class="w-full h-full object-cover"
/>
<img src="{{ event.image.url }}" alt="{{ event.title }}" class="w-full h-full object-cover" />
</figure>
{% else %}
<figure
class="h-48 bg-base-200 flex items-center justify-center"
>
<i
class="fa-solid fa-calendar-days text-6xl text-base-300"
></i>
<figure class="h-48 bg-base-200 flex items-center justify-center">
<i class="fa-solid fa-calendar-days text-6xl text-base-300"></i>
</figure>
{% endif %}
<div class="card-body">
<h3 class="card-title">{{ event.title }}</h3>
<p class="text-sm">
<i class="fa-regular fa-calendar mr-1"></i>
{{ event.start_time|date:"D, d M Y" }} at {{
event.start_time|time:"g:i A" }}
{{ event.start_time|date:"D, d M Y" }} at {{ event.start_time|time:"g:i A" }}
</p>
<p class="text-sm">
<i class="fa-solid fa-location-dot mr-1"></i>
{% if event.church %}{{ event.church.name }}{% else %}{{
event.location }}{% endif %}
{% if event.church %}{{ event.church.name }}{% else %}{{ event.location }}{% endif %}
</p>
<div class="card-actions justify-end mt-4">
<a
href="{% url 'event_detail' event.pk %}"
class="btn btn-primary btn-sm"
>View Details</a
>
<a href="{% url 'event_detail' event.pk %}" class="btn btn-primary btn-sm">View Details</a>
</div>
</div>
</div>
Expand Down Expand Up @@ -80,53 +69,38 @@ <h2 class="text-2xl font-bold mb-4">Upcoming Events</h2>
<td>
<div class="font-semibold">{{ event.title }}</div>
{% if event.is_featured %}
<span class="badge badge-secondary badge-sm"
>Featured</span
>
<span class="badge badge-secondary badge-sm">Featured</span>
{% endif %}
</td>
<td>
{{ event.start_time|date:"D, d M Y" }}<br />
{{ event.start_time|date:"D, d M Y" }}<br>
<span class="text-sm text-base-content/70">
{{ event.start_time|time:"g:i A" }} - {{
event.end_time|time:"g:i A" }}
{{ event.start_time|time:"g:i A" }} - {{ event.end_time|time:"g:i A" }}
</span>
</td>
<td>
{% if event.church %} {{ event.church.name }} {%
else %} {{ event.location }} {% endif %}
{% if event.church %}
{{ event.church.name }}
{% else %}
{{ event.location }}
{% endif %}
</td>
<td>
<div class="flex flex-wrap gap-2">
<a
href="{% url 'event_detail' event.pk %}"
class="btn btn-sm btn-outline"
>
<a href="{% url 'event_detail' event.pk %}" class="btn btn-sm btn-outline">
Details
</a>
{% if user.is_authenticated %}
<button
class="btn btn-sm btn-outline like-button {% if user in event.likes.all %}btn-error{% endif %}"
data-event-id="{{ event.pk }}"
data-likes="{{ event.like_count }}"
>
<button class="btn btn-sm btn-outline like-button {% if user in event.likes.all %}btn-error{% endif %}"
data-event-id="{{ event.pk }}"
data-likes="{{ event.like_count }}">
<i class="fa-solid fa-heart"></i>
<span class="like-count"
>{{ event.like_count }}</span
>
<span class="like-count">{{ event.like_count }}</span>
</button>
{% endif %} {% if user.is_staff or
user.is_superuser %}
<a
href="{% url 'event_edit' event.pk %}"
class="btn btn-sm btn-warning"
>Edit</a
>
<a
href="{% url 'event_delete' event.pk %}"
class="btn btn-sm btn-error"
>Delete</a
>
{% endif %}
{% if user.is_staff or user.is_superuser %}
<a href="{% url 'event_edit' event.pk %}" class="btn btn-sm btn-warning">Edit</a>
<a href="{% url 'event_delete' event.pk %}" class="btn btn-sm btn-error">Delete</a>
{% endif %}
</div>
</td>
Expand Down
117 changes: 52 additions & 65 deletions home/templates/home/partials/_events_calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ <h3 class="text-lg font-semibold mb-2">Featured Events</h3>
<h3 class="card-title">{{ event.title }}</h3>
<p class="text-sm mb-2">
<i class="fa-regular fa-calendar mr-1"></i>
{{ event.start_time|date:"D, d M Y" }} at {{
event.start_time|time:"g:i A" }}
{{ event.start_time|date:"D, d M Y" }} at {{ event.start_time|time:"g:i A" }}
</p>
<p class="text-sm mb-2">
<i class="fa-solid fa-location-dot mr-1"></i>
{% if event.church %}{{ event.church.name }}{% else %}{{
event.location }}{% endif %}
{% if event.church %}{{ event.church.name }}{% else %}{{ event.location }}{% endif %}
</p>
<div class="card-actions justify-end mt-2">
<a
Expand Down Expand Up @@ -61,21 +59,21 @@ <h3 class="card-title">{{ event.title }}</h3>
<td>
<div class="font-semibold">{{ event.title }}</div>
{% if event.is_featured %}
<span class="badge badge-secondary badge-sm mt-1"
>Featured</span
>
<span class="badge badge-secondary badge-sm mt-1">Featured</span>
{% endif %}
</td>
<td>
{{ event.start_time|date:"D, d M Y" }}<br />
<span class="text-sm text-base-content/70">
{{ event.start_time|time:"g:i A" }} - {{
event.end_time|time:"g:i A" }}
{{ event.start_time|time:"g:i A" }} - {{ event.end_time|time:"g:i A" }}
</span>
</td>
<td>
{% if event.church %} {{ event.church.name }} {% else %}
{{ event.location }} {% endif %}
{% if event.church %}
{{ event.church.name }}
{% else %}
{{ event.location }}
{% endif %}
</td>
<td>
<div class="flex flex-wrap gap-2">
Expand Down Expand Up @@ -104,12 +102,11 @@ <h3 class="card-title">{{ event.title }}</h3>
title="Mark as interested"
>
<i class="fa-solid fa-heart"></i>
<span class="like-count ml-1"
>{{ event.like_count }}</span
>
<span class="like-count ml-1">{{ event.like_count }}</span>
</button>
{% endif %} {% if user.is_staff or user.is_superuser
%}
{% endif %}

{% if user.is_staff or user.is_superuser %}
<a
href="{% url 'event_edit' event.pk %}"
class="btn btn-sm btn-warning"
Expand All @@ -132,22 +129,19 @@ <h3 class="card-title">{{ event.title }}</h3>
<tr>
<td colspan="4" class="text-center py-8">
<div class="flex flex-col items-center gap-2">
<i
class="fa-regular fa-calendar-xmark text-4xl text-base-300"
></i>
<i class="fa-regular fa-calendar-xmark text-4xl text-base-300"></i>
<p class="text-base-content/70">
No upcoming events scheduled. Check back soon!
</p>
</div>
</td>
</tr>
{% endfor %} {% if user.is_staff or user.is_superuser %}
{% endfor %}

{% if user.is_staff or user.is_superuser %}
<tr>
<td colspan="4" class="text-center bg-base-200">
<a
href="{% url 'event_new' %}"
class="btn btn-primary btn-sm"
>
<a href="{% url 'event_new' %}" class="btn btn-primary btn-sm">
<i class="fa-solid fa-plus mr-2"></i>Add New Event
</a>
</td>
Expand All @@ -164,29 +158,24 @@ <h3 class="card-title">{{ event.title }}</h3>
const fullUrl = window.location.origin + url;

if (navigator.share) {
navigator
.share({
title: title,
url: fullUrl,
})
.catch((err) => console.error("Share failed:", err));
navigator.share({
title: title,
url: fullUrl,
}).catch((err) => console.error("Share failed:", err));
} else {
// Fallback: copy to clipboard
navigator.clipboard
.writeText(fullUrl)
.then(() => {
alert("Link copied to clipboard!");
})
.catch((err) => {
// Older fallback
const tempInput = document.createElement("input");
document.body.appendChild(tempInput);
tempInput.value = fullUrl;
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
alert("Link copied to clipboard!");
});
navigator.clipboard.writeText(fullUrl).then(() => {
alert("Link copied to clipboard!");
}).catch((err) => {
// Older fallback
const tempInput = document.createElement("input");
document.body.appendChild(tempInput);
tempInput.value = fullUrl;
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
alert("Link copied to clipboard!");
});
}
}

Expand All @@ -198,32 +187,32 @@ <h3 class="card-title">{{ event.title }}</h3>
button.addEventListener("click", function () {
const eventId = this.dataset.eventId;

fetch(`/events/${eventId}/like/`, {
fetch(`/home/events/${eventId}/like/`, {
method: "POST",
headers: {
"X-CSRFToken": getCookie("csrftoken"),
"Content-Type": "application/json",
},
})
.then((response) => response.json())
.then((data) => {
if (data.status === "success") {
const likeCount = this.querySelector(".like-count");
likeCount.textContent = data.likes;
.then((response) => response.json())
.then((data) => {
if (data.status === "success") {
const likeCount = this.querySelector(".like-count");
likeCount.textContent = data.likes;

if (data.liked) {
this.classList.add("btn-error");
} else {
this.classList.remove("btn-error");
}
if (data.liked) {
this.classList.add("btn-error");
} else {
alert("Please log in to like events");
this.classList.remove("btn-error");
}
})
.catch((error) => {
console.error("Error:", error);
alert("An error occurred. Please try again.");
});
} else {
alert("Please log in to like events");
}
})
.catch((error) => {
console.error("Error:", error);
alert("An error occurred. Please try again.");
});
});
});
});
Expand All @@ -236,9 +225,7 @@ <h3 class="card-title">{{ event.title }}</h3>
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
if (cookie.substring(0, name.length + 1) === name + "=") {
cookieValue = decodeURIComponent(
cookie.substring(name.length + 1)
);
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
Expand Down