示例#1
0
    def test_custom_upload_parameters(self):
        widget = RedactorEditor()
        rendered = widget.render('text', 'text', attrs={'id': 'test_id'})
        self.assertIn('"fileUpload": "/upload/file/"', rendered)

        widget = RedactorEditor(
            redactor_options={'fileUpload': '/another_url/'})
        rendered = widget.render('text', 'text', attrs={'id': 'test_id'})
        self.assertIn('"fileUpload": "/another_url/"', rendered)
示例#2
0
文件: admin.py 项目: adilkhash/notion
    class Meta:
        model = Note
        fields = ['title', 'slug', 'text', 'lang', 'status', 'theme']
        widgets = {
           'text': RedactorEditor(redactor_options={
               'plugins': ['table'],

           }),
        }
示例#3
0
class PostForm(forms.Form):
    title = forms.CharField(widget=forms.TextInput(
        attrs={
            'placeHolder': 'Tiêu đề...',
            'class': 'form-control'
        }))
    content = forms.CharField(widget=RedactorEditor(
        attrs={
            'placeHolder': 'Bạn muốn chia sẻ gì...',
        }))
示例#4
0
 class Meta:
     model = Service
     widgets = {
         'statement': Textarea(attrs={
             'cols': 80,
             'rows': 30
         }),
         'description': RedactorEditor(),
     }
     fields = '__all__'  #
示例#5
0
 def __init__(self, *args, **kwargs):
     options = kwargs.pop('redactor_options', {})
     upload_to = kwargs.pop('upload_to', '')
     allow_file_upload = kwargs.pop('allow_file_upload', True)
     allow_image_upload = kwargs.pop('allow_image_upload', True)
     self.widget = RedactorEditor(redactor_options=options,
                                  upload_to=upload_to,
                                  allow_file_upload=allow_file_upload,
                                  allow_image_upload=allow_image_upload)
     super(RedactorField, self).__init__(*args, **kwargs)
示例#6
0
 class Meta:
     model = Diler_Otdel
     widgets = {
         'text_diler_otdel': RedactorEditor(),
     }
     fields = ("text_diler_otdel", "is_active", "phone_1_for_do",
               "text_phone_1_for_do", "phone_2_for_do",
               "text_phone_2_for_do", "phone_3_for_do",
               "text_phone_3_for_do", "time_work_b", "time_work_b_time",
               "time_work_s", "time_work_s_time", "time_work_v",
               "time_work_v_time", "title", "keyword", "description")
示例#7
0
 class Meta:
     model = m.Advertisement
     exclude = ['created_by']
     widgets = {
         'category':
         forms.Select(attrs={'class': 'form-control'}),
         'title':
         forms.TextInput(attrs={'class': 'form-control'}),
         'body':
         RedactorEditor(allow_file_upload=False, allow_image_upload=False),
     }
示例#8
0
 class Meta:
     model = FAQ
     widgets = {
         'note': Textarea(
             attrs={
                 'cols': 80,
                 'rows': 20
             }
         ),  #CKEditorWidget(),#AdminWYMEditorArea(),#Textarea(attrs={'class':'ckeedior','cols': 80, 'rows': 30}),
         'answer': RedactorEditor(),
     }
     fields = '__all__'  #
示例#9
0
 class Meta:
     model = MakerScienceStaticContent
     widgets = {
         'about': RedactorEditor(),
         'about_howitworks': RedactorEditor(),
         'about_team': RedactorEditor(),
         'about_contact': RedactorEditor(),
         'about_faq': RedactorEditor(),
         'about_cgu': RedactorEditor(),
         'mentions': RedactorEditor(),
     }
示例#10
0
 class Meta:
     widgets = {
         'content':
         RedactorEditor(
             redactor_settings={
                 'formattingTags':
                 ['p', 'blockquote', 'pre', 'h2', 'h3', 'h4', 'h5', 'h6'],
                 'buttons': [
                     'formatting', 'bold', 'italic', 'deleted', 'image',
                     'unorderedlist', 'orderedlist', 'link', 'html'
                 ]
             })
     }
示例#11
0
 class Meta():
     model = Post
     fields = ('title', 'feature', 'text')
     labels = {
         'title': 'Title',
         'feature': 'Feature Image',
         'text': 'Content',
     }
     widgets = {
         'title': forms.TextInput(attrs={'class': 'titleinputclass'}),
         'feature': forms.ClearableFileInput(attrs={'class': 'featinput'}),
         'text': RedactorEditor()
         # 'text':CKEditorUploadingWidget(attrs={'class':'contentinput'}),
     }
示例#12
0
    def test_custom_upload_parameters(self):
        widget = RedactorEditor()
        rendered = widget.render('text', 'text', attrs={'id': 'test_id'})
        self.assertIn('"fileUpload": "/upload/file/"', rendered)

        widget = RedactorEditor(
            redactor_options={'fileUpload': '/another_url/'})
        rendered = widget.render('text', 'text', attrs={'id': 'test_id'})
        self.assertIn('"fileUpload": "/another_url/"', rendered)
