예제 #1
0
 class Meta:
     model = Bulletin
     fields = [
         'name', 'content', 'brief_description', 'show_window', 'visible',
         'file_content', 'indicators'
     ]
     labels = {
         'name': _('Bulletin name'),
         'content': _('Bulletin content'),
     }
     widgets = {
         'content':
         forms.Textarea,
         'brief_description':
         forms.Textarea,
         'file_content':
         ResubmitFileWidget(
             attrs={
                 'accept':
                 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet,text/csv'
             }),
         'indicators':
         ResubmitFileWidget(
             attrs={
                 'accept':
                 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet,text/csv'
             }),
     }
예제 #2
0
	class Meta:
		model = Themes
		fields = ['title', 'favicon', 'small_logo', 'large_logo', 'high_contrast_logo', 'footer_note']
		widgets = {
			'favicon': ResubmitFileWidget(attrs={'accept':'image/*'}),
			'small_logo': ResubmitFileWidget(attrs={'accept':'image/*'}),
			'large_logo': ResubmitFileWidget(attrs={'accept':'image/*'}),
			'high_contrast_logo': ResubmitFileWidget(attrs={'accept':'image/*'}),
		}
예제 #3
0
class FormModalMessage(forms.Form):
    MAX_UPLOAD_SIZE = 5 * 1024 * 1024

    comment = forms.CharField(widget=forms.Textarea, label=_("Message"))
    image = forms.FileField(
        widget=ResubmitFileWidget(attrs={'accept': 'image/*'}), required=False)

    def clean_comment(self):
        comment = self.cleaned_data.get('comment', '')
        cleaned_comment = strip_tags(comment)

        if cleaned_comment == '':
            self._errors['comment'] = [_('This field is required.')]

            return ValueError

        return comment

    def clean_image(self):
        image = self.cleaned_data.get('image', False)

        if image:
            if hasattr(image, '_size'):
                if image._size > self.MAX_UPLOAD_SIZE:
                    self._errors['image'] = [
                        _("The image is too large. It should have less than 5MB."
                          )
                    ]

                    return ValueError

        return image
예제 #4
0
 class Meta:
     model = Question
     fields = ['enunciado', 'question_img']
     widgets = {
         'enunciado': forms.Textarea,
         'question_img': ResubmitFileWidget(attrs={'accept': 'image/*'}),
     }
예제 #5
0
 class Meta:
     model = Alternative
     fields = ['content', 'alt_img', 'is_correct']
     widgets = {
         'content': forms.Textarea,
         'alt_img': ResubmitFileWidget(attrs={'accept': 'image/*'}),
     }
예제 #6
0
 class Meta:
     model = CategoryPost
     fields = ['action', 'post', 'image']
     widgets = {
         'action': forms.RadioSelect,
         'post': forms.Textarea,
         'image': ResubmitFileWidget(attrs={'accept': 'image/*'}),
     }
예제 #7
0
    class Meta:
        model = News
        fields = ['title','image','content']
        widgets = {
            'content': forms.Textarea,
            'image': ResubmitFileWidget(attrs={'accept':'image/*'}),

        }
예제 #8
0
 class Meta:
     model = PDFFile
     fields = ['name', 'file', 'brief_description','show_window', 'all_students', 'students', 'groups', 'visible']
     labels = {
         'name': _('File name'),
     }
     widgets = {
         'brief_description': forms.Textarea,
         'students': forms.SelectMultiple,
         'groups': forms.SelectMultiple,
         'file': ResubmitFileWidget(attrs={'accept':'application/pdf, application/x-pdf, application/x-bzpdf, application/x-gzpdf'}),
     }
예제 #9
0
 class Meta:
     model = User
     fields = [
         'email', 'username', 'last_name', 'social_name', 'description',
         'show_email', 'image'
     ]
     widgets = {
         'email': forms.EmailInput,
         'description': forms.Textarea,
         'username': forms.TextInput(attrs={'readonly': 'readonly'}),
         'last_name': forms.TextInput(attrs={'readonly': 'readonly'}),
         'image': ResubmitFileWidget(attrs={'accept': 'image/*'}),
     }
예제 #10
0
 class Meta:
     model = FileLink
     fields = [
         'name', 'file_content', 'brief_description', 'all_students',
         'students', 'groups', 'visible'
     ]
     labels = {
         'name': _('File name'),
     }
     widgets = {
         'brief_description':
         forms.Textarea,
         'students':
         forms.SelectMultiple,
         'groups':
         forms.SelectMultiple,
         'file_content':
         ResubmitFileWidget(
             attrs={
                 'accept':
                 'image/jpeg,image/x-citrix-jpeg,image/png,image/x-citrix-png,image/x-png,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.slideshow,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,text/html,application/msword,application/vnd.oasis.opendocument.presentation,application/vnd.oasis.opendocument.spreadsheet,application/vnd.oasis.opendocument.text,application/pdf,application/vnd.ms-powerpoint'
             }),
     }
예제 #11
0
 class Meta:
     model = User
     fields = [
         'email',
         'username',
         'last_name',
         'social_name',
         'image',
         'show_email',
         'x',
         'y',
         'width',
         'height',
     ]
     widgets = {
         'email': forms.EmailInput(attrs={'placeholder': _('Email *')}),
         'username': forms.TextInput(attrs={'placeholder': _('Name *')}),
         'last_name':
         forms.TextInput(attrs={'placeholder': _('Last Name *')}),
         'social_name':
         forms.TextInput(attrs={'placeholder': _('Social Name')}),
         'image': ResubmitFileWidget(attrs={'accept': 'image/*'}),
     }
예제 #12
0
 class Meta:
     model = Comment
     fields = ['comment', 'image']
     widgets = {
         'image': ResubmitFileWidget(attrs={'accept': 'image/*'}),
     }