Fixes in libraries
This commit is contained in:
parent
6a68dcd47c
commit
4d814326e0
6 changed files with 41 additions and 37 deletions
|
|
@ -122,6 +122,12 @@ class FloatField(PhangoField):
|
|||
|
||||
return 'FLOAT NOT NULL DEFAULT "0"'
|
||||
|
||||
class DecimalField(FloatField):
|
||||
|
||||
def get_type_sql(self):
|
||||
|
||||
return 'DECIMAL(20, 2) NOT NULL DEFAULT "0"'
|
||||
|
||||
class DoubleField(FloatField):
|
||||
|
||||
def get_type_sql(self):
|
||||
|
|
|
|||
|
|
@ -66,12 +66,17 @@ class TextForm(BaseForm):
|
|||
|
||||
class PasswordForm(BaseForm):
|
||||
|
||||
def __init__(self, name, value):
|
||||
def __init__(self, name, value, show_password=False):
|
||||
super(PasswordForm, self).__init__(name, value)
|
||||
self.type='password'
|
||||
self.show_password=show_password
|
||||
|
||||
def setform(self, value):
|
||||
return ""
|
||||
if not self.show_password:
|
||||
return ""
|
||||
|
||||
else:
|
||||
return value
|
||||
|
||||
class HiddenForm(BaseForm):
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
from paramecio2.libraries.db.corefields import FloatField
|
||||
from paramecio2.libraries.db.corefields import DecimalField
|
||||
from decimal import Decimal, getcontext
|
||||
from locale import format_string
|
||||
|
||||
getcontext().prec=2
|
||||
|
||||
class MoneyField(FloatField):
|
||||
class MoneyField(DecimalField):
|
||||
|
||||
def __init__(self, name, required=False):
|
||||
|
||||
|
|
@ -23,4 +23,5 @@ class MoneyField(FloatField):
|
|||
@staticmethod
|
||||
def format_money(value):
|
||||
return format_string('%.2f', Decimal(value), grouping=True)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue