Esempio n. 1
0
class BbsForm(forms.Form):
    title = forms.CharField(
        max_length=200,
        help_text='请输入文章标题:',
        widget=forms.TextInput(attrs={'class': 'article_title'}))
    summary = forms.CharField(
        max_length=300,
        help_text='请输入文章简介:',
        widget=forms.TextInput(attrs={'class': 'article_summary'}))
    content = forms.CharField(widget=CKEditorUploadingWidget(
        config_name='bbs_ckeditor'))

    def __init__(self, *args, **kwargs):
        if 'user' in kwargs:
            self.user = kwargs.pop('user')
        super(BbsForm, self).__init__(*args, **kwargs)

    def clean(self):
        # 判断用户是否登录
        if self.user.is_authenticated:
            self.cleaned_data['user'] = self.user
        else:
            raise forms.ValidationError('用户尚未登录!')
Esempio n. 2
0
class EditEventForm(forms.Form):
    event_edit_description = RichTextUploadingFormField(
        widget=CKEditorUploadingWidget())
    event_edit_title = forms.CharField(
        max_length=30,
        widget=forms.TextInput(attrs={
            'class': 'form-control',
            'placeholder': 'Событие'
        }))
    event_edit_time = forms.TimeField(widget=forms.TimeInput(
        attrs={
            'form': 'edit_todo_form',
            'class': 'form-control',
            'type': 'time'
        }))
    event_edit_deadline = forms.DateField(widget=forms.DateInput(
        attrs={
            'form': 'edit_todo_form',
            'class': 'form-control',
            'type': 'date'
        }))
    event_id = forms.IntegerField(widget=forms.HiddenInput())
    is_public = forms.BooleanField()
Esempio n. 3
0
class CategoryAdminForm(forms.ModelForm):
    readonly_fields = ('slug', )
    slug = forms.CharField(widget=forms.HiddenInput(),
                           initial=utils.generate_slug())
    description = forms.CharField(widget=CKEditorUploadingWidget(
        config_name='default'))

    class Meta:
        model = Category
        fields = '__all__'
        exclude = [PostCategory, CategoryProductAttribute, CategoryProduct]

    file = forms.FileField(required=False, label='Upload an image')

    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop('request', None)
        super(CategoryAdminForm, self).__init__(*args, **kwargs)

    def clean(self):
        from django.utils.html import strip_tags
        cleaned_data = super(CategoryAdminForm, self).clean()
        cleaned_data['name'] = strip_tags(cleaned_data.get('name'))
        return cleaned_data
Esempio n. 4
0
 def __init__(self, *args, **kwargs):
     super(ArticleAddForm, self).__init__(*args, **kwargs)
     self.fields[
         'category'].help_text = 'Pilih Kategori Artikel *(bisa lebih dari 1)'
     self.fields['category'].widget.attrs[
         'style'] = 'width:100%; padding:10px'
     self.fields['title'].widget.attrs['style'] = 'width:100%; padding:10px'
     self.fields['is_featured'].widget.attrs[
         'style'] = 'margin:10px 10px 0 0'
     self.fields['is_featured'].widget.attrs['data-toggle'] = 'toggle'
     self.fields['is_published'].widget.attrs[
         'style'] = 'margin:10px 10px 0 0'
     self.fields['is_published'].widget.attrs['data-toggle'] = 'toggle'
     self.fields['lead_in'].widget = forms.Textarea()
     self.fields['lead_in'].widget.attrs['rows'] = '3'
     self.fields['lead_in'].widget.attrs[
         'style'] = 'width:100%; padding:10px'
     self.fields['lead_in'].widget.attrs['placeholder'] = ''
     self.fields['content'].widget = CKEditorUploadingWidget()
     self.fields['tags'].widget.attrs['style'] = 'width:100%; padding:10px'
     self.fields[
         'tags'].help_text = 'Bisa lebih dari 1, pisahkan dengan koma ( , )'
     self.fields['tags'].required = False
