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**,
**Boolean**.
- **`...`**: Other options, which depend on the type of field.
**Optional**.
- **`hide`**: If 'true', don't show the form in the list. You can still
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
this form. **Optional**, **List of strings**.

@ -200,6 +200,7 @@ class ScriptForm:
form['fields'],
script,
output=form.get('output', 'escaped'),
hide=form.get('hide', False),
submit_title=form.get('submit_title', 'Submit'),
allowed_users=form.get('allowed_users', None))
)
@ -303,7 +304,7 @@ class FormDefinition:
for validation of the form values.
"""
def __init__(self, name, title, description, fields, script,
output='escaped', submit_title="Submit",
output='escaped', hide=False, submit_title="Submit",
allowed_users=None):
self.name = name
self.title = title
@ -311,6 +312,7 @@ class FormDefinition:
self.fields = fields
self.script = script
self.output = output
self.hide = hide
self.submit_title = submit_title
self.allowed_users = allowed_users
@ -604,6 +606,8 @@ class ScriptFormWebApp(WebAppHandler):
if form_def.allowed_users is not None and \
self.username not in form_def.allowed_users:
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'''
<li>
<h2 class="form-title">{title}</h2>

Loading…
Cancel
Save