You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

21 lines
672 B

# -*- coding: utf-8 -*-
from django import forms
from functions.forms import EmptySelect
from .models import Comment
class CommentForm(forms.ModelForm):
class Meta:
model = Comment
fields = ['parent', 'text']
widgets = dict(parent=EmptySelect)
def save(self, commit=True):
obj = super(CommentForm, self).save(commit=False)
return obj
def clean(self):
if getattr(self._user, 'readonly', True):
raise forms.ValidationError(_(u'Вы не можете оставлять комментарии. Вам выдано ограничение ReadOnly.'))
return super(CommentForm, self).clean()