Esempio n. 5
0
class StoicForm(forms.ModelForm):
    content = forms.CharField(label='Рассуждение',
                              widget=CKEditorUploadingWidget())

    class Meta:
        model = Stoic
        # fields = '__all__'
        fields = ['title', 'content', 'is_published', 'month']
        widgets = {
            'title': forms.TextInput(attrs={'class': 'form-control'}),
            'content': forms.Textarea(attrs={
                'class': 'form-control',
                'rows': 5
            }),
            'month': forms.Select(attrs={'class': 'form-control'}),
        }
#очищаем данные

    def clean_title(self):
        title = self.cleaned_data['title']
        if re.match(r'\d', title):
            raise ValidationError('Название не должно начинаться с цифры')
        return title
Esempio n. 6
0
    class Meta:

        model = NoticeBoard

        fields = [
            'title',
            'text',
        ]

        widgets = {
            'title':
            forms.TextInput(
                attrs={
                    'class': 'form-control',
                    'style': 'width: 66%',
                    'placeholder': '제목을 입력하세요.'
                }),
            # 'author': forms.Select(
            #     attrs={'class': 'custom-select'},
            # ),
            'text':
            forms.CharField(widget=CKEditorUploadingWidget()),
        }
Esempio n. 7
0
    class Meta:
        model = Blog

        fields = ['title', 'pub_date', 'body']

        widgets = {
            'title':
            forms.TextInput(
                attrs={
                    'class': 'form-control',
                    'style': 'width: 100%',
                    'placeholder': '제목을 입력하세요.'
                }),
            'pub_date':
            forms.TextInput(
                attrs={
                    'class': 'form-control',
                    'style': 'width: 100%',
                    'placeholder': '작성일짜를 입력하세요.'
                }),
            'body':
            forms.CharField(widget=CKEditorUploadingWidget()),
        }
Esempio n. 8
0
class AddEventForm(forms.Form):
    """!
        @brief Form that handles user's event for writing to DB
    """
    date = forms.DateField(widget=forms.DateInput(attrs={
        'form': 'add_event_form',
        'type': 'date'
    }))
    time = forms.TimeField(widget=forms.TimeInput(attrs={
        'form': 'add_event_form',
        'type': 'time'
    }))
    title = forms.CharField(max_length=256,
                            widget=forms.TextInput(
                                attrs={
                                    'class': 'form-control',
                                    'placeholder': 'Мероприятиеюшка',
                                    'type': 'name'
                                }))
    description = RichTextUploadingFormField(widget=CKEditorUploadingWidget())
    is_public = forms.BooleanField(required=False,
                                   widget=forms.CheckboxInput(
                                       attrs={
                                           'class': 'form-check-input',
                                           'form': 'add_event_form',
                                           'type': 'checkbox'
                                       }))
    should_notify_days = forms.IntegerField(min_value=0,
                                            max_value=30,
                                            required=False)
    should_notify_hours = forms.IntegerField(min_value=0,
                                             max_value=23,
                                             required=False)
    should_notify_minutes = forms.IntegerField(min_value=0,
                                               max_value=59,
                                               required=False)
    place = forms.CharField(max_length=255, required=None)
Esempio n. 9
0
class MaghalCreateForm(forms.ModelForm):

    name = forms.ChoiceField(
        choices=PRO_CHOICES,
        widget=forms.Select(attrs={'class': 'form-control '}))

    title = forms.CharField(
        required=True,
        max_length=100,
        widget=forms.TextInput(attrs={
            'class': 'form-control ',
            'placeholder': 'تایتل',
            'id': 'hi',
        }))

    summary = forms.CharField(
        required=False,
        max_length=150,
        widget=forms.Textarea(
            attrs={
                'class':
                "form-control ",
                'placeholder':
                'لطفا یک خلاصه ای از این مقاله بزار در حد ۱۵ - 20 کلمه '
            }))

    links = forms.URLField(
        required=False,
        widget=forms.URLInput(attrs={'class': 'form-control '}))

    body = forms.CharField(label='man babatam ',
                           required=True,
                           widget=CKEditorUploadingWidget())

    class Meta:
        model = Post
        fields = '__all__'
