Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Commit

Permalink
Adds a password field
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Krienbühl committed May 12, 2015
1 parent d7ec7ee commit 1f002ed
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
22 changes: 21 additions & 1 deletion onegov/form/parser/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ def textfield():
return textfield


def password():
""" Returns a password field parser.
Example:
***
"""

password = Literal('***')
password = password.setParseAction(tag(type='password'))

return password


def radio_buttons():
""" Returns a radio buttons parser.
Expand Down Expand Up @@ -183,7 +197,13 @@ def fieldset_title():


# put together the actual grammar
fields = Group(textfield() | radio_buttons() | checkboxes() | select())
fields = Group(
textfield() |
radio_buttons() |
checkboxes() |
select() |
password()
)

field = field_declaration() + fields.setResultsName('field')
field = field.setParseAction(tag(type='field'))
Expand Down
8 changes: 8 additions & 0 deletions onegov/form/tests/test_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ def test_textfield():
assert f.field.length == 25


def test_password():

f = field.parseString("Passwort* = ***")
assert f.label == "Passwort"
assert f.required
assert f.field.type == 'password'


def test_radiobutton():

f = field.parseString("Gender* = () Male (x) Female")
Expand Down

0 comments on commit 1f002ed

Please sign in to comment.