Skip to content

Commit

Permalink
some reforms
Browse files Browse the repository at this point in the history
  • Loading branch information
deawer234 committed Dec 6, 2023
1 parent 32fdbff commit 88c07a7
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 90 deletions.
6 changes: 3 additions & 3 deletions fiesta/apps/dashboard/templates/dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@
{% endif %}
</div>
{% endif %}
{% if blocks.events %}
<div class="w-full md:w-3/5">{% include blocks.events with request=request %}</div>
{% endif %}
</div>
{% if blocks.events %}
<div class="w-full ">{% include blocks.events with request=request %}</div>
{% endif %}
</div>
{% endblock %}
25 changes: 16 additions & 9 deletions fiesta/apps/events/templates/events/dashboard_block.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{% load i18n %}
<div class="Dashboard__tiles flex flex-col md:flex-row">
<div class="Dashboard__tiles flex flex-row md:flex-row">
<div class="Dashboard__tile Dashboard__tile--dark shadow-2xl bg-primary">
<div class="Dashboard__tile__title">Your Events</div>

{% if request.membership.is_international %}

<div class="Dashboard__tile__title">Your Events</div>

<div class="Dashboard__tile__value">
{% for participating in participations %}
{% for participating in users_events %}
<div>
<a href="{% url "events:event-detail" participating.event.id %}">
<span class="text-3xl">{{ participating.event.title }}</span>
<span class="text-lg text-gray-300">{{ participating.event.start }}</span>
<a href="{% url "events:event-detail" participating.id %}">
<span class="text-3xl">{{ participating.title }}</span>
<span class="text-lg text-gray-300">{{ participating.start }}</span>
</a>
</div>
{% endfor %}
</div>

{% else %}
<div class="Dashboard__tile__title">Upcoming events</div>
<div class="Dashboard__tile__value">
{% for event in request.user.events.all %}
<div>
Expand All @@ -27,12 +28,18 @@
</div>
{% endfor %}
</div>

{% endif %}
{% if request.membership.is_local %}
<div class="Dashboard__tile__actions text-right">
<a href="{% url "events:add-event" %}"
class="btn btn-lg btn-outline">Create new event</a>
</div>
{% endif %}
{% elif request.membership.is_international %}
<div class="Dashboard__tile__actions text-right">
<a href="{% url "events:index" %}"
class="btn btn-lg btn-outline">Show events</a>
</div>
{%endif %}

</div>
</div>
21 changes: 10 additions & 11 deletions fiesta/apps/events/templates/events/event_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
{% load breadcrumbs %}
{% load i18n %}

{% block head %}
{{form.media}}
{% endblock %}


{% block main %}

{% can_edit event as rights %}
{% if rights or request.membership.is_privileged %}

{% can_edit event as bool %}
{% if bool %}

<div class="card rounded-lg bg-base-100 text-left shadow-xl">

Expand Down Expand Up @@ -45,7 +44,7 @@ <h2 class="card-title text-base-content row-start-1">{{ price.title }}</h2>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"/>
</svg>
</a>

{% if event.state == event.State.DRAFT %}
<a href="#"
hx-post="{% url "events:price-delete" event.pk price.pk %}"
hx-confirm="Are you sure you want to delete this price?"
Expand All @@ -55,13 +54,16 @@ <h2 class="card-title text-base-content row-start-1">{{ price.title }}</h2>
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
</svg>
</a>
{% endif %}
</div>
</div>
</div>

{% endfor %}

</div>
{% endif %}


<div class="card-actions justify-end">
<a class="btn btn-primary btn-outline"
Expand All @@ -73,6 +75,7 @@ <h2 class="card-title text-base-content row-start-1">{{ price.title }}</h2>
</div>



<div class="card rounded-lg bg-base-100 text-left shadow-xl mt-6">

<div class="card-body">
Expand Down Expand Up @@ -134,11 +137,9 @@ <h1 class="card-title text-base-content"> Organizers </h1>
</div>
</div>

{% can_edit event as bool %}
{% if bool %}
<div class="card rounded-lg bg-base-100 text-left shadow-xl mt-6 mb-6">
<div class="card-body">
<h1 class="card-title text-base-content"> Event </h1>
<h1 class="card-title text-base-content"> Event configuration </h1>
<div class="card-actions justify-end">
<a href="{% url "events:participants" event.id %}" class="btn btn-primary btn-outline">{% translate "Show participants" %}</a>
<a href="{% url "events:event-update" event.id %}" class="btn btn-warning btn-outline">{% translate "Update event" %}</a>
Expand All @@ -154,8 +155,6 @@ <h1 class="card-title text-base-content"> Event </h1>



{%endif%}