示例#13
0
 class Meta:
     model = Activity
     fields = '__all__'
     widgets = {
         'description': RedactorEditor(),
         'contact_info': RedactorEditor(),
         'register_info': RedactorEditor(),
         'address': RedactorEditor(),
         'transportation': RedactorEditor(),
         'accommodation': RedactorEditor(),
     }
示例#14
0
文件: forms.py 项目: sergiorb/askkit
    class Meta:
        model = Question
        fields = [
            'question',
            'context',
            'date_begin',
            'date_end',
            'allow_anonymous_voter',
            'data_require_vote',
            'hide_data',
            'public',
            'asker',
            'fromIp',
        ]
        exclude = ['hide_data', 'asker', 'fromIp']

        labels = {
            'question': _('Question title:'),
            'context': _('Write something more:'),
            'date_begin': _('Open vote in:'),
            'date_end': _('Close vote in:'),
            'allow_anonymous_voter': _('Allow anonymous vote.'),
            'data_require_vote': _('Require vote to show charts.'),
            'hide_data': _('Hide chart.'),
            'public': _('Shown in \'Random question\'.'),
        }

        widgets = {
            'date_begin':
            DateTimeWidget(usel10n=True, bootstrap_version=3),
            'date_end':
            DateTimeWidget(usel10n=True, bootstrap_version=3),
            'context':
            RedactorEditor(allow_file_upload=False,
                           allow_image_upload=False,
                           attrs={
                               'rows': '2',
                               'cols': '2',
                           }),
            #'asker': forms.HiddenInput(),
            #'fromIp': forms.HiddenInput(),
        }
示例#15
0
class ReviewForm(BetterModelForm):
    description = forms.CharField(
        widget=RedactorEditor(attrs={'placeholder': 'Текст отзыва'}),
        label='Текст отзыва',
        required=True)

    class Meta:
        model = Review
        fields = ('title', 'description', 'active')
        fieldsets = [
            ('main', {
                'fields': ['title', 'active'],
                'legend': ''
            }),
            ('description', {
                'fields': ['description'],
                'legend': 'Описание',
                'classes': ['description']
            }),
        ]
示例#16
0
class MaterialForm(ModelForm):
    text = forms.CharField(widget=RedactorEditor())
    status = forms.CharField(
        min_length=1,
        max_length=1000,
    )

    class Meta:
        model = Material
        exclude = [
            'owner', 'date_publication', 'date_creation', 'rating',
            'karma_users', 'material_edit', 'if_comments'
        ]

    def save_with_owner(self, *args, **kwargs):
        owner = kwargs.pop('owner')
        obj = super(MaterialForm, self).save(commit=False)
        obj.owner = owner
        obj.save()
        return obj
示例#17
0
class PartyForm(ModelForm):
    text = forms.CharField(widget=RedactorEditor())
    date_time_start = forms.DateTimeField()
    date_time_finish = forms.DateTimeField()

    class Meta:
        model = Party
        exclude = [
            'date_creation',
            'files',
            'category',
            'image',
            'files',
        ]

    def save_with_owner(self, *args, **kwargs):
        owner = kwargs.pop('owner')
        obj = super(BlogPostForm, self).save(commit=False)
        obj.owner = owner
        obj.save()
        return obj
示例#18
0
class BlogPostForm(ModelForm):
    text = forms.CharField(widget=RedactorEditor())

    class Meta:
        model = BlogPost
        exclude = [
            'owner',
            'date_publication',
            'image',
            'default_image',
            'date_creation',
            'rating',
            'blog_edit',
            'karma_users',
            'files',
        ]

    def save_with_owner(self, *args, **kwargs):
        owner = kwargs.pop('owner')
        obj = super(BlogPostForm, self).save(commit=False)
        obj.owner = owner
        obj.save()
        return obj
示例#19
0
class BeritaAdminForm(forms.ModelForm):

    judul = forms.CharField(widget=forms.TextInput(attrs={
        'class': 'form-control',
        'placeholder': 'Judul'
    }))

    isi = forms.CharField(widget=RedactorEditor(redactor_options={
        'minHeight': '400px',
        'autoformat': True
    }))

    gambar = forms.FileField(widget=forms.FileInput(
        attrs={'class': 'form-control'}))

    tanggal = forms.DateField(widget=forms.DateInput(attrs={
        'class': 'form-control',
        'type': 'date'
    }))

    class Meta:
        model = Berita
        fields = ('judul', 'gambar', 'tanggal', 'isi')
示例#20
0
    class Meta:
        model = Report
        fields = [
            'subject',
            'name',
            'email',
            'message',
        ]
        exclude = [
            'status',
            'token',
            'asker',
            'date',
        ]

        widgets = {
            'message':
            RedactorEditor(allow_file_upload=False,
                           allow_image_upload=False,
                           attrs={
                               'rows': '2',
                               'cols': '2',
                           }),
        }
示例#21
0
 class Meta:
     model = Post
     widgets = {'content': RedactorEditor()}
