Parent: [2d07b2] (diff)

Child: [875040] (diff)

Download this file

widgets.py    43 lines (36 with data), 1.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import ew as ew_core
import ew.jinja2_ew as ew
from allura.lib.widgets import form_fields as ffw
from allura.lib.widgets import forms
from allura import model as M
class NewPostForm(forms.ForgeForm):
class fields(ew_core.NameList):
title = ew.TextField()
text = ffw.MarkdownEdit(show_label=False)
date = ew.DateField()
time = ew.TimeField()
state = ew.SingleSelectField(
options=[
ew.Option(py_value='draft', label='Draft'),
ew.Option(py_value='published', label='Published') ])
labels = ffw.LabelEdit()
class EditPostForm(NewPostForm):
class buttons(ew_core.NameList):
delete = ew.SubmitButton()
class ViewPostForm(ew_core.Widget):
template='jinja:blog_widgets/view_post.html'
defaults=dict(
ew_core.Widget.defaults,
value=None,
subscribed=None,
base_post=None)
def __call__(self, **kw):
kw = super(ViewPostForm, self).__call__(**kw)
kw['subscribed'] = \
M.Mailbox.subscribed(artifact=kw.get('value'))
return kw
class PreviewPostForm(ew_core.Widget):
template='jinja:blog_widgets/preview_post.html'
defaults=dict(
ew_core.Widget.defaults,
value=None)