<div class="md:flex lg:grid sm:flex grid-rows-2 grid-cols-2 grid-flow-row flex-wrap gap-0 max-lg:hidden pt-6">
<div class="card row-span-2 w-full lg:ml-[50px] max-lg:hidden">
<div class="card-body h-full rounded-lg bg-base-100 text-left shadow-xl lg:pr-12">
Expand Down
10 changes: 3 additions & 7 deletions fiesta/apps/events/templates/events/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ <h1 class="text-3xl font-semibold mb-4">Your events</h1>
<h1 class="text-3xl font-semibold mb-4">Upcoming Events of {{ request.in_space_of_section }}</h1>
<ul class="divide-y divide-gray-300" id="events-list" >
<!-- Event Item -->
{% for event in request.in_space_of_section.events.all %}
{% if not event.state == event.State.DRAFT %}
{% for event in upcoming_events %}

{% include "events/parts/event_item.html" %}
{% include "events/parts/event_item.html" %}

{% endif %}
{% endfor %}
</ul>
</div>
Expand All @@ -34,12 +32,10 @@ <h1 class="text-3xl font-semibold mb-4">Upcoming Events of {{ request.in_space_o
<h1 class="text-3xl font-semibold mb-4">Waiting confirmation</h1>
<ul class="divide-y divide-gray-300" >
<!-- Event Item -->
{% for event in request.in_space_of_section.events.all %}
{% if event.state == event.State.DRAFT %}
{% for event in darft_events %}

{% include "events/parts/event_item.html" %}

{% endif %}
{% endfor %}
</ul>
</div>
Expand Down
15 changes: 15 additions & 0 deletions fiesta/apps/events/templates/events/participants_table.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "fiestatables/page.html" %}

{% load breadcrumbs %}
{% load i18n %}

{% block upper_head %}
{% url "events:event-detail" event.pk as url%}
{% breadcrumb_push_item_with_url event.title url%}
{% trans "Participants" as participants %}
{% breadcrumb_push_item participants %}
{% endblock upper_head %}

{% block main %}
{{block.super}}
{% endblock main %}
56 changes: 30 additions & 26 deletions fiesta/apps/events/templates/events/parts/event_item.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
{% load i18n %}
{% load event_tags %}

<li class="py-4 bg-base-100 hover:bg-base-200 rounded-box p-4 mb-4 md:box-content">
<a href="{% url 'events:event-detail' event.id %}" class="block">
<div class="flex items-center space-x-4">
<div class="flex-shrink-0">
<div class="h-12 w-12 rounded-full bg-cover bg-center" style='background-image: url("{{ event.portrait_cover }}")'></div>
</div>
<a href="{% url 'events:event-detail' event.id %}">
<div class="card bg-base-100 hover:bg-base-200 shadow-xl rounded-xl mb-6">

<div class="flex-grow">
<h2 class="text-2xl font-semibold">{{ event.title }}</h2>
<p class="text-gray-600">{{ event.start.date }}</p>
<p class="text-gray-600">{{ event.description }}</p>
</div>
<div class="card-body flex flex-row">

{% if event.state == "published" %}
<div class="flex-shrink-0">
{% get_event_fullness event as tmp %}
{% if tmp == 0 %}
<span class="bg-green-400 mr-2 border divide-gray-100 rounded-full pt-2 pb-2 pl-3 pr-3 mb-2">Registrations opened</span>
{% elif tmp == 1 %}
<span class="bg-yellow-400 mr-2 border divide-gray-100 rounded-full pt-2 pb-2 pl-3 pr-3 mb-2">Some spots left</span>
{% elif tmp == 2 %}
<span class="bg-red-400 mr-2 border divide-gray-100 rounded-full pt-2 pb-2 pl-3 pr-3 mb-2">Registrations closed</span>
{% endif %}
</div>
{% endif %}
</div>
</a>
</li>
{% if event.portrait_cover%}
<div class="flex-shrink-0">
<div class="h-12 w-12 rounded-full bg-cover bg-center" style='background-image: url("{{ event.portrait_cover.url }}")'></div>
</div>
{% endif %}

<div class="flex-grow">
<h2 class="text-2xl card-title">{{ event.title }}</h2>
<p class="text-gray-600">{{ event.start.date }}</p>
</div>

{% if event.state == "published" %}
<div class="flex-none">
{% get_event_fullness event as tmp %}
{% if tmp == 0 %}
<span class="bg-green-400 mr-2 border divide-gray-100 rounded-full pt-2 pb-2 pl-3 pr-3 mb-2">Registrations opened</span>
{% elif tmp == 1 %}
<span class="bg-yellow-400 mr-2 border divide-gray-100 rounded-full pt-2 pb-2 pl-3 pr-3 mb-2">Some spots left</span>
{% elif tmp == 2 %}
<span class="bg-red-400 mr-2 border divide-gray-100 rounded-full pt-2 pb-2 pl-3 pr-3 mb-2">Registrations closed</span>
{% endif %}
</div>
{% endif %}
</div>

</div>
</a>
19 changes: 7 additions & 12 deletions fiesta/apps/events/templates/events/parts/update_event_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
{% load breadcrumbs %}
{% load i18n %}

{% block buttons_extra %}

{% endblock buttons_extra %}


<form action="{% url "events:event-update" event.pk %}" method="post" {% if form.is_multipart %}enctype="multipart/form-data" hx-encoding="multipart/form-data"{% endif %}>
{% csrf_token %}

Expand All @@ -19,13 +14,13 @@
{% endif %}
{{form}}

{% block breadcrumbs_right %}
<a class="btn btn-success btn-sm btn-outline"
href="{% url "events:eventplace-add" event.pk %}"
x-data="modal($el.href)"
x-bind="bind">{% translate "Add new place" %}</a>
{% endblock breadcrumbs_right %}

</form>

{% block buttons_extra %}
<a class="btn btn-primary btn-outline mr-6"
href="{% url "events:eventplace-add" event.pk %}"
x-data="modal($el.href)"
x-bind="bind">{% translate "Add new place" %}</a>
{% endblock buttons_extra %}


1 change: 1 addition & 0 deletions fiesta/apps/events/templates/events/place_view.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "fiestatables/page.html" %}
{% load breadcrumbs %}

