예제 #1
0
 class Meta:
     model = Post
     content = forms.CharField(widget=CKEditorUploadingWidget())
     model = Post
     fields = ('title', 'content', 'author', 'imageurl', 'uploadimg',
               'category')  #add 'imageurl'
예제 #2
0
파일: admin.py 프로젝트: sud0su/cacip-dev
    def __init__(self, *args, **kwargs):
        super(BlogAdminForm, self).__init__(*args, **kwargs)

        self.fields['title'].widget = admin.widgets.AdminTextInputWidget()
        # self.fields['title_en'].widget = admin.widgets.AdminTextInputWidget()
        self.fields['abstract'].widget = CKEditorUploadingWidget()
예제 #3
0
class PostAdminForm(forms.ModelForm):
	content = forms.CharField(widget=CKEditorUploadingWidget())
	
	class Meta:
		model = Post
		fields = '__all__'
예제 #4
0
class PostForm(forms.ModelForm):
    ## content = models.TextField()
    detail = forms.CharField(widget=CKEditorUploadingWidget())
예제 #5
0
class ProductoForm(forms.ModelForm):
    descripcion = forms.CharField(widget=CKEditorUploadingWidget())

    class Meta:
        model = Producto
        exclude = ('user', )
예제 #6
0
 class Meta:
     model = Article
     fields = '__all__'
     widgets = {
         'content': CKEditorUploadingWidget(),
     }
예제 #7
0
class ProductAdminForm(forms.ModelForm):
    characteristics = forms.CharField(label="Характеристики", widget=CKEditorUploadingWidget())

    class Meta:
        model = Product
        fields = '__all__'
예제 #8
0
class TaskForm(forms.ModelForm):
    task_info = forms.CharField(widget=CKEditorUploadingWidget())
    class Meta:
        model = Task
        fields = ('title','headline','task_info','access')
예제 #9
0
    class Meta:
        # model = Post
        fields = forms.ALL_FIELDS

        widgets = {
            'lead_es':
            CKEditorUploadingWidget(),
            'lead_en':
            CKEditorUploadingWidget(),
            'lead_fr':
            CKEditorUploadingWidget(),
            'excerpt_es':
            MiniTextArea,
            'excerpt_en':
            MiniTextArea,
            'excerpt_fr':
            MiniTextArea,
            'image_caption_es':
            MiniTextArea,
            'image_caption_en':
            MiniTextArea,
            'image_caption_fr':
            MiniTextArea,
            'body_es':
            CKEditorUploadingWidget(),
            'body_en':
            CKEditorUploadingWidget(),
            'body_fr':
            CKEditorUploadingWidget(),
            'blog':
            autocomplete.ModelSelect2(
                url='blogs:autocompletes:blog_autocomplete',
                attrs={
                    'data-placeholder': _('Blog...'),
                }),
            'source':
            autocomplete.ModelSelect2(
                url='blogs:autocompletes:source_autocomplete',
                attrs={
                    'data-placeholder': _('Fuente ...'),
                    # 'data-minimum-input-length': 3,
                }),
            'authors':
            autocomplete.ModelSelect2Multiple(
                url='blogs:autocompletes:author_autocomplete',
                attrs={
                    'data-placeholder': _('Autores ...'),
                    # 'data-minimum-input-length': 3,
                }),
            'categories':
            autocomplete.ModelSelect2Multiple(
                url='blogs:autocompletes:category_autocomplete',
                attrs={
                    'data-placeholder': _('Categorías ...'),
                    # 'data-minimum-input-length': 3,
                }),
            'related':
            autocomplete.ModelSelect2Multiple(
                url='blogs:autocompletes:post_autocomplete',
                attrs={
                    'data-placeholder': _('Publicaciones relacionadas ...'),
                    # 'data-minimum-input-length': 3,
                }),
            'tags':
            autocomplete.ModelSelect2Multiple(
                url='blogs:autocompletes:tag_autocomplete',
                attrs={'data-placeholder': _('Etiquetas...')}),
            'reference':
            autocomplete.ModelSelect2(
                url='blogs:autocompletes:post_autocomplete',
                attrs={
                    'data-placeholder': _('Referencia...'),
                }),
        }