Esempio n. 10
0
class RecipeForm(forms.ModelForm):
    long_description = forms.CharField(widget=CKEditorUploadingWidget())

    class Meta:
        model = Recipe
        fields = (
            'title',
            'image',
            'short_description',
            'long_description',
            'tags',
            'category',
        )

        widgets = {
            'title':
            forms.TextInput(attrs={
                'class': 'form-control',
                'placeholder': 'Title',
            }),
            'short_description':
            forms.Textarea(
                attrs={
                    'class': 'form-control',
                    'placeholder': 'Write short description',
                }),
            'tags':
            forms.SelectMultiple(attrs={
                'class': 'form-control',
                'placeholder': 'Tags',
            }),
            'category':
            forms.Select(attrs={
                'class': 'form-control',
                'placeholder': 'Tags',
            }),
        }
Esempio n. 11
0
class PostModeratorEditForm(forms.ModelForm):

    STATUS_UNPUBLISHED = 'unpublished'
    STATUS_ON_MODERATE = 'on_moderate'
    STATUS_NEED_REVIEW = 'need_review'
    STATUS_MODERATE_FALSE = 'moderate_false'

    STATUSES = (
        (STATUS_UNPUBLISHED, 'модерация подтверждена'),
        (STATUS_ON_MODERATE, 'на модерации'),
        (STATUS_NEED_REVIEW, 'необходимы исправления'),
        (STATUS_MODERATE_FALSE, 'модерация не пройдена'),
    )

    content = forms.CharField(label='Содержание', widget=CKEditorUploadingWidget(config_name='default'))
    status = forms.ChoiceField(choices=STATUSES, label='Статус', initial=STATUS_ON_MODERATE)
    tags_str = forms.CharField(
        label='Тэги поста:',
        max_length=200,
        required=False,
        widget=forms.TextInput(
            attrs={'size': 67, 'placeholder': 'Тэги введите через запятую', }
        )
    )

    class Meta:
        model = Post
        exclude = ('tags', 'moderated', 'moderated_at', )
        fields = ('name', 'hub_category', 'tags_str', 'status', 'user', 'moderate_desc', 'karma_count', 'content')

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field_name, field in self.fields.items():
            field.widget.attrs['class'] = 'form-control'
            field.help_text = ''
            if field_name in ('post_karma', 'karma_count', 'user'):
                field.widget = forms.HiddenInput()
Esempio n. 12
0
class QuestionForm(forms.Form):

    title = forms.CharField(label="Titre de la question",
                            max_length=1024,
                            widget=forms.TextInput(attrs={
                                'class': 'form-control',
                                'placeholder': 'Username'
                            }))

    category = forms.ModelChoiceField(
        queryset=QuestionCategory.objects.all(),
        widget=autocomplete.ModelSelect2(url='question_category_autocomplete',
                                         attrs={
                                             'class': 'form-control',
                                             'style': 'width: 100%;'
                                         }),
        label="Dans quelle catégorie situerez-vous votre question?")

    tags = forms.ModelMultipleChoiceField(
        queryset=QuestionTag.objects.all(),
        widget=autocomplete.ModelSelect2Multiple(
            url='question_tags_autocomplete',
            attrs={
                'class': 'form-control',
                'style': 'width: 100%;'
            }),
        label="Mots clés")

    details = forms.CharField(
        widget=CKEditorUploadingWidget(attrs={
            'class': 'form-control',
            'style': 'width: 80%;'
        }),
        label="Détails")

    anonymously = forms.BooleanField(
        required=False, label="Poser la question de façon anonyme")
