예제 #1
0
 def get_editor_widget(self, request, plugins):
     """ Returns the Django form Widget to be used for the text area """
     if USE_TINYMCE and "tinymce" in settings.INSTALLED_APPS:
         from cms.plugins.text.widgets.tinymce_widget import TinyMCEEditor
         return TinyMCEEditor(installed_plugins=plugins)
     else:
         return WYMEditor(installed_plugins=plugins)
예제 #2
0
class NewsLetterForm(TranslatableModelForm):
    message = forms.CharField(widget=WYMEditor())
    date = forms.ChoiceField(
        help_text=_("If no dates are shown here, check your site settings"))

    def __init__(self, *args, **kwargs):
        super(NewsLetterForm, self).__init__(*args, **kwargs)

        if get_settings() and get_settings().interval == NO_INTERVAL:
            self.fields['date'] = forms.DateField()
        else:
            self.fields['date'].choices = get_upcoming_dates(datetime.now())

        # I don't understand where self.language comes from, it must be some magic in TranslatableModelForm
        # but I can't identify it; in any case we need some default for tests
        if not hasattr(self, 'language'):
            self.language = 'en'

        for fieldname in ['sender_email', 'sender_name', 'subject', 'message']:
            self.fields[fieldname].initial = getattr(
                get_default_for_newsitem(self.language),
                fieldname) if get_default_for_newsitem(self.language) else ""

    class Meta:
        model = NewsLetter
예제 #3
0
def get_editor_widget():
    """
    Returns the Django form Widget to be used for
    the text area
    """
    #plugins = plugin_pool.get_text_enabled_plugins(self.placeholder, self.page)        
    if USE_TINYMCE and "tinymce" in settings.INSTALLED_APPS:
        from cms.plugins.text.widgets.tinymce_widget import TinyMCEEditor
        return TinyMCEEditor()
    else:
        return WYMEditor()
class ReminderSettingsForm(forms.ModelForm):
    resubscribe_email_message = forms.CharField(widget=WYMEditor(), required=False)

    def clean(self):
        cleaned_data = super(ReminderSettingsForm, self).clean()
        if cleaned_data.get('send_reminders'):
            if cleaned_data.get('interval') != NO_INTERVAL and not (cleaned_data.get('begin_date') and cleaned_data.get('interval')):
                raise forms.ValidationError(_("If 'send_reminders' is checked the other fields pertaining to reminders are required"))

        if cleaned_data.get('send_resubscribe_email'):
            if not (cleaned_data.get('resubscribe_email_subject') and cleaned_data.get('resubscribe_email_message')):
                raise forms.ValidationError(_("If 'send_resubscribe_email' is checked the other fields pertaining to resubscription are required"))

        return cleaned_data

    class Meta:
        model = ReminderSettings
class SiteSettingsForm(forms.ModelForm):
    light_color = forms.RegexField(
        label=_("Light color"),
        help_text=
        _("Hexidecimal value w/o preceding '#'; The dark color is calculated from this."
          ),
        regex='[0-9a-fA-F]{6}',
        error_messages={
            'invalid':
            _('Use a hexidecimal value (length: 6) without the preceding #')
        })
    footer = forms.CharField(widget=WYMEditor(), required=False)

    def save(self, commit=True):
        result = super(SiteSettingsForm, self).save(commit=False)
        result.light_color = result.light_color.lower()
        if commit:
            result.save()
        return result

    class Meta:
        model = SiteSettings
예제 #6
0
class NewsLetterTemplateForm(TranslatableModelForm):
    message = forms.CharField(widget=WYMEditor())

    class Meta:
        model = NewsLetterTemplate