예제 #10
0
class EventsForm(forms.ModelForm):
    information = forms.CharField(widget=CKEditorUploadingWidget())

    class Meta:
        model = Event
        fields = ('title', 'event_image', 'headline', 'information')
예제 #11
0
class ResponseForm(forms.ModelForm):
	response = forms.CharField(widget=CKEditorUploadingWidget(config_name='response'))
	class Meta:
		model = TaskResponse
		fields = ('response',)
예제 #12
0
class ArticleForm(forms.ModelForm):
    body = forms.CharField(widget=CKEditorUploadingWidget())

    class Meta:
        model = Article
        fields = '__all__'
예제 #13
0
 class Meta:
     model = Post
     fields = '__all__'
     widgets = {
         'content': CKEditorUploadingWidget()
     }
예제 #14
0
        ]


class ProductForm(catalogue_admin_forms.ProductForm):
    class Meta:
        model = catalogue_admin_forms.Product
        fields = [
            'title_az', 'title_en', 'title_ru', 'upc', 'description_az',
            'description_en', 'description_ru', 'is_discountable',
            'best_seller', 'structure'
        ]
        widgets = {
            'structure': catalogue_admin_forms.forms.Select(),
            'description_az': CKEditorUploadingWidget(),
            'description_en': CKEditorUploadingWidget(),
            'description_ru': CKEditorUploadingWidget()
        }


CategoryForm = catalogue_admin_forms.movenodeform_factory(
    catalogue_admin_forms.Category,
    fields=[
        'name_az', 'name_en', 'name_ru', 'description_az', 'description_en',
        'description_ru', 'image'
    ],
    widgets={
        'description_az': CKEditorUploadingWidget(),
        'description_en': CKEditorUploadingWidget(),
        'description_ru': CKEditorUploadingWidget()
    })
예제 #15
0
class ProductAdminForm(forms.ModelForm):
    dsc = forms.CharField(label='Описание', widget=CKEditorUploadingWidget())

    class Meta:
        model = Product
        fields = '__all__'
예제 #16
0
class PostAdminForm(forms.ModelForm):
    """
    django-autocomplete-light提供Form层的组件来加入后端接口
    """
    desc = forms.CharField(widget=forms.Textarea, label='摘要', required=False)
    category = forms.ModelChoiceField(
        queryset=Category.objects.all(),
        widget=autocomplete.ModelSelect2(url='category-autocomplete'),
        label='分类',
    )
    tag = forms.ModelMultipleChoiceField(
        queryset=Tag.objects.all(),
        widget=autocomplete.ModelSelect2Multiple(url='tag-autocomplete'),
        label='标签',
    )
    # content_ck和content_md是为了在页面展示的
    content_ck = forms.CharField(widget=CKEditorUploadingWidget(), label='正文', required=False)
    content_md = forms.CharField(widget=forms.Textarea(), label='正文', required=False)
    # content 用来接收最终的编辑内容
    content = forms.CharField(widget=forms.HiddenInput(), required=False)