Esempio n. 13
0
    class Meta:
        model = ProjectForCompany
        fields = (
            "name_project",
            "about_project",
            "start_date",
            "finished",
            "finish_date",
            "price"
        )

        widgets = {
            "name_project": forms.TextInput(attrs={
                "class": "form-control",
                "placeholder": "Название проекта"
            }),
            "about_project": CKEditorUploadingWidget(),
            "start_date": forms.SelectDateWidget(attrs={}),
            "finish_date": forms.SelectDateWidget(attrs={}),
            "price": forms.TextInput(attrs={
                "class": "form-control",
                "placeholder": "Стоимость"
            })
        }
Esempio n. 14
0
class addfeed_form(forms.Form):
    title = forms.CharField(
        label='Title',
        max_length=255,
        widget=forms.TextInput(attrs={
            'placeholder': 'Enter title',
            'class': 'form-control'
        }),
        required=True)
    CATEGORY_CHOICES = (
        ("NR", "New Release"),
        ("DI", "Discovery"),
        ("UP", "Update"),
        ("BF", "Bugs and Fixes"),
        ("PD", "Price Drop"),
    )
    category = forms.CharField(label='Type of Feed',
                               widget=forms.Select(
                                   attrs={'class': 'form-control'},
                                   choices=CATEGORY_CHOICES),
                               required=True)

    content = forms.CharField(label='Content',
                              widget=CKEditorUploadingWidget(),
                              required=True)

    screenshots = forms.ImageField(label='Screen Shots', required=False)

    tags = forms.CharField(
        label='tags',
        max_length=255,
        widget=forms.TextInput(attrs={
            'placeholder': 'Enter title',
            'class': 'form-control'
        }),
        required=True)
Esempio n. 15
0
class CatdaSoccerPlayersForm(forms.ModelForm):
    bio = forms.CharField(widget=CKEditorUploadingWidget(attrs={
        'required': False,
        'col': 30,
        'rows': 10
    }))

    class Meta:
        model = CatdaSoccerPlayer
        fields = (
            'full_name',
            'short_description',
            'bio',
            'catda_team_positions',
            'catda_strongest_foot',
            'ratings',
            'team_number',
            'dob',
            'former_team',
            'bio_picture',
            'author',
            'featured_picture',
            'featured',
        )
Esempio n. 16
0
class AbstractArticleForm(forms.ModelForm):
    article_title = forms.CharField(
        label=FieldArticle.TITLE, widget=CKEditorWidget(config_name='titles'))
    article_lead = forms.CharField(label=FieldArticle.LEAD,
                                   widget=CKEditorWidget(config_name='leads'))
    article_image_copyright = forms.CharField(
        label=FieldArticle.IMAGE_COPYRIGHT,
        widget=Textarea(attrs={
            'style': 'height : auto',
            'rows': 2
        }),
        required=False)
    article_description = forms.CharField(label=FieldArticle.DESCRIPTION,
                                          widget=CKEditorUploadingWidget())
    article_keywords = HistoryTagField(label=FieldArticle.KEYWORDS)

    class Meta:
        abstract = True
        model = Article
        fields = ('__all__')
        exclude = ('article_title_text', 'article_title_slug',
                   'article_date_add', 'article_date_edit', 'article_added_by',
                   'article_modified_by', 'article_authorizations',
                   'article_contributors')
Esempio n. 17
0
    class Meta:
        model = Post

        fields = ['cat_id', 'board_id', 'post_notice', 'post_name', 'post_content']

        widgets = {
            'cat_id': forms.Select(
                attrs={'class': 'custom-select'}
            ),

            'board_id': forms.Select(
                attrs={'class': 'custom-select'}
            ),

            'post_notice': forms.CheckboxInput(

            ),

            'post_name': forms.TextInput(
                attrs={'class': 'form-control', 'style': 'width: 100%', 'placeholder': '제목을 입력하세요.'}
            ),

            'post_content': forms.CharField(widget=CKEditorUploadingWidget()),
        }
