2024-05-10 11:54:16 +00:00
|
|
|
import datetime
|
|
|
|
|
2024-03-20 08:19:58 +00:00
|
|
|
from django import forms
|
2024-05-30 07:57:20 +00:00
|
|
|
|
2024-05-10 11:54:16 +00:00
|
|
|
from .models import AdoptionNotice, Animal, Image, Report, ModerationAction, User, Species
|
2024-04-07 09:33:41 +00:00
|
|
|
from django_registration.forms import RegistrationForm
|
2024-04-20 06:06:20 +00:00
|
|
|
from crispy_forms.helper import FormHelper
|
2024-05-10 11:54:16 +00:00
|
|
|
from crispy_forms.layout import Submit, Layout, Fieldset, HTML, Row, Column, Field
|
2024-04-20 06:06:20 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2024-05-10 11:54:16 +00:00
|
|
|
from notfellchen.settings import MEDIA_URL
|
|
|
|
|
2024-03-20 08:19:58 +00:00
|
|
|
|
|
|
|
class DateInput(forms.DateInput):
|
|
|
|
input_type = 'date'
|
|
|
|
|
|
|
|
|
|
|
|
class AdoptionNoticeForm(forms.ModelForm):
|
2024-04-20 06:06:20 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
self.helper = FormHelper()
|
2024-04-20 06:40:04 +00:00
|
|
|
|
|
|
|
self.helper.form_id = 'form-adoption-notice'
|
2024-04-20 06:06:20 +00:00
|
|
|
self.helper.form_class = 'card'
|
|
|
|
self.helper.form_method = 'post'
|
|
|
|
|
2024-04-20 06:40:16 +00:00
|
|
|
self.helper.layout = Layout(
|
|
|
|
Fieldset(
|
|
|
|
_('Vermittlungsdetails'),
|
|
|
|
'name',
|
|
|
|
'group_only',
|
|
|
|
'searching_since',
|
|
|
|
'description',
|
|
|
|
'further_information',
|
|
|
|
),
|
|
|
|
Submit('submit', _('Submit'))
|
|
|
|
)
|
2024-04-20 06:06:20 +00:00
|
|
|
|
2024-03-20 08:19:58 +00:00
|
|
|
class Meta:
|
|
|
|
model = AdoptionNotice
|
|
|
|
fields = ['name', "group_only", "further_information", "description", "searching_since"]
|
|
|
|
widgets = {
|
|
|
|
'searching_since': DateInput(),
|
|
|
|
}
|
|
|
|
|
2024-03-20 12:40:00 +00:00
|
|
|
|
|
|
|
class ImageForm(forms.ModelForm):
|
2024-05-10 11:54:16 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
self.helper = FormHelper()
|
|
|
|
self.helper.form_id = 'form-animal-photo'
|
|
|
|
self.helper.form_class = 'card'
|
|
|
|
self.helper.form_method = 'post'
|
|
|
|
|
2024-03-20 12:40:00 +00:00
|
|
|
class Meta:
|
|
|
|
model = Image
|
|
|
|
fields = ('title', 'image', 'alt_text')
|
2024-03-22 11:45:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ReportForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Report
|
|
|
|
fields = ('reported_broken_rules', 'comment')
|
|
|
|
|
|
|
|
|
|
|
|
class ModerationActionForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = ModerationAction
|
|
|
|
fields = ('action', 'public_comment', 'private_comment')
|
2024-04-07 09:33:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
class CustomRegistrationForm(RegistrationForm):
|
2024-04-07 09:41:37 +00:00
|
|
|
class Meta(RegistrationForm.Meta):
|
|
|
|
model = User
|