예제 #1
0
 def test_tinymce_widget(self):
     widget = TinyMCE()
     html = widget.render(
         'foobar', 'lorem ipsum', attrs={'id': 'id_foobar'}
     )
     self.assertIn('id="id_foobar"', html)
     self.assertIn('name="foobar"', html)
     self.assertIn('lorem ipsum', html)
     self.assertIn('class="tinymce"', html)
예제 #2
0
 class Meta:
     model = Article
     fields = [
         'title',
         'subtitle',
         'slug',
         'body',
         'featured_image',
         'featured_image_caption',
         'status',
     ]
     widgets = {
         'body': TinyMCE(attrs={
             'cols': 25,
             'rows': 3
         }),
     }
예제 #3
0
class TutorialAdmin(admin.ModelAdmin):

    fieldsets = [('Title/date', {
        'fields': ['tutorial_title', 'tutorial_published']
    }), ('URL', {
        'fields': ['tutorial_slug']
    }), ('Series', {
        'fields': ['tutorial_series']
    }), ('Content', {
        'fields': ['tutorial_content']
    })]

    formfield_overrides = {
        models.TextField: {
            'widget': TinyMCE()
        },
    }
예제 #4
0
class TutorialAdmin(admin.ModelAdmin):
    #fields = ["tutorial_title",  "tutorial_published", "tutorial_content"]
    fieldsets = [
        ("Title/date", {
            "fields": ["tutorial_title", "tutorial_published"]
        }),
        ("URL", {
            "fields": ["tutorial_slug"]
        }),
        ("Series", {
            "fields": ["tutorial_series"]
        }),
        ("Content", {
            "fields": ["tutorial_content"]
        }),
    ]
    formfield_overrides = {models.TextField: {'widget': TinyMCE()}}
예제 #5
0
class TutorialAdmin(admin.ModelAdmin):
    fieldsets = (
        ("Title/date", {
            "fields": ("tutorial_title", "tutorial_published")
        }),
        ("URL", {
            "fields": ("tutorial_slug", )
        }),
        ("Series", {
            "fields": ("tutorial_series", )
        }),
        ("Content", {
            "fields": ("tutorial_content", )
        }),
    )

    formfield_overrides = {models.TextField: {"widget": TinyMCE()}}
예제 #6
0
class PostAdmin(admin.ModelAdmin):

    fieldsets = [("Title/date", {
        'fields': ["title", "created_on"]
    }), ("Content", {
        'fields': ["body"]
    }), ("Category", {
        'fields': ["categories"]
    }), ("Byline", {
        "fields": ["author"]
    })]

    formfield_overrides = {
        models.TextField: {
            'widget': TinyMCE()
        },
    }