Esempio n. 18
0
class PostForm(ModelForm):
    title = forms.CharField(label='Tytuł postu:',
                            max_length=200,
                            widget=forms.TextInput(),
                            required=True)
    published_date = forms.DateField(input_formats=['%d/%m/%Y'],
                                     label='Data publikacji:',
                                     widget=DatePickerInput(format='%d/%m/%Y'),
                                     required=True)
    text = forms.CharField(widget=CKEditorUploadingWidget(),
                           label="",
                           required=True)
    facebook = forms.BooleanField(label='Udostępnij przez Facebooka:',
                                  required=False)
    twitter = forms.BooleanField(label='Udostępnij przez Twittera:',
                                 required=False)
    comments = forms.BooleanField(label='Włącz komentarze:', required=False)

    class Meta:
        model = Post
        fields = [
            'title', 'published_date', 'text', 'facebook', 'twitter',
            'comments'
        ]
Esempio n. 19
0
 class Meta:
     model = Soal
     fields = ('kategori_soal', 'sifat_soal', 'tipe_soal', 'grup',
               'text_soal')
     widgets = {'text_soal': CharField(widget=CKEditorUploadingWidget())}
Esempio n. 20
0
class NewsAdminForm(forms.ModelForm):
    content = forms.CharField(widget=CKEditorUploadingWidget())

    class Meta:
        model = New
        fields = '__all__'
Esempio n. 21
0
class PostAdminForm(forms.ModelForm):
    body = forms.CharField(widget=CKEditorUploadingWidget())

    class Meta:
        model = Post
        fields = '__all__'
Esempio n. 22
0
class PostForm(forms.ModelForm):
    description = forms.CharField(widget=CKEditorUploadingWidget())
Esempio n. 23
0
 class Meta:
     widgets = {
         'title': forms.TextInput(),
         'description': forms.TextInput(),
         'context': forms.CharField(widget=CKEditorUploadingWidget()),
     }
Esempio n. 24
0
class CommentAdminForm(forms.ModelForm):
    text = forms.CharField(widget=CKEditorUploadingWidget())

    class Meta:
        model = Comment
        fields = '__all__'
Esempio n. 25
0
class BlogAdminForm(forms.ModelForm):
    description = forms.CharField(widget=CKEditorUploadingWidget())

    class Meta:
        model = Blog
        fields = '__all__'
