def test_old_style_configs(self): from django_summernote.widgets import (SummernoteWidget, SummernoteInplaceWidget) OLD_STYLE_CONFIG = { 'width': '640px', 'toolbar': [ ['font', ['bold']], ], } self.app_config._copy_old_configs(OLD_STYLE_CONFIG, self.app_config.get_default_config()) widget = SummernoteInplaceWidget() html = widget.render( 'foobar', 'lorem ipsum', attrs={'id': 'id_foobar'} ) assert '"width": "640px"' in html assert '"height": 480' in html assert '"toolbar": [["font", ["bold"]]]' in html widget = SummernoteWidget() html = widget.render( 'foobar', 'lorem ipsum', attrs={'id': 'id_foobar'} ) assert '"width": "640px"' in html assert '"height": 480' in html assert '"toolbar": [["font", ["bold"]]]' in html
def test_old_style_configs(self): from django_summernote.widgets import (SummernoteWidget, SummernoteInplaceWidget) OLD_STYLE_CONFIG = { 'width': '640px', 'toolbar': [ ['font', ['bold']], ], } self.app_config._copy_old_configs(OLD_STYLE_CONFIG, self.app_config.get_default_config()) widget = SummernoteInplaceWidget() html = widget.render('foobar', 'lorem ipsum', attrs={'id': 'id_foobar'}) assert '"width": "640px"' in html assert '"height": 480' in html assert '"toolbar": [["font", ["bold"]]]' in html widget = SummernoteWidget() html = widget.render('foobar', 'lorem ipsum', attrs={'id': 'id_foobar'}) assert '"width": "640px"' in html assert '"height": 480' in html assert '"toolbar": [["font", ["bold"]]]' in html
class Meta: model = Quest fields = ('name', 'visible_to_students', 'xp', 'icon', 'short_description', 'verification_required', 'instructions', 'campaign', 'common_data', 'submission_details', 'instructor_notes', 'repeat_per_semester', 'max_repeats', 'hours_between_repeats', 'specific_teacher_to_notify', 'blocking', 'hideable', 'sort_order', 'date_available', 'time_available', 'date_expired', 'time_expired', 'available_outside_course', 'archived', 'editor') date_options = { 'showMeridian': False, # 'todayBtn': True, 'todayHighlight': True, # 'minuteStep': 5, 'pickerPosition': 'bottom-left', } time_options = { 'pickerPosition': 'bottom-left', 'maxView': 0, } widgets = { 'instructions': SummernoteInplaceWidget(), 'submission_details': SummernoteInplaceWidget(), 'instructor_notes': SummernoteInplaceWidget(), 'date_available': DatePickerInput(format='%Y-%m-%d'), 'time_available': TimePickerInput(), 'date_expired': DatePickerInput(format='%Y-%m-%d'), 'time_expired': TimePickerInput(), }
def test_widget_inplace(self): from django_summernote.widgets import SummernoteInplaceWidget widget = SummernoteInplaceWidget() html = widget.render("foobar", "lorem ipsum", attrs={"id": "id_foobar"}) assert "summernote" in html
class Meta: model = Proposal fields = ( 'title', 'brief', 'desc', 'comment', 'difficulty', 'duration', 'language', ) widgets = { 'desc': SummernoteInplaceWidget(), 'comment': SummernoteInplaceWidget(), } labels = { 'title': _('Proposal title (required)'), 'brief': _('Brief (required)'), 'desc': _('Detailed description (required)'), 'comment': _('Comment to reviewers (optional)'), 'difficulty': _('Session difficulty'), 'duration': _('Session duration'), 'language': _('Language'), }
class Meta: model = Sponsor fields = ( 'name_ko', 'name_en', 'level', 'manager_name', 'manager_email', 'business_registration_number', 'business_registration_file', 'url', 'logo_image', 'desc_ko', 'desc_en', ) widgets = { 'desc_ko': SummernoteInplaceWidget(), 'desc_en': SummernoteInplaceWidget(), } labels = { 'level': _('후원사 등급'), 'logo_image': _('로고 이미지'), 'name_ko': _('후원사 이름 (한글)'), 'name_en': _('후원사 이름 (영문)'), 'url': _('후원사 홈페이지 주소'), 'desc_ko': _('후원사 소개 (한글)'), 'desc_en': _('후원사 소개 (영문)'), 'manager_name': _('후원 담당자 이름'), 'manager_email': _('후원 담당자 이메일'), 'business_registration_number': _('후원사 사업자 등록 번호'), 'business_registration_file': _('후원사 사업자 등록증'), }
class Meta: model = TutorialProposal fields = ( 'title', 'brief', 'desc', 'difficulty', 'duration', 'language', 'capacity', ) widgets = { 'desc': SummernoteInplaceWidget(), 'comment': SummernoteInplaceWidget(), } labels = { 'title': _('Title'), 'brief': _('Brief'), 'desc': _('Detailed description'), 'difficulty': _('Session difficulty'), 'duration': _('Session duration'), 'language': _('Language'), 'capacity': _('Capacity'), }
def test_old_style_configs(self): from django_summernote.settings import _copy_old_configs, SETTINGS_DEFAULT from django_summernote.widgets import (SummernoteWidget, SummernoteInplaceWidget) OLD_STYLE_CONFIG = { 'width': '640px', 'toolbar': [ ['font', ['bold']], ], } _copy_old_configs(summernote_config, OLD_STYLE_CONFIG, SETTINGS_DEFAULT) widget = SummernoteInplaceWidget() html = widget.render( 'foobar', 'lorem ipsum', attrs={'id': 'id_foobar'} ) assert '"width": "640px"' in html assert '"height": 480' in html assert '"toolbar": [["font", ["bold"]]]' in html widget = SummernoteWidget() html = widget.render( 'foobar', 'lorem ipsum', attrs={'id': 'id_foobar'} ) assert '"width": "640px"' in html assert '"height": 480' in html assert '"toolbar": [["font", ["bold"]]]' in html
class Meta: model = Article fields = '__all__' widgets = { 'title': SummernoteInplaceWidget(), 'body': SummernoteInplaceWidget() }
def test_widget_inplace(self): from django_summernote.widgets import SummernoteInplaceWidget widget = SummernoteInplaceWidget() html = widget.render('foobar', 'lorem ipsum', attrs={'id': 'id_foobar'}) assert 'summernote' in html
def test_widget_inplace(self): from django_summernote.widgets import SummernoteInplaceWidget widget = SummernoteInplaceWidget() html = widget.render( 'foobar', 'lorem ipsum', attrs={'id': 'id_foobar'} ) assert 'summernote' in html
class Meta: model = Sponsor fields = ( 'virtual_booth_content_ko', 'virtual_booth_content_en', ) labels = {'virtual_booth_content': _('Virtual booth content')} widgets = { 'virtual_booth_content_ko': SummernoteInplaceWidget(), 'virtual_booth_content_en': SummernoteInplaceWidget(), }
def test_widget_inplace_with_ugettext_lazy(self): from django_summernote.widgets import SummernoteInplaceWidget from django.utils.translation import ugettext_lazy from django_summernote.widgets import __summernote_options__ widget = SummernoteInplaceWidget() # Force an attribute to be an unevaluated __proxy__ type. This is how django handles string translations. html = widget.render('foobar', 'lorem ipsum', attrs={ x: ugettext_lazy('yada') for x in ['id'] + __summernote_options__ }) assert 'summernote' in html
class Meta: model = NoteTemplate exclude = ('pub_date',) #fields = ['title', 'note', 'parent'] widgets = { 'note': SummernoteInplaceWidget(), }
class Meta: model = PostDetail fields = ('post_detail', ) widgets = { 'foo': SummernoteWidget(), 'bar': SummernoteInplaceWidget(), }
class Meta: model = Challenge fields = [ *common_information_items, "display_forum_link", "disclaimer", "contact_email", "banner", *common_images_items, *event_items, *registration_items, "use_teams", ] widgets = { "workshop_date": forms.TextInput(attrs={"type": "date"}), "task_types": Select2MultipleWidget, "modalities": Select2MultipleWidget, "structures": Select2MultipleWidget, "organizations": Select2MultipleWidget, "series": Select2MultipleWidget, "publications": Select2MultipleWidget, "registration_page_text": SummernoteInplaceWidget(), } help_texts = { "publications": format_lazy( ( "The publications associated with this archive. " 'If your publication is missing click <a href="{}">here</a> to add it ' "and then refresh this page." ), reverse_lazy("publications:create"), ) }
class Meta: model = ClassDetail fields = ('class_detail',) widgets = { 'foo': SummernoteWidget(), 'bar': SummernoteInplaceWidget(), }
def __init__(self, *args, **kargs): super(EditActionOutForm, self).__init__(*args, **kargs) if self.instance.action_type == Action.PERSONALIZED_TEXT: self.fields['content'].widget = SummernoteInplaceWidget() else: # Add the target_url field self.fields['target_url'] = forms.CharField( initial=self.instance.target_url, label=_('Target URL'), strip=True, required=False, widget=forms.Textarea( attrs={ 'rows': 1, 'cols': 120, 'placeholder': _('URL to send the personalized JSON') } ) ) # Modify the content field so that it uses the TextArea self.fields['content'].widget = forms.Textarea( attrs={'cols': 80, 'rows': 15, 'placeholder': _('Write a JSON object')} )
class Meta: model = Article fields = ['article_title', 'article_text'] widgets = { 'foo': SummernoteWidget(), 'bar': SummernoteInplaceWidget(), }
class Meta: model = Ideas exclude = ['likes', 'author', 'is_approved', 'views', 'status'] widgets = { 'foo': SummernoteWidget(), 'bar': SummernoteInplaceWidget(), }
class Meta: model = SprintProposal fields = ('title', 'language', 'project_url', 'project_brief', 'contribution_desc',) widgets = { 'contribution_desc': SummernoteInplaceWidget(), 'comment': SummernoteInplaceWidget(), } labels = { 'title': _('Title'), 'language': _('Language'), 'project_url': _('Project URL'), 'project_brief': _('Project brief'), 'contribution_desc': _('Contribution description') }
def test_widgets_with_attributes(self): from django_summernote.widgets import (SummernoteWidget, SummernoteInplaceWidget) widget = SummernoteInplaceWidget(attrs={'class': 'special'}) html = widget.render( 'foobar', 'lorem ipsum', attrs={'id': 'id_foobar'} ) assert 'class="special"' in html widget = SummernoteWidget(attrs={'class': 'special'}) html = widget.render( 'foobar', 'lorem ipsum', attrs={'id': 'id_foobar'} ) assert 'class="special"' in html
def test_widgets_with_adhoc_settings(self): from django_summernote.widgets import (SummernoteWidget, SummernoteInplaceWidget) widget = SummernoteInplaceWidget(attrs={'summernote': {'toolbar': [['font', ['bold']]]}}) html = widget.render( 'foobar', 'lorem ipsum', attrs={'id': 'id_foobar'} ) assert '"toolbar": [["font", ["bold"]]]' in html widget = SummernoteWidget(attrs={'summernote': {'toolbar': [['font', ['italic']]]}}) html = widget.render( 'foobar', 'lorem ipsum', attrs={'id': 'id_foobar'} ) assert '"toolbar": [["font", ["italic"]]]' in html
class Meta: model = Comentario widgets = { 'foo': SummernoteWidget(), 'bar': SummernoteInplaceWidget(), } fields = ['ContenidoComentario']
class PostAdmin(admin.ModelAdmin): """Admin panel class for Post""" exclude = ('author',) date_hierarchy = 'created_at' list_display = ('title', 'author', 'created_at', 'published', 'get_tags') list_filter = ['author', 'created_at', 'published'] search_fields = ('title', 'body') prepopulated_fields = {"slug": ("title",)} formfield_overrides = { models.TextField: {'widget': SummernoteInplaceWidget()}, } inlines = [ RecipeInline, ] # http://stackoverflow.com/questions/753704/manipulating-data-in-djangos-admin-panel-on-save def save_model(self, request, obj, form, change): """Customize save method via admin panel save""" if not change: obj.author = request.user # obj.set_slug() obj.save() class Media: css = { 'all': ('/static/css/summernote2.css',) }
class Meta: model = Detail fields = ('name', 'issue', 'class_detail') widgets = { 'summernote': SummernoteWidget(), 'summernoteinplace': SummernoteInplaceWidget(), }
class Meta: model = models.ReportConfiguration fields = ('header', 'footer') widgets = { 'header': SummernoteInplaceWidget( attrs={'summernote': { 'width': '100%', 'height': '200px' }}), 'footer': SummernoteInplaceWidget( attrs={'summernote': { 'width': '100%', 'height': '200px' }}), }
class Meta: model = Article #fields = "__all__" fields = ['category', 'title', 'body'] widgets = { 'body': SummernoteInplaceWidget(), }
class ConfigForm(forms.Form): html_title = forms.CharField(max_length=255) page_title = forms.CharField(max_length=20) contact_url = forms.URLField( required=False, help_text="If this is empty, button will <b>NOT</b> appear") contact_url_text = forms.CharField(max_length=255) host_loc = forms.CharField(max_length=255) contact_text = forms.CharField(widget=SummernoteInplaceWidget()) footer = forms.CharField(widget=SummernoteInplaceWidget()) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) gs_field = GeneralSettings.objects.filter(key="GS_FOOTER_TEXT") if gs_field: self.fields['footer'].initial = escape(gs_field[0].value) gs_field = GeneralSettings.objects.filter(key="GS_HTMLTITLE_TEXT") if gs_field: self.fields['html_title'].initial = escape(gs_field[0].value) gs_field = GeneralSettings.objects.filter(key="GS_PAGETITLE_TEXT") if gs_field: self.fields['page_title'].initial = escape(gs_field[0].value) gs_field = GeneralSettings.objects.filter(key="GS_CONTACT_URL") if gs_field and gs_field[0].value: self.fields['contact_url'].initial = escape(gs_field[0].value) gs_field = GeneralSettings.objects.filter(key="GS_CONTACT_URL_TEXT") if gs_field: self.fields['contact_url_text'].initial = escape(gs_field[0].value) gs_field = GeneralSettings.objects.filter(key="GS_CONTACT_TEXT") if gs_field: self.fields['contact_text'].initial = escape(gs_field[0].value) gs_field = GeneralSettings.objects.filter(key="GS_HOST_UPLOAD_LOC") if gs_field: self.fields['host_loc'].initial = escape(gs_field[0].value) def clean(self): self.cleaned_data = super().clean() if self.cleaned_data["host_loc"][-1] != '/': self.add_error("host_loc", "Path has to end with the (/) slash")
class Meta: model = News fields = [ 'title', 'category', 'tags', 'text', 'text_min', 'description', 'image' ] widget = { 'title': forms.TextInput(attrs={'class': 'form-control'}), #'slug' : forms.TextInput(attrs={'class': 'form-control'}), 'category': forms.TextInput(attrs={'class': 'form-control'}), 'tags': forms.TextInput(attrs={'class': 'form-control'}), 'text': SummernoteInplaceWidget(), 'text_min': SummernoteInplaceWidget(), 'description': forms.TextInput(attrs={'class': 'form-control'}), 'image': forms.FileInput(attrs={'class': 'form-control'}), }
class Meta: model = Entry fields = ['text', 'microch', 'current', 'voltage', 'wd', 'ss', 'diaf', 'hs', "n", 'exp_time', 'dose', 'exp_size', 'num_dots', 'micro_adv', 'resist', 'resist_rpm', 'resist_time', 'dry_type', 'dry_temp', 'dry_time', 'dev', 'dev_time', 'ref', 'ref_temp', 'ref_time', 'tr_rec', 'tr_time', 'tr_vel', 'pyth', 'gds', 'body'] labels = {'text': 'Описание партии'} widgets = {'body': SummernoteInplaceWidget()}
class SubmissionForm(forms.Form): comment_text = forms.CharField(label='', required=False, widget=SummernoteInplaceWidget()) attachments = RestrictedFileFormField(required=False, max_upload_size=16777216, widget=forms.ClearableFileInput(attrs={'multiple': True}), label="Attach files", help_text="Hold Ctrl to select multiple files, 16MB limit per file")
class RecipeAdmin(admin.ModelAdmin): model = Recipe formfield_overrides = { models.TextField: {'widget': SummernoteInplaceWidget()}, } inlines = [ IngredientInline, RecipeStepInline, ]