[Tutor] Help

Alan Gauld alan.gauld at yahoo.co.uk
Wed Jun 2 05:25:48 EDT 2021


On 02/06/2021 08:33, R M wrote:
> I have this code and want to change it to stop calculating percentage. 

You need to give us more information and a more precise
description.

In the code below nothing is displaying anything, let
alone a percentage.

Most of the work is being done by SiteConfog methods
which we can't see. unless these are the SireConfig
methods? Its not obvious. And we certainly don't know
anything about the objects attribute and its
get_or_create() method.

Which method do you think is returning a percentage?

You can usually convert a percentage to a value
by multiplying by 100.


Let it just display the value what do I need to do?
> 
>     @staticmethod
>     def get_default_loan_processing_fee():
>         config, _ = SiteConfig.objects.get_or_create(conf_key=constants.SITE_CONFIG_KEY_LOAN_PROCESSING_FEES,
>                                                      defaults={"value": '0', 'type': SiteConfig.TYPE_INT})
> 
>         return config
> 
>     @staticmethod
>     def get_default_loan_processing_fee_value():
>         site_config = SiteConfig.get_default_loan_processing_fee()
>         return decimal(site_config.value)
> 
>     @staticmethod
>     def set_default_loan_processing_fee_value(value):
>         config, _ = SiteConfig.objects.update_or_create(conf_key=constants.SITE_CONFIG_KEY_LOAN_PROCESSING_FEES,
>                                                         defaults={"value": '%s' % value})
>         return config


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list