# 为了避免出现JS资源冲突的问题,定义了Meta以及其中的fields,需要把自动补全的字段放到前面
    class Meta:
        model = Post
        fields = (
            'category', 'tag', 'desc', 'title',
            'is_md', 'content', 'content_md', 'content_ck',
            'status'
        )

    def __init__(self, instance=None, initial=None, **kwargs):
        """
        对Form做初始化处理
        :param instance: 当前文章的实例
        :param initial: Form中各字段初始化的值
        :param kwargs:
        """
        print('====== adminforms PostAdminForm init ======\n'
              '====== adminforms PostAdminForm instance : ', instance)
        initial = initial or {}
        if instance:
            print('------ instance有值!!!------')
            if instance.is_md:
                initial['content_md'] = instance.content
            else:
                initial['content_ck'] = instance.content
        print('====== instance :', instance)
        super().__init__(instance=instance, initial=initial, **kwargs)

    def clean(self):
        """
        对用户提交的内容做处理,
        判断是否使用了Markdown语法,
        然后设置获取对应编辑器的值,并将其赋值给content
        """
        is_md = self.cleaned_data.get('is_md')
        print('====== adminforms PostAdminForm clean ======\n,'
              '====== adminforms PostAdminForm clean.is_md :', is_md)
        if is_md:
            content_field_name = 'content_md'
        else:
            content_field_name = 'content_ck'
        content = self.cleaned_data.get(content_field_name)
        print('====== adminforms PostAdminForm clean.content :', content)
        if not content:
            self.add_error(content_field_name, '必填项!')
            return

        self.cleaned_data['content'] = content
        # self.content = content
        print('====== adminforms PostAdminFOrm clean.cleaned_data[content] :', self.cleaned_data['content'])
        # print('====== self.content :', self.content)
        return super().clean()

    class Media:
        print('====== adminforms PostAdminForm Media ======')
        """通过JS文件来实现展示逻辑的控制"""
        js = ('js/post_editor.js', )
예제 #17
0
 class Meta:
     model = Post
     exclude = ['authors', 'slug']
     widgets = {'body': CKEditorUploadingWidget()}
예제 #18
0
class HotelAdminForm(forms.ModelForm):
    text = forms.CharField(label="Описание", widget=CKEditorUploadingWidget())

    class Meta:
        model = Hotel
        fields = '__all__'
예제 #19
0
class CKEditorTextareaForm(forms.Form):

    ckeditor_textarea = forms.CharField(
        widget=CKEditorUploadingWidget(config_name='djeym'), )
예제 #20
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
예제 #21
0
class MovieAdminForm(forms.ModelForm):
    description = forms.CharField(label="Описание", widget=CKEditorUploadingWidget())

    class Meta:
        model = Movie
        fields = '__all__'
예제 #22
0
파일: forms.py 프로젝트: YarlingB/cantera
class PublicacionForm(forms.ModelForm):
    resumen = forms.CharField(widget=CKEditorUploadingWidget())

    class Meta:
        model = Publicacion
        exclude = ('slug', 'usuario', 'tipo')