示例#22
0
 def __init__(self, *args, **kwargs):
     options = kwargs.pop('redactor_options', {})
     upload_to = kwargs.pop('upload_to', '')
     self.widget = RedactorEditor(redactor_options=options, upload_to=upload_to)
     super(RedactorField, self).__init__(*args, **kwargs)
示例#23
0
class PageForm(forms.ModelForm):
    title = forms.CharField()
    slug = forms.CharField()
    content = forms.CharField(widget=RedactorEditor(allow_file_upload=False,
                                                    allow_image_upload=False))
示例#24
0
 class Meta:
     model = FlatPage
     widgets = {'content': RedactorEditor()}
示例#25
0
 class Meta:
     model = Post
     fields = '__all__'
     widgets = {'body': RedactorEditor(), }
示例#26
0
    def __init__(self, *args, **kwargs):
        super(ThingForm, self).__init__(*args, **kwargs)
        if 'id' in self.fields:
            del self.fields['id']
        if 'json' in self.fields:
            del self.fields['json']
        if "content_type_id" in self.fields:
            if not self.instance.pk:
                del self.fields['content_type_id']
            else:
                choices = [(i.content_type().pk, i.content_type().name.title())
                           for i in Thing.__subclasses__()]
                self.fields['content_type_id'] = forms.ChoiceField(
                    required=True,
                    choices=choices,
                    label="Thing Type",
                    initial=self.instance.content_type().pk)

        if "creator" in self.fields:
            del self.fields['creator']
        # published_at field is re-added at the end to be last.
        if 'published_at' in self.fields:
            del self.fields['published_at']

        for f in self.instance.attrs:

            key = f['key']
            if key not in self.fields:
                # Add the field to the form
                if "form_field" in f:
                    self.fields[key] = f['form_field']
                else:
                    if f['datatype'] == TYPE_BOOLEAN:
                        self.fields[key] = forms.BooleanField(required=False)
                    elif f['datatype'] == TYPE_DATE:
                        self.fields[key] = forms.DateTimeField(
                            widget=AdminSplitDateTime)
                    elif f['datatype'] == TYPE_FILE:
                        self.fields[key] = forms.FileField(
                            required=False, widget=forms.ClearableFileInput)
                    elif f['datatype'] == TYPE_FOREIGNKEY:
                        choices = [(i.pk, i.name)
                                   for i in f['model'].objects.all()]
                        self.fields[key] = forms.ChoiceField(required=False,
                                                             choices=choices)
                    else:
                        self.fields[key] = forms.CharField(required=False)

            # Set the label
            if "name" in f:
                self.fields[key].label = f['name']
            else:
                self.fields[key].label = f['key']

            # Set the required status
            if "required" in f:
                self.fields[key].required = f['required']
            else:
                self.fields[key].required = False

            # Set the disabled status
            if "editable" in f:
                if not f['editable']:
                    self.fields[key].widget.attrs['disabled'] = 'disabled'

            # Set the widget if it's defined
            if "form_widget" in f:
                self.fields[key].widget = f['form_widget']
            elif f['datatype'] == TYPE_LONGTEXT:
                self.fields[key].widget = RedactorEditor()

            # Populate help text if it's defined
            if not self.fields[key].help_text:
                if "help_text" in f:
                    self.fields[key].help_text = f['help_text']
                elif "description" in f:
                    # Auto-create the description if using a shared field
                    if "{{ model }}" in f['description']:
                        self.fields[key].help_text = f['description'].replace(
                            "{{ model }}",
                            self.instance.obj_type().title())
                    else:
                        self.fields[key].help_text = f['description']
                else:
                    self.fields[key].help_text = "The %s of the %s" % (
                        f['name'], self.instance.obj_type().title())

            # Grab the attribute and try to prepopulte the initial
            # if there is a value.
            attr = self.instance.get_val(f)
            if attr:
                if f['datatype'] == TYPE_FOREIGNKEY:
                    attr = attr.pk
                self.fields[key].initial = attr

        self.fields['published_at'] = forms.DateTimeField(
            label="Published",
            widget=AdminSplitDateTime,
            required=False,
            help_text=
            "This field controls both the order of the item and whether it's publicly viewable. If the publish date is in the future or not set, this item won't be viewable to logged out viewers"
        )
示例#27
0
    def __init__(self, *args, **kwargs):
        super(BlogAdminForm, self).__init__(*args, **kwargs)

        self.fields['content'].widget = RedactorEditor()
示例#28
0
 class Meta:
     model = models.Education
     widgets = {
         'summary': RedactorEditor(),
     }
     fields = "__all__"
示例#29
0
 class Meta:
     model = models.Job
     widgets = {
         'description': RedactorEditor(),
     }
     fields = "__all__"
示例#30
0
 class Meta:
     model = models.Project
     widgets = {
         'summary': RedactorEditor(),
     }
     fields = "__all__"
示例#31
0
 class Meta:
     model = Post
     fields = '__all__'
     widgets = {
         'content': RedactorEditor()
     }