예제 #7
0
class TinyMCEForm(forms.Form):
    content = forms.CharField(widget=TinyMCE())

    def __init__(self, *args, **kwargs):
        super(TinyMCEForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_show_labels = False
        self.helper.form_method = 'post'
        self.helper.form_action = reverse('portfolio:tinymce',
                                          args=('django-tinymce', ))

        self.helper.layout = Layout(
            HTML(
                _("<h4>Django-tinymce.</h4><p>&quot;Django-tinymce&quot; is a Django application that contains a widget to render a form field as a TinyMCE editor. It uses TinyMCE editor 3.5.11. Current version of TinyMCE editor is TinyMCE&nbsp;4.5.x. and you need only two scripts in HEAD section of HTML document <a href=\"{% url 'portfolio:tinymce' 'tinymce4' %}\">to convert</a> any your field in rich text editor.</p>"
                  )),
            'content',
        )
예제 #8
0
파일: admin.py 프로젝트: tutorexchange/OUGC
class TournamentAdmin(admin.ModelAdmin):

    fieldsets = [("Title/date", {
        'fields': ["tournament_title", "tournament_published"]
    }), ("URL", {
        "fields": ["tournament_slug"]
    }), ("Series", {
        "fields": ["tournament_series"]
    }), ("Content", {
        "fields": ["tournament_content"]
    })]

    formfield_overrides = {
        models.TextField: {
            'widget': TinyMCE()
        },
    }
예제 #9
0
 class Meta:
     model = models.Competition
     fields = ('title', 'description', 'force_submission_to_leaderboard',
               'image', 'has_registration', 'end_date', 'published')
     widgets = {
         'description':
         TinyMCE(attrs={
             'rows': 20,
             'class': 'competition-editor-description'
         },
                 mce_attrs={
                     "theme": "advanced",
                     "cleanup_on_startup": True,
                     "theme_advanced_toolbar_location": "top",
                     "gecko_spellcheck": True
                 })
     }
예제 #10
0
class CandidateAdmin(admin.ModelAdmin):

    list_display = ('full_name', 'position', 'state', 'party', 'election', 'position', 'votes')
    # Non-editable fields
    readonly_fields = ('votes',)

    fieldsets = [
        ('CANDIDATE INFO', {
            'fields': ('election', 'position', 'full_name', 'state', 'party', 'description', 'website', 'avatar',),
        }
        ),
    ]

    formfield_overrides = {
        models.TextField: {'widget': TinyMCE(attrs={'cols': 80, 'rows': 30})},
        # forms.ChoiceField: {'choices': ('President', 'Vice President', 'Secretary', 'Treasurer')},
    }
예제 #11
0
class master_coursesAdmin(admin.ModelAdmin):
    fieldsets = [
        ("Titles/Duration/Image", {
            "fields": ["course_title", "course_duration"]
        }),
        ("URL", {
            "fields": ["course_slug"]
        }),
        ("Series", {
            "fields": ["course_series"]
        }),
        ("Contents", {
            "fields": ["course_contents"]
        }),
    ]

    formfield_overrides = {models.TextField: {'widget': TinyMCE()}}
예제 #12
0
 class Meta:
     model = Vacancy
     fields = ('title', 'specialty', 'skills', 'description', 'salary_min',
               'salary_max')
     labels = {
         'title': 'Название вакансии',
         'specialty': 'Специализация',
         'skills': 'Требуемые навыки',
         'description': 'Описание вакансии',
         'salary_min': 'Зарплата от',
         'salary_max': 'Зарплата до',
     }
     widgets = {
         'skills':
         Textarea(attrs={'rows': 2}),
         'description':
         TinyMCE(
             attrs={
                 'cols': 80,
                 'rows': 14,
                 'maxwidth': 678
             },
             mce_attrs={
                 'width':
                 678,
                 'menubar':
                 False,
                 'toolbar2':
                 "",
                 'toolbar1':
                 '''
                        bold italic underline | fontselect,
                        fontsizeselect | forecolor backcolor | alignleft alignright aligncenter alignjustify |
                         bullist numlist | link image
                        ''',
                 'plugins':
                 '''
                         textcolor save link image media contextmenu
                         lists insertdatetime nonbreaking
                         contextmenu directionality searchreplace wordcount visualblocks
                         visualchars code autolink lists charmap print hr
                         anchor pagebreak
                         ''',
             },
         ),
     }
예제 #13
0
class FormCreatePost(forms.Form):
    judul_artikel = forms.CharField()
    isi_artikel = forms.CharField(widget=TinyMCE(attrs={
        'cols': 80,
        'rows': 30
    }))

    def __init__(self, *args, **kwargs):
        super(FormCreatePost, self).__init__(*args, **kwargs)
        self.fields['judul_artikel'].widget.attrs.update({
            'style':
            'margin-bottom:20px;',
            'class':
            'form-widget pure-u-1-2',
            'placeholder':
            'Masukkan Judul Artikel'
        })
예제 #14
0
class CreateScenarioForm(forms.Form):
    title = forms.CharField(
        label='Title',
        max_length=130,
        help_text=
        'This Scenario\'s title. This may be seen by people who have not played the Scenario.'
    )
    summary = forms.CharField(
        label='Summay',
        max_length=400,
        required=False,
        help_text=
        "Summarize the Scenario so that people who have already played it can recognize it."
    )
    description = forms.CharField(
        label='Write-up',
        widget=TinyMCE(attrs={
            'cols': 80,
            'rows': 30
        }),
        max_length=70000,
        help_text=
        'Describe the Scenario in detail. Win conditions, enemies, background, etc.'
    )
    max_players = forms.IntegerField(label="Max Players", initial=4)
    min_players = forms.IntegerField(label="Minimum Players", initial=2)
    suggested_character_status = forms.ChoiceField(
        label="Required Status",
        choices=HIGH_ROLLER_STATUS,
        help_text='Must be this tall to ride')
    is_highlander = forms.BooleanField(
        label="Highlander",
        required=False,
        help_text="Only one Contractor can achieve victory")
    is_rivalry = forms.BooleanField(
        label="Rivalry",
        required=False,
        help_text="The Contractors may have different or opposing goals")
    requires_ringer = forms.BooleanField(
        label="Requires Ringer",
        required=False,
        help_text="One Player must play an NPC instead of their Contractor")
    tags = forms.ModelMultipleChoiceField(
        queryset=ScenarioTag.objects.order_by("tag").all(),
        required=False,
        widget=forms.CheckboxSelectMultiple)
예제 #15
0
    class Admin(admin.ModelAdmin):
        list_display = (
            'titulo',
            'publicacao',
        )
        #list_filter = ('nome', )
        ordering = ('titulo', )
        #search_fields = ('codigo', )

        formfield_overrides = {
            models.TextField: {
                'widget': TinyMCE(attrs={
                    'cols': 80,
                    'rows': 30
                }),
            }
        }
예제 #16
0
class TutorialAdmin(admin.ModelAdmin):
    # fields = ['published','title','content']

    fieldsets = [("Title/date", {
        'fields': ['title', 'published']
    }), ("URL", {
        'fields': ['slug']
    }), ("Series", {
        'fields': ['series']
    }), ("Content", {
        'fields': ['content']
    })]
    formfield_overrides = {
        models.TextField: {
            'widget': TinyMCE()
        },
    }
예제 #17
0
class CakeAdmin(admin.ModelAdmin):

    fieldsets = [("Title/date", {
        'fields': ["cake_title", "cake_id"]
    }), ("Content", {
        "fields": ["cake_content"]
    }), ("Image", {
        "fields": ["photo"]
    }), ("amount", {
        "fields": ["amount"]
    })]

    formfield_overrides = {
        models.TextField: {
            'widget': TinyMCE()
        },
    }
class TutorialAdmin(admin.ModelAdmin):
    ##  benefit if you want to edit only some fields and rest are default so in that case you  can define 
    # what colums you want to show in admin panel 
    # fields =["tutorial_title",
    # "tutorial_publish",
    # "tutorial_content"]
    ### clustering in admin panel 
    fieldsets = [
        ("Title/date",{"fields":["tutorial_title","tutorial_published"]}),

        ("URL",{"fields":["tutorial_slug"]}),
        ("Series",{"fields":["tutorial_series"]}),
        ("Content",{"fields":["tutorial_content"]})
    ]
    formfield_overrides={
        models.TextField:{'widget': TinyMCE()}
    }
예제 #19
0
class CoreFlatPageForm(forms.ModelForm):
    """Override form to allow tinyMCE for content field"""

    content = forms.CharField(
        widget=TinyMCE(
            attrs={
                'cols': 80,
                'rows': 30,

            },
            content_language=translation.get_language()
        )
    )

    class Meta:
        model = CoreFlatPage
        fields = '__all__'
예제 #20
0
class ProtocolStepsAdmin(admin.ModelAdmin):
    list_display = [
        'protocol',
        'label',
        'order',
    ]
    search_fields = [
        'protocol',
        'label',
    ]
    list_filter = []
    list_editable = [
        'order',
    ]
    ordering = [
        'protocol',
        'label',
    ]
    fieldsets = (
        ('Parameter', {
            'fields': (
                'label',
                'protocol',
                'order',
            )
        }),
        ('Durchführung', {
            'fields': (
                'execution',
                'executionParameter',
            )
        }),
        ('Bild', {
            'fields': ('image', )
        }),
    )
    filter_horizontal = [
        'executionParameter',
    ]
    radio_fields = {}
    formfield_overrides = {
        models.TextField: {
            'widget': TinyMCE()
        },
    }
예제 #21
0
 class Meta:
     model = User
     fields = (
         'participation_status_updates',
         'organizer_status_updates',
         'organizer_direct_message_updates',
         'organization_or_affiliation',
         'email_on_submission_finished_successfully',
         'team_name',
         'team_members',
         'method_name',
         'method_description',
         'contact_email',
         'project_url',
         'publication_url',
         'bibtex',
         'first_name',
         'last_name',
         'email',
         'public_profile',
         'biography',
         'webpage',
         'linkedin',
         'ORCID',
         'image',
     )
     widgets = {
         'team_members':
         forms.Textarea(attrs={"class": "form-control"}),
         'method_description':
         forms.Textarea(attrs={"class": "form-control"}),
         'bibtex':
         forms.Textarea(attrs={"class": "form-control"}),
         'biography':
         TinyMCE(attrs={
             'rows': 20,
             'class': 'competition-editor-description'
         },
                 mce_attrs={
                     "theme": "advanced",
                     "cleanup_on_startup": True,
                     "theme_advanced_toolbar_location": "top",
                     "gecko_spellcheck": True
                 })
     }
예제 #22
0
파일: forms.py 프로젝트: jetlyb/Kiwi
class BasePlanForm(forms.Form):
    name = forms.CharField(label="Plan name")
    type = forms.ModelChoiceField(
        label="Type",
        queryset=TestPlanType.objects.all(),
        empty_label=None,
    )
    text = forms.CharField(label="Plan Document",
                           widget=TinyMCE(),
                           required=False)
    product = forms.ModelChoiceField(
        label="Product",
        queryset=Product.objects.all(),
        empty_label=None,
    )
    product_version = forms.ModelChoiceField(
        label="Product Version",
        queryset=Version.objects.none(),
        empty_label=None,
    )
    extra_link = StripURLField(label='Extra link',
                               max_length=1024,
                               required=False)
    env_group = forms.ModelChoiceField(
        label="Environment Group",
        queryset=TCMSEnvGroup.get_active().all(),
        required=False)
    parent = forms.IntegerField(required=False)

    owner = forms.CharField(label="Plan Document", required=False)

    def clean_parent(self):
        try:
            p = self.cleaned_data['parent']
            if p:
                return TestPlan.objects.get(pk=p)
        except TestPlan.DoesNotExist:
            raise forms.ValidationError('The plan does not exist in database.')

    def populate(self, product_id):
        if product_id:
            self.fields['product_version'].queryset = Version.objects.filter(
                product__id=product_id)
        else:
            self.fields['product_version'].queryset = Version.objects.all()
예제 #23
0
def profile(request):
    if request.method == 'POST':
        # uploaded_pic = request.FILES['profile_image2']
        profile_form = ProfileFrom(request.POST, instance=request.user.profile)
        # profile_picture_form = ProfilePictureUpdateForm(request.POST, request.FILES, instance=request.user.profile)
        social_media_form = SocialMediaForm(request.POST, instance=request.user.profile)
        if profile_form.is_valid():
            profile_form.save(Profile.about)
            social_media_form.save(Profile.instagram)
            social_media_form.save(Profile.twitter)
            social_media_form.save(Profile.instagram)
            # profile_picture_form.save(Profile.profile_image)
            fs = FileSystemStorage()
            # fs.save(uploaded_pic)
        return redirect('profile')
    else:
        post = get_object_or_404(Profile, user_id=request.user)
        form = ProfileFrom(initial={'about': post.about, 'facebook': post.facebook, 'twitter': post.twitter,
                                    'instagram': post.instagram, 'profile_image2': post.profile_image})

        form.fields['about'].widget = TinyMCE()
        about = Profile.objects.get(user=request.user).about
        username = User.objects.get(username=request.user).username
        facebook_url = Profile.objects.get(user=request.user).facebook
        twitter_url = Profile.objects.get(user=request.user).twitter
        instagram_url = Profile.objects.get(user=request.user).instagram
        profile_pic = Profile.objects.get(user=request.user).profile_image
        pets = CreatePet.objects.filter(owner=request.user)
        paginator = Paginator(pets, 3)
        page = request.GET.get('page')
        my_pets = paginator.get_page(page)
        context = {
            'post': post,
            'form': form,
            'about': about,
            'username': username,
            'facebook_url': facebook_url,
            'twitter_url': twitter_url,
            'instagram_url': instagram_url,
            'profile_pic': profile_pic,
            'pets': my_pets,

        }

    return render(request, 'petco_account/profile.html', context)
예제 #24
0
class PaginaAdminForm(forms.ModelForm):
    contenido = forms.CharField(
        required=False,
        widget=TinyMCE(mce_attrs=customize_tinyMCE({
            'width': 980,
            'height': 600
        })))
    tags = TagField(required=False,
                    widget=LabelWidget(model=HierarchicalTag,
                                       hierarchical=True))

    def __init__(self, *args, **kwargs):
        request = self.request
        super(PaginaAdminForm, self).__init__(*args, **kwargs)
        init_gallerycon_settings()
        if 'parent_id' in request.GET:
            self.fields['parent'].initial = Pagina.objects.get(
                pk=request.GET.get('parent_id'))
예제 #25
0
class BlogForms(forms.ModelForm):
    blog_contenido = forms.CharField(widget=TinyMCE(attrs={
        'cols': 80,
        'rows': 30
    }))

    class Meta:
        model = Blog
        exclude = (
            'blog_portada',
            'blog_pertenece',
        )
        widgets = {
            'blog_descripcion': forms.Textarea(attrs={
                "rows": 3,
                "cols": 80
            }),
        }
예제 #26
0
class ShowScheduleForm(ModelForm):
    required_css_class = 'required'
    error_css_class = 'error'
    e_description = CharField(widget=TinyMCE(attrs={
        'cols': 80,
        'rows': 20
    }, ),
                              label=event_labels['e_description'])

    class Meta:
        model = Show
        fields = [
            'e_title',
            'e_description',
            'duration',
        ]
        help_texts = event_help_texts
        labels = event_labels
예제 #27
0
class PostAdmin(admin.ModelAdmin):

    fieldsets = [("Title/Slug/Author", {
        'fields': ["title", "slug", "author"]
    }), ("Content/Status", {
        "fields": ["content", "status"]
    })]

    list_display = ('title', 'slug', 'status', 'created_on')
    list_filter = ("status", )
    search_fields = ['title', 'content']
    prepopulated_fields = {'slug': ('title', )}

    formfield_overrides = {
        models.TextField: {
            'widget': TinyMCE()
        },
    }
예제 #28
0
class NewsAdmin(admin.ModelAdmin):
    list_display = ('title', 'author', 'body', 'date')
    fieldsets = ((None, {'fields': ['title', 'slug', 'body']}), )
    prepopulated_fields = {'slug': ("title", )}

    def save_model(self, request, obj, form, change):
        if not change:
            obj.author = request.user
        super(NewsAdmin, self).save_model(request, obj, form, change)

    formfield_overrides = {
        models.TextField: {
            'widget': TinyMCE(attrs={
                'cols': 80,
                'rows': 30
            })
        },
    }
예제 #29
0
class TeamMembershipAdmin(admin.ModelAdmin):
    list_display = (
        '__unicode__',
        'active',
        'captain',
    )
    list_filter = (
        'team',
        'race',
        'champion',
        'captain',
    )
    search_fields = ('char_name', )
    formfield_overrides = {
        HTMLField: {
            'widget': TinyMCE(mce_attrs={'theme': 'advanced'})
        },
    }
예제 #30
0
파일: forms.py 프로젝트: beadaut/daremo
class TopicForm(forms.ModelForm):

    title = forms.CharField(label=_("Title"), max_length=60, required=True)
    description = forms.CharField(label=_("First message"),
                                  widget=TinyMCE(
                                      attrs={
                                          'cols':
                                          80,
                                          'rows':
                                          30,
                                          'placeholder':
                                          _("Write your answer here!")
                                      },
                                      mce_attrs=TINYMCE_DEFAULT_CONFIG))

    class Meta():
        model = Topic
        fields = ('title', 'description')
예제 #31
0
class OfferForm(forms.ModelForm):
    description = forms.CharField(widget=TinyMCE(attrs={
        'cols': 80,
        'rows': 30
    }),
                                  label=u'Descrição')
    delivery = forms.BooleanField(initial=False,
                                  label='Entrega',
                                  required=False)
    shipping = forms.BooleanField(initial=False, label='Frete', required=False)

    class Meta:
        model = Offer
        fields = ('title', 'slug', 'highlight', 'highlight_image',
                  'image_grid', 'subcategory', 'delivery', 'shipping',
                  'interests', 'affiliate', 'bought', 'bought_virtual',
                  'max_by_user', 'percent_by_site', 'percent_cashback', 'city',
                  'description', 'when_to_use', 'how_to_use', 'good_to_know')
예제 #32
0
def test_custom_profile(settings):
    w = TinyMCE(profile={'toolbar': ''})
    output = w.render('content', '', {'id': 'content'})
    custom_output = u'<textarea cols="40" id="content" name="content" rows="10"></textarea>\n<script type="text/javascript">tinyMCE.init({"toolbar": "", "selector": "#content"})</script>'
    assert output == custom_output
예제 #33
0
def test_widget(settings):
    w = TinyMCE(profile=None)
    output = w.render('content', '', {'id': 'content'})
    default_output = u'<textarea cols="40" id="content" name="content" rows="10"></textarea>\n<script type="text/javascript">tinyMCE.init({"theme": "modern", "selector": "#content", "toolbar": "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons", "plugins": "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking save table contextmenu directionality emoticons template paste textcolor"})</script>'
    assert output == default_output