예제 #23
0
class AbstractScholarshipForm(forms.ModelForm):
    scholarship_name = forms.CharField(
        label=FieldScholarship.NAME,
        widget=CKEditorWidget(config_name='titles'))
    scholarship_lead = forms.CharField(
        label=FieldScholarship.LEAD,
        widget=CKEditorWidget(config_name='leads'))
    scholarship_image_copyright = forms.CharField(
        label=FieldScholarship.IMAGE_COPYRIGHT,
        widget=Textarea(attrs={
            'style': 'height : auto',
            'rows': 2
        }),
        required=False)
    scholarship_description = forms.CharField(
        label=FieldScholarship.DESCRIPTION, widget=CKEditorUploadingWidget())
    scholarship_keywords = HistoryTagField(label=FieldScholarship.KEYWORDS)
    scholarship_connected_projects = forms.ModelMultipleChoiceField(
        label=FieldScholarship.CONNECTED_PROJECTS,
        required=False,
        queryset=Project.objects.all(),
        widget=autocomplete.ModelSelect2Multiple(url='project-autocomplete')
    )  # related_name field has to be defined in the form

    def __init__(self, *args, **kwargs):
        if kwargs.get('instance'):
            initial = kwargs.setdefault('initial', {})
            # the widget for a ModelMultipleChoiceField expects a list of primary key for the selected data
            initial['scholarship_connected_projects'] = [
                project.project_id for project in
                kwargs['instance'].scholarship_connected_projects.all()
            ]
        super(AbstractScholarshipForm, self).__init__(*args, **kwargs)

    def clean_scholarship_date_end(self):
        try:
            dateFrom = self.cleaned_data.get('scholarship_date_start', None)
            dateTo = self.cleaned_data.get('scholarship_date_end', None)
        except:
            raise forms.ValidationError(MessageScholarship.INCORRECT_DATE)
        if dateFrom is not None and dateTo is not None:
            if dateFrom > dateTo:
                raise forms.ValidationError(
                    MessageScholarship.INCORRECT_PERIOD)
        return dateTo

    def _save_m2m(self):
        instance = self.instance
        instance.scholarship_connected_projects.clear()
        for project in self.cleaned_data['scholarship_connected_projects']:
            instance.scholarship_connected_projects.add(project)
        super(AbstractScholarshipForm, self)._save_m2m()

    class Meta:
        abstract = True
        model = Scholarship
        fields = ('__all__')
        widgets = {
            'scholarship_founder':
            autocomplete.ModelSelect2(url='institution-autocomplete'),
            'scholarship_targets':
            autocomplete.ModelSelect2Multiple(url='targetgroup-autocomplete'),
            'scholarship_city':
            autocomplete.ModelSelect2(url='city-autocomplete'),
            'scholarship_type':
            autocomplete.ModelSelect2(url='scholarshiptype-autocomplete'),
        }
        exclude = ('scholarship_name_text', 'scholarship_name_slug',
                   'scholarship_date_add', 'scholarship_date_edit',
                   'scholarship_added_by', 'scholarship_modified_by',
                   'scholarship_authorizations')
예제 #24
0
class ArticleForm(forms.ModelForm):
    content = forms.CharField(widget=CKEditorUploadingWidget())
예제 #25
0
class PostAdminForm(forms.ModelForm):
    desc = forms.CharField(widget=forms.Textarea, label='摘要', required=False)
    content = forms.CharField(widget=CKEditorUploadingWidget(),
                              label='正文',
                              required=True)
예제 #26
0
class PlayerAdminForm(forms.ModelForm):
    description = forms.CharField(widget=CKEditorUploadingWidget())

    class Meta:
        model = Player
        fields = '__all__'
예제 #27
0
 class Meta:
     model = Category
     fields = ['name', 'slug', 'parent', 'image', 'template_name', 'status', 'editor']
     widgets = {'status': forms.RadioSelect, 'description': CKEditorUploadingWidget(config_name='mcat')}
예제 #28
0
class PostForm(forms.ModelForm):
    detail = forms.CharField(widget=CKEditorUploadingWidget())
