mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
make sure to set card model id when creating cards, tweak code formatting
This commit is contained in:
parent
f5facee398
commit
d7961413b4
2 changed files with 9 additions and 7 deletions
|
@ -83,6 +83,8 @@ class Card(object):
|
||||||
self.fact = fact
|
self.fact = fact
|
||||||
if cardModel:
|
if cardModel:
|
||||||
self.cardModel = cardModel
|
self.cardModel = cardModel
|
||||||
|
# for non-orm use
|
||||||
|
self.cardModelId = cardModel.id
|
||||||
self.ordinal = cardModel.ordinal
|
self.ordinal = cardModel.ordinal
|
||||||
d = {}
|
d = {}
|
||||||
for f in self.fact.model.fieldModels:
|
for f in self.fact.model.fieldModels:
|
||||||
|
|
|
@ -111,18 +111,18 @@ def _pluralCount(time):
|
||||||
return 1
|
return 1
|
||||||
return round(time, 1)
|
return round(time, 1)
|
||||||
|
|
||||||
# locale
|
# Locale
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
def fmtPercentage(float_value, point=1):
|
def fmtPercentage(float_value, point=1):
|
||||||
"Return string representing a float respecting current locale followed by a percentage sign"
|
"Return float with percentage sign"
|
||||||
fmt = '%' + "0.%(b)df" % {'b': point}
|
fmt = '%' + "0.%(b)df" % {'b': point}
|
||||||
return locale.format_string(fmt, float_value) + "%"
|
return locale.format_string(fmt, float_value) + "%"
|
||||||
|
|
||||||
def fmtFloat(float_value, point=1):
|
def fmtFloat(float_value, point=1):
|
||||||
"Return a string representing a float with decimal separator according to current locale"
|
"Return a string with decimal separator according to current locale"
|
||||||
fmt = '%' + "0.%(b)df" % {'b': point}
|
fmt = '%' + "0.%(b)df" % {'b': point}
|
||||||
return locale.format_string(fmt, float_value)
|
return locale.format_string(fmt, float_value)
|
||||||
|
|
||||||
# HTML
|
# HTML
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
Loading…
Reference in a new issue