Esempio n. 26
0
class ComposeMailForm(forms.Form):
    """Compose mail form."""

    from_ = forms.ChoiceField(
        label=_("From"),
        choices=[],
        widget=forms.Select(attrs={"class": "selectize"}))
    to = forms.CharField(label=_("To"), validators=[validate_email_list])
    cc = forms.CharField(
        label=_("Cc"),
        required=False,
        validators=[validate_email_list],
        widget=forms.TextInput(
            attrs={
                "placeholder": _("Enter one or more addresses."),
                "class": "selectize-contact"
            }))
    bcc = forms.CharField(
        label=_("Bcc"),
        required=False,
        validators=[validate_email_list],
        widget=forms.TextInput(
            attrs={
                "placeholder": _("Enter one or more addresses."),
                "class": "selectize-contact"
            }))

    subject = forms.CharField(label=_("Subject"),
                              max_length=255,
                              required=False)
    origmsgid = forms.CharField(label="", required=False)
    body = forms.CharField(
        required=False,
        widget=CKEditorUploadingWidget(attrs={"class": "editor form-control"}))

    def __init__(self, user, *args, **kwargs):
        """Custom constructor."""
        super(ComposeMailForm, self).__init__(*args, **kwargs)
        from_addresses = [(user.email, user.email)]
        for address in user.mailbox.alias_addresses:
            try:
                validate_email(address)
                from_addresses += [(address, address)]
            except forms.ValidationError:
                pass
        additional_sender_addresses = (
            user.mailbox.senderaddress_set.values_list("address", flat=True))
        from_addresses += [(address, address)
                           for address in additional_sender_addresses]
        self.fields["from_"].choices = from_addresses
        self.fields["from_"].initial = user.email
        self.field_widths = {"cc": "11", "bcc": "11", "subject": "11"}

    def clean_to(self):
        """Convert to a list."""
        to = self.cleaned_data["to"]
        return email_utils.prepare_addresses(to, "envelope")

    def clean_cc(self):
        """Convert to a list."""
        cc = self.cleaned_data["cc"]
        return email_utils.prepare_addresses(cc, "envelope")

    def clean_bcc(self):
        """Convert to a list."""
        bcc = self.cleaned_data["bcc"]
        return email_utils.prepare_addresses(bcc, "envelope")

    def _html_msg(self, sender, headers):
        """Create a multipart message.

        We attach two alternatives:
        * text/html
        * text/plain
        """
        body = self.cleaned_data["body"]
        if body:
            tbody = html2plaintext(body)
            body, images = make_body_images_inline(body)
        else:
            tbody = ""
            images = []
        msg = EmailMultiAlternatives(self.cleaned_data["subject"],
                                     tbody,
                                     sender,
                                     self.cleaned_data["to"],
                                     cc=self.cleaned_data["cc"],
                                     bcc=self.cleaned_data["bcc"],
                                     headers=headers)
        msg.attach_alternative(body, "text/html")
        for img in images:
            msg.attach(img)
        return msg

    def _plain_msg(self, sender, headers):
        """Create a simple text message."""
        msg = EmailMessage(self.cleaned_data["subject"],
                           self.cleaned_data["body"],
                           sender,
                           self.cleaned_data["to"],
                           cc=self.cleaned_data["cc"],
                           bcc=self.cleaned_data["bcc"],
                           headers=headers)
        return msg

    def _format_sender_address(self, user, address):
        """Format address before message is sent."""
        if user.first_name != "" or user.last_name != "":
            return '"{}" <{}>'.format(
                Header(user.fullname, "utf8").encode(), address)
        return address

    def _build_msg(self, request):
        """Build message to send.

        Can be overidden by children.
        """
        headers = {
            "User-Agent": pkg_resources.get_distribution("modoboa").version
        }
        origmsgid = self.cleaned_data.get("origmsgid")
        if origmsgid:
            headers.update({"References": origmsgid, "In-Reply-To": origmsgid})
        mode = request.user.parameters.get_value("editor")
        sender = self._format_sender_address(request.user,
                                             self.cleaned_data["from_"])
        return getattr(self, "_{}_msg".format(mode))(sender, headers)

    def to_msg(self, request):
        """Convert form's content to an object ready to send."""
        msg = self._build_msg(request)
        if request.session["compose_mail"]["attachments"]:
            for attdef in request.session["compose_mail"]["attachments"]:
                msg.attach(create_mail_attachment(attdef))
        return msg
Esempio n. 27
0
class UserSettings(param_forms.UserParametersForm):
    app = "modoboa_webmail"

    sep1 = form_utils.SeparatorField(label=_("Display"))

    displaymode = forms.ChoiceField(
        initial="plain",
        label=_("Default message display mode"),
        choices=[("html", "html"), ("plain", "text")],
        help_text=_("The default mode used when displaying a message"),
        widget=form_utils.InlineRadioSelect())

    enable_links = form_utils.YesNoField(
        initial=False,
        label=_("Enable HTML links display"),
        help_text=_("Enable/Disable HTML links display"))

    messages_per_page = forms.IntegerField(
        initial=40,
        label=_("Number of displayed emails per page"),
        help_text=_("Sets the maximum number of messages displayed in a page"))

    refresh_interval = forms.IntegerField(
        initial=300,
        label=_("Listing refresh rate"),
        help_text=_("Automatic folder refresh rate (in seconds)"))

    mboxes_col_width = forms.IntegerField(
        initial=200,
        label=_("Folder container's width"),
        help_text=_("The width of the folder list container"))

    sep2 = form_utils.SeparatorField(label=_("Folders"))

    trash_folder = forms.CharField(
        initial="Trash",
        label=_("Trash folder"),
        help_text=_("Folder where deleted messages go"))

    sent_folder = forms.CharField(
        initial="Sent",
        label=_("Sent folder"),
        help_text=_("Folder where copies of sent messages go"))

    drafts_folder = forms.CharField(initial="Drafts",
                                    label=_("Drafts folder"),
                                    help_text=_("Folder where drafts go"))
    junk_folder = forms.CharField(
        initial="Junk",
        label=_("Junk folder"),
        help_text=_("Folder where junk messages should go"))

    sep3 = form_utils.SeparatorField(label=_("Composing messages"))

    editor = forms.ChoiceField(
        initial="plain",
        label=_("Default editor"),
        choices=[("html", "html"), ("plain", "text")],
        help_text=_("The default editor to use when composing a message"),
        widget=form_utils.InlineRadioSelect())

    signature = forms.CharField(initial="",
                                label=_("Signature text"),
                                help_text=_("User defined email signature"),
                                required=False,
                                widget=CKEditorUploadingWidget())

    visibility_rules = {"enable_links": "displaymode=html"}

    @staticmethod
    def has_access(**kwargs):
        return hasattr(kwargs.get("user"), "mailbox")

    def clean_mboxes_col_width(self):
        """Check if the entered value is a positive integer.

        It must also be different from 0.
        """
        if self.cleaned_data['mboxes_col_width'] <= 0:
            raise forms.ValidationError(
                _('Value must be a positive integer (> 0)'))
        return self.cleaned_data['mboxes_col_width']
