2020-07-28 20:15:34 +02:00
|
|
|
from django import forms
|
|
|
|
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
|
2020-07-30 13:09:00 +02:00
|
|
|
from .models import Explorer, Place, PlaceImage
|
2020-07-28 20:15:34 +02:00
|
|
|
|
|
|
|
class ExplorerCreationForm(UserCreationForm):
|
|
|
|
class Meta:
|
|
|
|
model = Explorer
|
|
|
|
fields = ('username', 'email')
|
|
|
|
|
|
|
|
class ExplorerChangeForm(UserChangeForm):
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Explorer
|
|
|
|
fields = ('username', 'email')
|
2020-07-29 20:22:04 +02:00
|
|
|
|
|
|
|
class PlaceForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Place
|
|
|
|
fields = '__all__'
|
|
|
|
exclude = ['submitted_by']
|
2020-07-30 13:09:00 +02:00
|
|
|
|
|
|
|
class PlaceImageCreateForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = PlaceImage
|
2020-07-31 00:27:01 +02:00
|
|
|
fields = ['filename']
|
2020-07-30 13:09:00 +02:00
|
|
|
widgets = {
|
2020-07-30 22:33:41 +02:00
|
|
|
'filename': forms.ClearableFileInput(attrs={'multiple': True})
|
|
|
|
}
|
2020-07-30 22:18:55 +02:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
print(self.fields)
|
|
|
|
self.fields['filename'].required = False
|