예제 #1
0
def detail_view(request, report_id):
    is_editor = is_user_an_editor(request)
    r = requests.get(API_HOST + '/api/report/%d/' % (report_id))
    if r.status_code // 100 == 4:
        return render(request, 'not_found.html')
    widget_html = ""
    report = r.json()
    md = ""
    comment = report.get('comment', None)
    if comment is None:
        comment = {'md': ''}
    value = comment['md']
    if is_editor:
        w = MarkdownxWidget()
        widget_html = w.render('comment', value, {})
    else:
        markdownify = import_string('markdownx.utils.markdownify')
        md = markdownify(value)
    return render(
        request, 'detail.html', {
            'report': report,
            'markdownx_editor': widget_html,
            'is_editor': is_editor,
            'markdownx_md': md
        })
예제 #2
0
 class Meta:
     model = Category
     fields = '__all__'
     widgets = {
         'short_description': MarkdownxWidget(),
         'description': MarkdownxWidget(),
     }
예제 #3
0
 class Meta:
     model = MyReference
     fields = ['name', 'description', 'url']
     widgets = {
         'name': forms.TextInput(attrs={'class': 'form-control'}),
         'description': MarkdownxWidget(attrs={'class': 'form-control'})
     }
예제 #4
0
파일: forms.py 프로젝트: JasonWurunfei/FTH
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         'user',
         'title',
         'body',
         'created_date',
         'mod_date',
         Submit('submit', 'Submit', css_class='btn btn-primary btn-lg'),
     )
     self.fields['title'].widget = forms.TextInput(
         attrs={'autocomplete': 'off'})
     self.fields['body'].label = ''
     self.fields['user'].widget = forms.HiddenInput()
     self.fields['created_date'].widget = forms.HiddenInput()
     self.fields['mod_date'].widget = forms.HiddenInput()
     self.fields['body'].widget = MarkdownxWidget(
         attrs={
             'style':
             '''
                     background-color:#ffffe6;
                     min-width:500px;
                     min-height:500px;
             ''',
         })
예제 #5
0
    class Meta:
        model = Post
#        fields = ('title', 'category', 'tag', 'content', 'is_public')
        fields = '__all__'
        widgets = {
            'text' : MarkdownxWidget(attrs={'class': 'textarea'})
        }
예제 #6
0
class PositionForm(forms.ModelForm):
    """Form representing a position. This form is inserted into
    PositionFormset
    """
    description = forms.CharField(
        label='',
        widget=MarkdownxWidget(
            attrs={
                'placeholder': 'Position Description',
                'class': 'card-input'
            })
    )

    time_estimate = forms.CharField(
        widget=forms.TextInput(
            attrs={
                'class': 'card-input'
        }))

    class Meta:
        model = Position
        fields = ['title', 'description', 'skills', 'time_estimate', 'id', ]
        widgets = {
            'title': forms.TextInput(attrs={
                'placeholder': 'Position Title',
                'class': 'card-input'
            }),
            'id': forms.HiddenInput(),
        }
예제 #7
0
def create_exercise_view(request):
    if request.method == 'POST':
        form = f.ExerciseForm(request.POST)
        if form.is_valid():
            with reversion.create_revision():
                exercise = form.save(commit=False)
                exercise.author = request.user
                exercise.save()
                form.save_m2m()
                reversion.set_user(request.user)
            return redirect('learning:exercise', exercise_id=exercise.id)
    else:
        if 'section' in request.GET:
            section = get_object_or_404(m.Section, id=request.GET['section'])
            form = f.ExerciseForm(initial={'synopses_sections': [
                section,
            ]})
        else:
            form = f.ExerciseForm()

    context = build_base_context(request)
    context['pcode'] = 'l_exercises'
    context['title'] = 'Submeter exercício'
    context['form'] = form
    editor = MarkdownxWidget().render(name='', value='', attrs=dict())
    context['markdown_editor'] = editor
    context['sub_nav'] = [{
        'name': 'Exercícios',
        'url': reverse('learning:exercises')
    }, {
        'name': 'Submeter exercício',
        'url': reverse('learning:exercise_create')
    }]
    return render(request, 'learning/editor.html', context)
예제 #8
0
class UserUpdateForm(forms.ModelForm):
    """Form for updating user's general information (first_name,
    last_name, about, avatar, skills)
    """
    about = forms.CharField(
        widget=MarkdownxWidget(
            attrs={
                "class": "card-input",
                "placeholder": "Add a short description about yourself..."
            }))

    first_name = forms.CharField(
        widget=forms.TextInput(
            attrs={
                "class": "card-input",
                "placeholder": "First Name"
            }))

    last_name = forms.CharField(
        widget=forms.TextInput(
            attrs={
                "class": "card-input",
                "placeholder": "Last Name"
            }))

    class Meta:
        model = User
        fields = ['first_name', 'last_name', 'about', 'skills']