Esempio n. 28
0
class Blog_Form(forms.ModelForm):
    title = forms.CharField(
        required=True,
        max_length=100,
        widget=forms.TextInput(attrs={'class': "inputfield"}))
    image = forms.ImageField(
        required=True,
        max_length=100,
    )
    author = forms.ModelChoiceField(
        required=True,
        queryset=User.objects.filter(is_superuser=1),
        empty_label="Select Author",
        widget=forms.Select(attrs={'class': "inputfield"}))
    Blog_Category_id = forms.ModelChoiceField(
        required=True,
        queryset=Blog_Category_Db.objects.all(),
        empty_label="Select Category",
        widget=forms.Select(attrs={'class': "inputfield"}))
    meta_title = forms.CharField(
        label='Meta Title',
        required=True,
        max_length=1000,
        widget=forms.TextInput(attrs={'class': "inputfield"}))
    meta_description = forms.CharField(
        label='Meta Description',
        required=True,
        max_length=1000,
        widget=forms.TextInput(attrs={'class': "inputfield"}))
    meta_keywords = forms.CharField(
        label='Meta Keywords',
        required=True,
        max_length=500,
        widget=forms.TextInput(attrs={'class': "inputfield"}))
    details = forms.CharField(required=True,
                              max_length=3000,
                              widget=CKEditorUploadingWidget())

    class Meta:
        # managed = False
        model = Blog_Db
        fields = [
            'title', 'image', 'author', 'Blog_Category_id', 'meta_title',
            'meta_description', 'meta_keywords', 'details'
        ]

    def clean_title(self):
        if self.instance.pk != None:
            title = self.cleaned_data.get('title')
            list = Blog_Db.objects.filter(title__iexact=title,
                                          id=self.instance.pk)
            if list:
                return title
            else:
                if title and Blog_Db.objects.filter(
                        title__iexact=title).exists():
                    raise forms.ValidationError(u'Title already exists.')
                return title
        else:
            title = self.cleaned_data.get('title')
            if title and Blog_Db.objects.filter(title__iexact=title).exists():
                raise forms.ValidationError(u'Title already exists.')
        return title
Esempio n. 29
0
class PageContenuAdminForm(forms.ModelForm):
    contenu = forms.CharField(widget=CKEditorUploadingWidget())

    class Meta:
        model = page.PageContenu
        fields = ('titre', 'contenu')
Esempio n. 30
0
class NewsAdminForm(TranslatableModelForm):
    body = forms.CharField(label ='Текст',widget=CKEditorUploadingWidget())
    class Meta:
        model = NewsTranslate
        fields = '__all__'