1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-20 17:41:55 +02:00

Add placeholders in activity form

This commit is contained in:
Yohann D'ANELLO
2020-08-31 00:13:38 +02:00
parent 56c41258b9
commit 8744455cbe
5 changed files with 125 additions and 85 deletions

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from datetime import timedelta
from random import shuffle
from django import forms
from django.contrib.contenttypes.models import ContentType
@ -10,11 +11,23 @@ from django.utils.translation import gettext_lazy as _
from member.models import Club
from note.models import Note, NoteUser
from note_kfet.inputs import Autocomplete, DateTimePickerInput
from note_kfet.middlewares import get_current_authenticated_user
from permission.backends import PermissionBackend
from .models import Activity, Guest
class ActivityForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# By default, the Kfet club is attended
self.fields["attendees_club"].initial = Club.objects.get(name="Kfet")
self.fields["attendees_club"].widget.attrs["placeholder"] = "Kfet"
clubs = list(Club.objects.filter(PermissionBackend
.filter_queryset(get_current_authenticated_user(), Club, "view")).all())
shuffle(clubs)
self.fields["organizer"].widget.attrs["placeholder"] = ", ".join(club.name for club in clubs[:4]) + ", ..."
def clean_date_end(self):
date_end = self.cleaned_data["date_end"]
date_start = self.cleaned_data["date_start"]

View File

@ -72,6 +72,7 @@ class Activity(models.Model):
max_length=255,
blank=True,
default="",
help_text=_("Place where the activity is organized, eg. Kfet."),
)
activity_type = models.ForeignKey(
@ -92,6 +93,7 @@ class Activity(models.Model):
on_delete=models.PROTECT,
related_name='+',
verbose_name=_('organizer'),
help_text=_("Club that organizes the activity. The entry fees will go to this club."),
)
attendees_club = models.ForeignKey(
@ -99,6 +101,7 @@ class Activity(models.Model):
on_delete=models.PROTECT,
related_name='+',
verbose_name=_('attendees club'),
help_text=_("Club that is authorized to join the activity. Mostly the Kfet club."),
)
date_start = models.DateTimeField(

View File

@ -17,7 +17,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<div class="card-body" id="profile_infos">
<dl class="row">
<dt class="col-xl-6">{% trans 'description'|capfirst %}</dt>
<dd class="col-xl-6"> {{ activity.description }}</dd>
<dd class="col-xl-6"> {{ activity.description|linebreaks }}</dd>
<dt class="col-xl-6">{% trans 'type'|capfirst %}</dt>
<dd class="col-xl-6"> {{ activity.activity_type }}</dd>