website/conservancy/usethesource/forms.py

30 lines
1.7 KiB
Python

from django import forms
from .models import Comment, SourceOffer
class CommentForm(forms.ModelForm):
post_to_list = forms.BooleanField(required=False)
class Meta:
model = Comment
fields = ['time', 'attribute_to', 'message', 'post_to_list']
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['time'].widget.input_type = 'datetime-local'
class DownloadForm(forms.Form):
agree = forms.BooleanField(label="I understand that the goal of this process is to determine compliance with FOSS licenses, and that in downloading the source code candidate and/or firmware image, I am assisting SFC as a volunteer to investigate that question. I, therefore, promise and represent that I will not copy, distribute, modify, or otherwise use this source code candidate and/or firmware image for any purpose other than to help SFC evaluate the source code candidate for compliance with the terms of FOSS licenses, including but not limited to any version of the GNU General Public License. Naturally, if I determine in good faith that portions of the source code candidate and/or firmware image are subject to a FOSS license and are compliant with it, I may copy, distribute, modify, or otherwise use those portions in accordance with the FOSS license, and I take full responsibility for that determination and subsequent use.")
class SourceOfferForm(forms.ModelForm):
class Meta:
model = SourceOffer
fields = ['vendor', 'device', 'photo']
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['photo'].widget.attrs['capture'] = 'camera'
self.fields['photo'].widget.attrs['accept'] = 'image/*'