예제 #9
0
파일: forms.py 프로젝트: SasakiPeter/56gen
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['text'].widget = MarkdownxWidget()
        for field in self.fields.values():
            field.widget.attrs['class'] = 'form-control'
            field.widget.attrs['placeholder'] = field.label
        self.fields['text'].initial = """## マークダウンの書き方
### 順序なしリスト

* リストアイテム1
* リストアイテム2
* リストアイテム3

### 順序ありリスト

1. リストアイテム
1. リストアイテム
1. リストアイテム

### 文字強調

*イタリック*  
**太文字**

### 引用

> #### コラム~マークダウンとは
> このサイトでは[マークダウン形式](https://ja.wikipedia.org/wiki/Markdown)での入力を受け付けています。
> 上記に例を示したので、例にならって入力してみてください。"""
        self.fields['tags'].widget = MyCheckboxSelectMultiple()
        self.fields['tags'].queryset = Tag.objects
예제 #10
0
 class Meta:
     model = Article
     fields = ('thumbnail', 'categories', 'title', 'text', 'is_public',
               'title_seo', 'description', 'keywords')
     widgets = {
         'text': MarkdownxWidget(attrs={'class': 'textarea'}),
     }
예제 #11
0
 class Meta:
     model = Content
     fields = [
         "text", "visibility", "pinned", "show_preview", "federate", "include_following",
         "recipients",
     ]
     widgets = {
         "text": MarkdownxWidget()
     }
예제 #12
0
 class Meta:
     model = Comment
     fields = (
         'author',
         'text',
     )
     widgets = {
         'text': MarkdownxWidget(attrs={'class': 'textarea'}),
     }
예제 #13
0
 class Meta:
     model = Comment
     fields = (
         'name',
         'content',
     )
     widgets = {
         'content': MarkdownxWidget(attrs={'class': 'com-form'}),
     }
예제 #14
0
 class Meta:
     model = Post
     fields = (
         'title',
         'outlined_material_icon_name',
         'text',
     )
     widgets = {
         'text': MarkdownxWidget(attrs={'class': 'textarea'}),
     }
예제 #15
0
	class Meta:
		model = Question
		fields = ('title', 'tag', 'text', 'is_public')
		widgets = {
			'tag': forms.CheckboxSelectMultiple(
				attrs={'class': 'list-unstyled',}
			),
			'question_text': MarkdownxWidget(
				attrs={'placeholder': 'マークダウンに対応しています。'}
			),
		}
예제 #16
0
 class Meta:
     model = Post
     fields = (
         'post',
         'category',
         'content',
         'is_public',
     )
     widgets = {
         'content': MarkdownxWidget(attrs={'class': 'post-form'}),
     }
예제 #17
0
파일: forms.py 프로젝트: dymnz/Paper
class NoteForm(forms.Form):
    #tags = TagField(widget=forms.TextInput(attrs={'class' : 'tag-field'}), max_length=200)

    tag_dropdown = forms.ChoiceField(
        choices=[(tag, tag) for tag in Tag.objects.all()],
        widget=forms.Select(attrs={'class': 'tag-field'}),
        label='')
    text = MarkdownxFormField(
        widget=MarkdownxWidget(attrs={'class': 'text-box'}),
        label='',
    )
예제 #18
0
 class Meta:
     model = TalkAtArticle
     fields = [
         'msg',
     ]
     widgets = {
         'msg':
         MarkdownxWidget(
             attrs={
                 'placeholder': 'あなたの回答を入力(コードを含む場合はMarkdown記法をご使用ください)'
             })
     }
예제 #19
0
    class Meta:
        model = ToDo
        fields = [
            'title', 'description', 'source_url', 'slug', 'status', 'progress',
            'ref_title1', 'ref_url1', 'ref_title2', 'ref_url2', 'ref_title3',
            'ref_url3', 'ref_title4', 'ref_url4', 'ref_title5', 'ref_url5'
        ]

        widgets = {
            'title': forms.TextInput(attrs={'class': 'form-control'}),
            'description': MarkdownxWidget(attrs={'class': 'form-control'})
        }
예제 #20
0
    class Meta:
        model = Article
        fields = (
            'title',
            'text',
            'tag',
            'photo',
        )
        widgets = {            # 'text': forms.Textarea(attrs={'rows':5, 'cols':8}),
            'title': forms.TextInput(attrs={"placeholder":"タイトル"}),
            'text': MarkdownxWidget(attrs={'class': 'textarea','rows': 7, 'cols': 22, 'style': 'resize:none;'}),

                  }