{% load i18n %}
{% block main %}
Expand Down
30 changes: 13 additions & 17 deletions fiesta/apps/events/views/event.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import json
from typing import Any
from uuid import UUID
from django import http
from django.db import models
from django.forms.models import BaseModelForm

from django.http import HttpRequest, HttpResponse, HttpResponseRedirect, JsonResponse
from django.http import HttpRequest, HttpResponse
from django.template.loader import render_to_string
from django.shortcuts import get_object_or_404
import requests
from _operator import attrgetter


import django_filters
from django.contrib.postgres.search import SearchVector
from django.forms import TextInput
from django.views.generic import CreateView, DetailView, UpdateView, DeleteView, View
Expand All @@ -30,10 +26,9 @@
from apps.events.forms.event import AddEventForm
from apps.events.models.price_variant import EventPriceVariantType

from ...fiestatables.columns import ImageColumn, NaturalDatetimeColumn, LabeledChoicesColumn
from ...fiestatables.filters import BaseFilterSet, ProperDateFromToRangeFilter
from ...fiestatables.views.tables import FiestaTableView
from ...sections.views.mixins.membership import EnsurePrivilegedUserViewMixin, EnsureLocalUserViewMixin, EnsureInternationalUserViewMixin
from ...sections.views.mixins.membership import EnsurePrivilegedUserViewMixin, EnsureLocalUserViewMixin
from ...sections.views.mixins.section_space import EnsureInSectionSpaceViewMixin
from ...utils.breadcrumbs import with_breadcrumb, with_plugin_home_breadcrumb, with_object_breadcrumb
from allauth.account.utils import get_next_redirect_url
Expand Down Expand Up @@ -74,6 +69,7 @@ def get_success_url(self):


@with_plugin_home_breadcrumb
@with_object_breadcrumb(prefix=None, getter=attrgetter("title"))
@with_breadcrumb(_("Update"))
class UpdateEventView(
EnsurePrivilegedUserViewMixin,
Expand Down Expand Up @@ -134,7 +130,7 @@ def get_success_url(self):
return reverse("events:index")

@with_plugin_home_breadcrumb
@with_breadcrumb(_("Detail"))
@with_object_breadcrumb(prefix=None, getter=attrgetter("title"))
class EventDetailView(
EnsureInSectionSpaceViewMixin,
DetailView,
Expand Down Expand Up @@ -249,19 +245,19 @@ def __init__(self, *args, **kwargs):


@with_plugin_home_breadcrumb
@with_breadcrumb(_("Participants"))
class ParticipantsView(
EnsurePrivilegedUserViewMixin,
EnsureLocalUserViewMixin,
EnsureInSectionSpaceViewMixin,
FiestaTableView):
FiestaTableView,
):

model = Participant

request: HttpRequest
template_name = "fiestatables/page.html"
template_name = "events/participants_table.html"
table_class = EventParticipantsTable
filterset_class = EventParticipantsFilter
model = Participant

filterset_class = EventParticipantsFilter

def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:
self.event = get_object_or_404(Event, pk=self.kwargs.get("pk"))
return super().dispatch(request, *args, **kwargs)
Expand All @@ -277,7 +273,7 @@ def get_table_kwargs(self):
return kwargs

def get_queryset(self):
return self.request.in_space_of_section.events.get(id=self.event.pk).participants.filter(
return self.request.in_space_of_section.events.get(id=self.event.pk).event_participants.filter(
state__in=(
Participant.State.WAITING,
Participant.State.CONFIRMED,
Expand Down
9 changes: 4 additions & 5 deletions fiesta/apps/events/views/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ class EventsIndexView(EnsureInSectionSpaceViewMixin, ListView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)

participants = Participant.objects.filter(user=self.request.membership.user)

events = [participant.event for participant in participants if participant.event]

context['users_events'] = events
context['users_events'] = Event.objects.filter(event_participants__user=self.request.membership.user).order_by('start')

context['upcoming_events'] = Event.objects.filter(section=self.request.in_space_of_section, state=Event.State.PUBLISHED).exclude(event_participants__user=self.request.membership.user).order_by('start')

context['darft_events'] = Event.objects.filter(section=self.request.in_space_of_section, state=Event.State.DRAFT).order_by('start')
return context

0 comments on commit 88c07a7

Please sign in to comment.