admin: allow changing the form category in a popup

This commit is contained in:
Frédéric Péters 2012-08-13 14:39:19 +02:00
parent 432f43ae4d
commit 852f854c30
1 changed files with 29 additions and 3 deletions

View File

@ -272,7 +272,7 @@ class FieldsDirectory(FieldsDirectory):
class FormDefPage(Directory):
_q_exports = ['', 'fields', 'edit', 'delete', 'duplicate', 'export',
'archive', 'invite', 'enable', 'workflow']
'archive', 'invite', 'enable', 'workflow', 'category']
def __init__(self, component):
try:
@ -295,9 +295,16 @@ class FormDefPage(Directory):
'<div class="bo-block">'
'<h3>%s</h3>' % _('Access')
'<ul>'
if self.formdef.category:
categories = get_categories()
if categories:
'<li>%s ' % _('Category:')
'%s</li>' % self.formdef.category.name
if self.formdef.category:
self.formdef.category.name
else:
_('None')
' '
'(<a href="category" rel="popup">%s</a>)' % _('change')
'</li>'
if self.formdef.workflow:
'<li>%s ' % _('Workflow:')
'%s' % self.formdef.workflow.name
@ -381,7 +388,26 @@ class FormDefPage(Directory):
'<li><a href="invite">%s</a></li>' % _('Invites')
'</ul>'
def category [html] (self):
categories = get_categories()
form = Form(enctype='multipart/form-data')
form.add(SingleSelectWidget, 'category_id',
value=self.formdef.category_id,
options=[(None, '---')] + categories)
form.add_submit('submit', _('Submit'))
form.add_submit('cancel', _('Cancel'))
if form.get_widget('cancel').parse():
return redirect('.')
if not form.is_submitted() or form.has_errors():
get_response().breadcrumb.append( ('category', _('Category')) )
html_top('forms', title = self.formdef.name)
'<p>%s</p>' % _('Select a category for this form')
form.render()
else:
self.formdef.category_id = form.get_widget('category_id').parse()
self.formdef.store()
redirect('.')
def get_preview [html] (self):
form = Form()