예제 #21
0
class CreateProjectForm(forms.ModelForm):
    """Form for creating a project
    """
    STATUS = [
        ('A', 'Open'),
        ('B', 'Closed'),
        ('C', 'Complete'),
    ]

    title = forms.CharField(
        max_length=255,
        widget=forms.TextInput(
            attrs={
                'class': 'card-input',
                'placeholder': 'Project Title'
            }))

    description = forms.CharField(
        widget=MarkdownxWidget(
            attrs={
                'class': 'card-input',
                'placeholder': 'Project description'
            }))

    status = forms.CharField(
        widget=forms.RadioSelect(
            choices=STATUS,
            attrs={
                'class': 'status-list'
        }))

    time_estimate = forms.CharField(
        max_length=10,
        widget=forms.TextInput(
            attrs={
                'class': 'card-input',
                'placeholder': 'Time estimate'}
        ))

    applicant_requirements = forms.CharField(
        widget=forms.Textarea(
            attrs={
                'class': 'card-input'
            }
        )
    )

    class Meta:
        model = Project
        fields = ['title', 'description', 'time_estimate',
                  'applicant_requirements', 'status', ]
예제 #22
0
class AddNoteForm(forms.Form):
    tags = forms.CharField(widget=forms.Textarea(attrs={
        "rows": 1,
        "cols": 120
    }))
    note = MarkdownxFormField(widget=MarkdownxWidget(attrs={
        "rows": 6,
        "cols": 120
    }))

    def clean_data(self):
        tags = self.cleaned_data['tags']
        note = self.cleaned_data['note']
        return tags, note
예제 #23
0
 class Meta:
     model = Article
     fields = [
         'is_published', 'title', 'category', 'course', 'lesson', 'content',
         'article_image_1', 'article_image_2'
     ]
     labels = {
         'title': '',
         'content': '',
     }
     widgets = {
         'title':
         forms.TextInput(attrs={'placeholder': '記事タイトル:30文字以内'}),
         'content':
         MarkdownxWidget(
             attrs={
                 'placeholder':
                 '本文を入力(コードを含む場合はMarkdown記法をご使用ください)<br> * 実現したいこと <br> * 試したこと <br> * 出力されたエラー <br> などを書きましょう'
             })
     }
예제 #24
0
class ArticleForm(forms.ModelForm):
    title = forms.CharField(
        label = 'Título',
        required = True,
        widget = forms.TextInput(attrs={'class': 'form-control'})
    )
    labels = forms.CharField(
        label = 'Etiquetas',
        required = True,
        widget = forms.TextInput(attrs={'class': 'form-control'})
    )
    pub_date = forms.DateTimeField(
        label = "Fecha de publicación",
        required = True,
        initial = datetime.datetime.now,
        widget = forms.DateTimeInput(attrs={'class': 'form-control'})
    )
    content = MarkdownxFormField(
        label = "Contenido de la publicación",
        required = True,
        widget = MarkdownxWidget(attrs={'class': 'form-control'})
    )
    category = forms.ModelChoiceField(
        label = 'Categoría',
        queryset = Category.objects.all(),
        initial = 0,
        widget = forms.Select(attrs={'class': 'form-control'})
    )
    author = forms.ModelChoiceField(
        label = 'Autor',
        queryset = User.objects.all(),
        initial = 0,
        widget = forms.Select(attrs={'class': 'form-control'})
    )


    class Meta:
        model = Article
        fields = ('title', 'labels', 'pub_date', 'category', 'content', 'author')
예제 #25
0
 class Meta:
     model = Question
     fields = [
         'title', 'category', 'lesson', 'course', 'content',
         'question_image_1', 'question_image_2'
     ]
     labels = {
         'title': '',
         'category': '',
         'lesson': '',
         'course': '',
         'content': '',
     }
     # emply_label = '選択してください'
     widgets = {
         'title':
         forms.TextInput(attrs={'placeholder': '質問タイトル:30文字以内'}),
         'content':
         MarkdownxWidget(
             attrs={
                 'placeholder':
                 '本文を入力(コードを含む場合はMarkdown記法をご使用ください)&#13;・実現したいこと&#13;・試したこと&#13;・出力されたエラー&#13;などを書きましょう'
             })
     }
예제 #26
0
파일: forms.py 프로젝트: Zeerti/KBS-Demo
class MyForm(forms.Form):
    body = MarkdownxFormField(widget=MarkdownxWidget(
        attrs={'class': 'custom-class-body'}))
예제 #27
0
class MyForm(forms.Form):
    markdownx_form_field1 = MarkdownxFormField(widget=MarkdownxWidget(
        attrs={'class': 'custom-class-markdownx_form_field1'}))
    markdownx_form_field2 = MarkdownxFormField(widget=MarkdownxWidget(
        attrs={'class': 'custom-class-markdownx_form_field2'}))
예제 #28
0
 class Meta:
     model = Article
     fields = ('title', 'text')
     widgets = {
         'text': MarkdownxWidget(),
     }
예제 #29
0
파일: forms.py 프로젝트: SasakiPeter/56gen
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.fields['desc'].widget = MarkdownxWidget()
     for field in self.fields.values():
         field.widget.attrs['class'] = 'form-control'
         field.widget.attrs['placeholder'] = field.label
예제 #30
0
파일: forms.py 프로젝트: takumab/socialhome
 class Meta:
     model = Content
     fields = ["text", "visibility", "pinned"]
     widgets = {"text": MarkdownxWidget()}