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.
22 lines
723 B
22 lines
723 B
# -*- coding: utf-8 -*-
|
|
from django import forms
|
|
from django.utils.translation import ugettext as _
|
|
|
|
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()
|
|
|