<commit_before># Miro Community - Easiest way to make a video website
#
# Copyright (C) 2009, 2010, 2011, 2012 Participatory Culture Foundation
# 
# Miro Community is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
# 
# Miro Community is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with Miro Community.  If not, see <http://www.gnu.org/licenses/>.

from django import forms
from django.forms.models import modelformset_factory, BaseModelFormSet
from django.utils.translation import ugettext_lazy as _

from django.conf import settings
from django.contrib import comments
from django.contrib.comments import forms as comment_forms
from django.contrib.comments.views.moderation import (perform_approve,
                                                      perform_delete)

try:
    from recaptcha_django import ReCaptchaField
except ImportError:
    ReCaptchaField = None

Comment = comments.get_model()
    
class CommentForm(comment_forms.CommentForm):
    comment = forms.CharField(label=_("Comment"), widget=forms.Textarea,
                              max_length=comment_forms.COMMENT_MAX_LENGTH)
    email = forms.EmailField(label=_("Email address"),
                             required=False)
    if ReCaptchaField and not settings.DEBUG and \
            settings.RECAPTCHA_PRIVATE_KEY:
        captcha = ReCaptchaField()

    def __init__(self, target_object, data=None, initial=None):
        comment_forms.CommentForm.__init__(self, target_object, data, initial)
        if 'captcha' in self.fields and data and 'user' in data:
            from localtv.models import SiteSettings # avoid circular import
            if SiteSettings.objects.get_current().user_is_admin(data['user']):
                del self.fields['captcha']

class BulkModerateForm(forms.ModelForm):
    BULK = forms.BooleanField(required=False)
    APPROVE = forms.BooleanField(required=False)<commit_msg>Don't fail if recaptcha is installed without a private key.<commit_after># Miro Community - Easiest way to make a video website
#
# Copyright (C) 2009, 2010, 2011, 2012 Participatory Culture Foundation
# 
# Miro Community is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
# 
# Miro Community is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with Miro Community.  If not, see <http://www.gnu.org/licenses/>.

from django import forms
from django.forms.models import modelformset_factory, BaseModelFormSet
from django.utils.translation import ugettext_lazy as _

from django.conf import settings
from django.contrib import comments
from django.contrib.comments import forms as comment_forms
from django.contrib.comments.views.moderation import (perform_approve,
                                                      perform_delete)

try:
    from recaptcha_django import ReCaptchaField
except ImportError:
    ReCaptchaField = None

Comment = comments.get_model()
    
class CommentForm(comment_forms.CommentForm):
    comment = forms.CharField(label=_("Comment"), widget=forms.Textarea,
                              max_length=comment_forms.COMMENT_MAX_LENGTH)
    email = forms.EmailField(label=_("Email address"),
                             required=False)
    if (ReCaptchaField and not settings.DEBUG and
        getattr(settings, 'RECAPTCHA_PRIVATE_KEY', '')):
        captcha = ReCaptchaField()

    def __init__(self, target_object, data=None, initial=None):
        comment_forms.CommentForm.__init__(self, target_object, data, initial)
        if 'captcha' in self.fields and data and 'user' in data:
            from localtv.models import SiteSettings # avoid circular import
            if SiteSettings.objects.get_current().user_is_admin(data['user']):
                del self.fields['captcha']

class BulkModerateForm(forms.ModelForm):
    BULK = forms.BooleanField(required=False)
    APPROVE = forms.BooleanField(required=False)
{'fraction_non_alphanumeric': 0.07022708158116064, 'fraction_numerical': 0.007148864592094197, 'mean_word_length': 3.487735849056604, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3711530', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1220, 'n_words': 449}