Changeset a637ba1 in tailbone


Ignore:
Timestamp:
12/18/18 17:41:38 (8 months ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
5151e2d
Parents:
3e9fdba
Message:

Add 'percent' as field type for Form; fix rendering of 'percent' for Grid

these both now assume the value obtained will be a "typical" percentage
decimal, i.e. 0.30130 instead of 30.130

Location:
tailbone
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tailbone/forms/core.py

    r3e9fdba ra637ba1  
    587587        elif type_ == 'quantity':
    588588            self.set_renderer(key, self.render_quantity)
     589        elif type_ == 'percent':
     590            self.set_renderer(key, self.render_percent)
    589591        elif type_ == 'gpc':
    590592            self.set_renderer(key, self.render_gpc)
     
    813815        return pretty_quantity(value)
    814816
     817    def render_percent(self, obj, field):
     818        value = self.obtain_value(obj, field)
     819        if value is None:
     820            return ""
     821        return "{:0.3f} %".format(value * 100)
     822
    815823    def render_gpc(self, obj, field):
    816824        value = self.obtain_value(obj, field)
  • tailbone/grids/core.py

    r3e9fdba ra637ba1  
    272272        if value is None:
    273273            return ""
    274         return "{:0.2f}".format(value)
     274        return "{:0.3f} %".format(value * 100)
    275275
    276276    def render_quantity(self, obj, column_name):
Note: See TracChangeset for help on using the changeset viewer.