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

Commit

Permalink
Remove support for form buttons - it doesn't make sense for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Krienbühl committed May 19, 2015
1 parent 0b517f8 commit 616fbb5
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 71 deletions.
3 changes: 0 additions & 3 deletions onegov/form/parser/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ class (not an instance of it).
if block.type == 'fieldset':
builder.set_current_fieldset(block.label or None)

elif block.type == 'button':
raise NotImplementedError

elif block.type == 'text':
if block.length:
validators = [Length(max=block.length)]
Expand Down
41 changes: 0 additions & 41 deletions onegov/form/parser/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,6 @@
# ...
I don't belong to a Fieldset = ___
Buttons
-------
Buttons come in two versions. One without address, and one with. If there's no
address, the button POSTs to the current url. If there is an url, the button
POSTs the form the the given url.
For example::
[Submit to current URL]
[Submit to another URL](http://my-post-address.com)
You'll notice that this looks just like a Markdown link.
Available Fields
----------------
Expand Down Expand Up @@ -414,32 +400,6 @@ def custom():
return custom


def button():
""" Returns a buttons parser.
Examples::
[Send]
[Send](http://my-post-address.com)
By default, buttons post to the form.
"""

characters = with_whitespace_inside(text_without('[]'))

label = Combine(OneOrMore(characters))('label')
label.setParseAction(lambda t: t[0])

url = OneOrMore(text_without('()'))('url').setParseAction(lambda t: t[0])

button = Suppress('[') + label + Suppress(']')
button += Optional(Suppress('(') + url + Suppress(')'))
button.setParseAction((tag(type='button')))

return button


def fieldset_title():
""" A fieldset title parser. Fieldset titles are just like headings in
markdown::
Expand Down Expand Up @@ -492,7 +452,6 @@ def block_content():
identifier = field_identifier()

return MatchFirst([
button(),
fieldset_title(),
identifier + (textfield() | textarea() | password() | custom()),
identifier + OneOrMore(Optional(LE) + radios())('parts'),
Expand Down
28 changes: 1 addition & 27 deletions onegov/form/tests/test_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import textwrap

from onegov.form.parser.grammar import (
button,
custom,
document,
field_identifier,
Expand Down Expand Up @@ -137,24 +136,6 @@ def test_custom():
assert f.asDict() == {'type': 'custom', 'custom_id': 'stripe'}


def test_button():

btn = button()

f = btn.parseString("[Click Me!](https://www.google.ch)")
assert f.asDict() == {
'type': 'button',
'label': 'Click Me!',
'url': 'https://www.google.ch'
}

f = btn.parseString("[Send]")
assert f.asDict() == {
'type': 'button',
'label': 'Send'
}


def test_document():
# a form that includes all the features available
form = textwrap.dedent("""
Expand All @@ -175,12 +156,10 @@ def test_document():
Password = ***
Comment = ...
E-Mail = /E-Mail
[Submit](https://www.google.ch)
""")

result = document().searchString(form)
assert len(result) == 11
assert len(result) == 10

assert result[0].asDict() == {'label': 'Name', 'type': 'fieldset'}

Expand Down Expand Up @@ -236,11 +215,6 @@ def test_document():
'type': 'custom',
'custom_id': 'e-mail'
}
assert result[10].asDict() == {
'label': 'Submit',
'type': 'button',
'url': 'https://www.google.ch'
}


def test_multiline_checkboxes():
Expand Down

0 comments on commit 616fbb5

Please sign in to comment.