mirror of
https://framagit.org/la-chariotte/la-chariotte.git
synced 2025-05-17 11:11:49 +02:00
35 lines
1,023 B
Python
35 lines
1,023 B
Python
import datetime
|
|
|
|
from django import forms
|
|
from django.contrib.auth import get_user_model
|
|
from django.forms.utils import to_current_timezone
|
|
from django.utils import timezone
|
|
|
|
from la_chariotte.lieu.models import Lieu
|
|
|
|
|
|
class LieuForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Lieu
|
|
fields = [
|
|
"name",
|
|
"description",
|
|
"url",
|
|
]
|
|
widgets = {
|
|
"name": forms.TextInput(
|
|
attrs={"placeholder": "ex : Centre social Kropotkine"}
|
|
),
|
|
"description": forms.Textarea(
|
|
attrs={"placeholder": "Plus d'infos sur le lieu ? (facultatif)"}
|
|
),
|
|
"url": forms.TextInput(attrs={"placeholder": "raccourci"}),
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
self.user = kwargs.pop("user")
|
|
super().__init__(*args, **kwargs)
|
|
|
|
def save(self, commit=True):
|
|
self.instance.orga = get_user_model().objects.get(id=self.user.pk)
|
|
return super().save(commit=commit)
|