예제 #29
0
class EventForm(forms.ModelForm):
    type = forms.CharField(widget=forms.Select(
        choices=EVENTS, attrs={'class': 'form-control'}), required=True)
    c_o_e = forms.CharField(widget=forms.Select(
        choices=CENTER_OF_EXCELLENCE, attrs={'class': 'form-control'}), required=True)

    event_name = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control', 'placeholder': 'Event Name'}), required=True, max_length=100)
    event_pic = forms.FileField(widget=forms.ClearableFileInput(
        attrs={'class': 'custom-file-input', 'style': "opacity:1"}), required=True)
    fees = forms.FloatField(widget=forms.TextInput(
        attrs={'class': 'form-control', 'placeholder': 'Fees'}), min_value=0, max_value=10000, required=True)
    registration_start = forms.DateField(widget=forms.DateInput(
        attrs={'type': 'date', 'class': 'form-control'}))
    registration_end = forms.DateField(widget=forms.DateInput(
        attrs={'type': 'date', 'class': 'form-control'}))
    event_date = forms.DateField(widget=forms.DateInput(
        attrs={'type': 'date', 'class': 'form-control'}))
    duration_number = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control', 'placeholder': 'Durations'}), required=True, max_length=5)
    duration_string = forms.CharField(widget=forms.Select(
        choices=DURATION_STRING, attrs={'class': 'form-control'}), required=True)
    eligible_branches = forms.CharField(widget=forms.CheckboxSelectMultiple(
        choices=BRANCHES, attrs={'class': 'form-check-inline'}), required=True)
    eligible_year = forms.CharField(widget=forms.CheckboxSelectMultiple(
        choices=YEAR, attrs={'class': 'form-check-inline'}), required=True)

    pre_requisites_1 = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control', 'placeholder': 'Pre Requisites'}), required=True, max_length=50)
    pre_requisites_2 = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control', 'placeholder': 'Pre Requisites'}), required=True, max_length=50)
    pre_requisites_3 = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control', 'placeholder': 'Pre Requisites'}), required=True, max_length=50)
    learning_outcome_1 = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control', 'placeholder': 'Learning Outcome'}), required=False, max_length=100)
    learning_outcome_2 = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control', 'placeholder': 'Learning Outcome'}), required=False, max_length=100)
    learning_outcome_3 = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control', 'placeholder': 'Learning Outcome'}), required=False, max_length=100)
    learning_outcome_4 = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control', 'placeholder': 'Learning Outcome'}), required=False, max_length=100)
    learning_outcome_5 = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control', 'placeholder': 'Learning Outcome'}), required=False, max_length=100)
    learning_outcome_6 = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control', 'placeholder': 'Learning Outcome'}), required=False, max_length=100)
    description = forms.CharField(widget=CKEditorUploadingWidget())

    outside_student = forms.IntegerField(widget=forms.RadioSelect(
        choices=CHOICE, attrs={'class': 'form-check-inline'}), required=True)
    venue = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control', 'placeholder': 'Venue'}), required=True, max_length=50)
    resource_person = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control', 'placeholder': 'Resource Person'}), required=True, max_length=100)
    resource_person_data = forms.CharField(widget=CKEditorUploadingWidget())
    resource_person_pic = forms.FileField(widget=forms.ClearableFileInput(
        attrs={'class': 'custom-file-input', 'style': "opacity:1"}), required=True)

    class Meta:
        model = EventRecord
        fields = ['event_name', 'description', 'duration_number', 'resource_person', 'resource_person_data', 'venue',
                  'fees', 'registration_start', 'registration_end', 'event_date', 'type', 'c_o_e', 'duration_string',
                  'eligible_branches', 'outside_student', 'pre_requisites_1', 'pre_requisites_2', 'pre_requisites_3',
                  'learning_outcome_1', 'learning_outcome_2', 'learning_outcome_3', 'learning_outcome_4',
                  'learning_outcome_5', 'learning_outcome_6', 'resource_person_pic', 'event_pic', 'eligible_year']

    def clean_registration_start(self):
        try:
            registration_start = self.cleaned_data['registration_start']
            if True or registration_start.strftime('%Y-%m-%d') >= date.today().strftime('%Y-%m-%d'):
                return registration_start
            raise forms.ValidationError("Invalid Start Date")
        except Exception:
            raise forms.ValidationError("Invalid Start Date")

    def clean_registration_end(self):
        try:
            registration_start = self.cleaned_data['registration_start']
            registration_end = self.cleaned_data['registration_end']
            if registration_start <= registration_end:
                return registration_end
            raise forms.ValidationError("Invalid End Date")
        except Exception:
            raise forms.ValidationError("Invalid End Date")

    def clean_event_date(self):
        try:
            registration_start = self.cleaned_data['registration_start']
            event_date = self.cleaned_data['event_date']
            if registration_start <= event_date:
                return event_date
            raise forms.ValidationError("Invalid Event Date")
        except Exception:
            raise forms.ValidationError("Invalid Event Date")
예제 #30
0
class NewsAdminForm(forms.ModelForm):
    description_ru = forms.CharField(label="Описание", widget=CKEditorUploadingWidget())
    description_en = forms.CharField(label="Description", widget=CKEditorUploadingWidget(), required=False)