WIP: Note editing, markdown to html
[oweals/karmaworld.git] / karmaworld / apps / notes / forms.py
1 #!/usr/bin/env python
2 # -*- coding:utf8 -*-
3 # Copyright (C) 2012  FinalsClub Foundation
4 from django.forms import ModelForm, IntegerField, HiddenInput, Form, CharField, Textarea
5 from django.forms import TextInput
6 from django_filepicker.widgets import FPFileWidget
7 from django.template.loader import render_to_string
8 from wysihtml5.widgets import RichTextEditor
9
10 from karmaworld.apps.notes.models import Note, NoteMarkdown
11
12
13 class NoteForm(ModelForm):
14     html = CharField(widget=RichTextEditor)
15
16     class Meta:
17         model = Note
18         fields = ('name', 'tags', 'html')
19         widgets = {
20           'name': TextInput()
21         }
22
23 class NoteDeleteForm(Form):
24     note = IntegerField(widget=HiddenInput())
25
26 class FileUploadForm(ModelForm):
27     auto_id = False
28     class Meta:
29         model = Note
30         fields = ('fp_file',)
31         widgets = {
32           'fp_file': FPFileWidget(attrs={
33                        'id': 'filepicker-file-upload',
34                      }),
35         }