-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ControlDecimal and fix the ModelForm
- Loading branch information
1 parent
367230e
commit 6acdd4b
Showing
6 changed files
with
38 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from pyforms_web.controls.control_base import ControlBase | ||
import simplejson, decimal | ||
|
||
class ControlDecimal(ControlBase): | ||
|
||
def init_form(self): | ||
return """new ControlFloat('{0}', {1})""".format( | ||
self._name, | ||
simplejson.dumps(self.serialize()) | ||
) | ||
|
||
|
||
def deserialize(self, properties): | ||
""" | ||
Serialize the control data. | ||
:param dict properties: Serialized data to load. | ||
""" | ||
super().deserialize(properties) | ||
|
||
str_val = properties.get('value', None) | ||
|
||
self.value = decimal.Decimal(str_val) if str_val else None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters