Added a 'hide' option to form definitions which lets you hide the form in the list. You can still refer to it in other ways, if you know its name.

pull/7/head
Ferry Boender 10 years ago
parent d12361c0ca
commit df1b173d2a
  1. 8
      doc/MANUAL.md
  2. 6
      src/scriptform.py

@ -153,8 +153,12 @@ Structurally, they are made up of the following elements:
- **`required`**: Whether the field is required. **Optional**, - **`required`**: Whether the field is required. **Optional**,
**Boolean**. **Boolean**.
- **`...`**: Other options, which depend on the type of field. - **`hide`**: If 'true', don't show the form in the list. You can still
**Optional**. view it, if you know its name. This is useful for other forms to
redirect to this forms and such.
- **`...`**: Other options, which depend on the type of field. For
more information, see [Field types](#field_types). **Optional**.
- **`allowed_users`**: A list of users that are allowed to view and submit - **`allowed_users`**: A list of users that are allowed to view and submit
this form. **Optional**, **List of strings**. this form. **Optional**, **List of strings**.

@ -200,6 +200,7 @@ class ScriptForm:
form['fields'], form['fields'],
script, script,
output=form.get('output', 'escaped'), output=form.get('output', 'escaped'),
hide=form.get('hide', False),
submit_title=form.get('submit_title', 'Submit'), submit_title=form.get('submit_title', 'Submit'),
allowed_users=form.get('allowed_users', None)) allowed_users=form.get('allowed_users', None))
) )
@ -303,7 +304,7 @@ class FormDefinition:
for validation of the form values. for validation of the form values.
""" """
def __init__(self, name, title, description, fields, script, def __init__(self, name, title, description, fields, script,
output='escaped', submit_title="Submit", output='escaped', hide=False, submit_title="Submit",
allowed_users=None): allowed_users=None):
self.name = name self.name = name
self.title = title self.title = title
@ -311,6 +312,7 @@ class FormDefinition:
self.fields = fields self.fields = fields
self.script = script self.script = script
self.output = output self.output = output
self.hide = hide
self.submit_title = submit_title self.submit_title = submit_title
self.allowed_users = allowed_users self.allowed_users = allowed_users
@ -604,6 +606,8 @@ class ScriptFormWebApp(WebAppHandler):
if form_def.allowed_users is not None and \ if form_def.allowed_users is not None and \
self.username not in form_def.allowed_users: self.username not in form_def.allowed_users:
continue # User is not allowed to run this form continue # User is not allowed to run this form
if form_def.hide:
continue # Don't show hidden forms in the list.
h_form_list.append(u''' h_form_list.append(u'''
<li> <li>
<h2 class="form-title">{title}</h2> <h2 class="form-title">{title}</h2>

Loading…
Cancel
Save