def test_evacuated_population_needs(self): """Test evacuated_population_needs function.""" water = ResourceParameter() water.name = 'Water' water.unit.name = 'litre' water.unit.abbreviation = 'l' water.unit.plural = 'litres' water.frequency = 'weekly' water.maximum_allowed_value = 10 water.minimum_allowed_value = 0 water.value = 5 rice = ResourceParameter() rice.name = 'Rice' rice.unit.name = 'kilogram' rice.unit.abbreviation = 'kg' rice.unit.plural = 'kilograms' rice.frequency = 'daily' rice.maximum_allowed_value = 1 rice.minimum_allowed_value = 0 rice.value = 0.5 total_needs = evacuated_population_needs( 10, [water.serialize(), rice.serialize()]) self.assertEqual(total_needs['weekly'][0]['name'], 'Water') self.assertEqual(total_needs['weekly'][0]['amount'], 50) self.assertEqual(total_needs['weekly'][0]['table name'], 'Water [l]') self.assertEqual(total_needs['daily'][0]['name'], 'Rice') self.assertEqual(total_needs['daily'][0]['amount'], 5) self.assertEqual(total_needs['daily'][0]['table name'], 'Rice [kg]')
def test_evacuated_population_needs(self): """Test evacuated_population_needs function.""" water = ResourceParameter() water.name = 'Water' water.unit.name = 'litre' water.unit.abbreviation = 'l' water.unit.plural = 'litres' water.frequency = 'weekly' water.maximum_allowed_value = 10 water.minimum_allowed_value = 0 water.value = 5 rice = ResourceParameter() rice.name = 'Rice' rice.unit.name = 'kilogram' rice.unit.abbreviation = 'kg' rice.unit.plural = 'kilograms' rice.frequency = 'daily' rice.maximum_allowed_value = 1 rice.minimum_allowed_value = 0 rice.value = 0.5 total_needs = evacuated_population_needs( 10, [water.serialize(), rice.serialize()] ) self.assertEqual(total_needs['weekly'][0]['name'], 'Water') self.assertEqual(total_needs['weekly'][0]['amount'], 50) self.assertEqual(total_needs['weekly'][0]['table name'], 'Water [l]') self.assertEqual(total_needs['daily'][0]['name'], 'Rice') self.assertEqual(total_needs['daily'][0]['amount'], 5) self.assertEqual(total_needs['daily'][0]['table name'], 'Rice [kg]')
def default_minimum_needs(): """Helper to get the default minimum needs. .. note:: Key names will be translated. """ # TODO: update this to use parameters rice = ResourceParameter() rice.value = 2.8 rice.frequency = tr('weekly') rice.minimum_allowed_value = 1.4 rice.maximum_allowed_value = 5.6 rice.name = tr('Rice') rice.unit.abbreviation = tr('kg') rice.unit.name = tr('kilogram') rice.unit.plural = tr('kilograms') drinking_water = ResourceParameter() drinking_water.value = 17.5 drinking_water.frequency = tr('weekly') drinking_water.minimum_allowed_value = 10 drinking_water.maximum_allowed_value = 30 drinking_water.name = tr('Drinking Water') drinking_water.unit.abbreviation = tr('l') drinking_water.unit.name = tr('litre') drinking_water.unit.plural = tr('litres') water = ResourceParameter() water.value = 67 water.frequency = tr('weekly') water.minimum_allowed_value = 30 water.maximum_allowed_value = 100 water.name = tr('Clean Water') water.unit.abbreviation = tr('l') water.unit.name = tr('litre') water.unit.plural = tr('litres') family_kits = ResourceParameter() family_kits.value = 0.2 family_kits.frequency = tr('weekly') family_kits.minimum_allowed_value = 0.2 family_kits.maximum_allowed_value = 0.2 family_kits.name = tr('Family Kits') toilets = ResourceParameter() toilets.value = 0.05 toilets.frequency = tr('single') toilets.minimum_allowed_value = 0.02 toilets.maximum_allowed_value = 0.05 toilets.name = tr('Toilets') toilets.help_text = tr( 'Toilets are not provided on a regular basis - it is expected that ' 'installed toilets will continue to be usable.') provenance = default_provenance() minimum_needs = [ rice, drinking_water, water, family_kits, toilets, provenance ] return minimum_needs
def default_minimum_needs(): """Helper to get the default minimum needs. .. note:: Key names will be translated. """ # TODO: update this to use parameters rice = ResourceParameter() rice.value = 2.8 rice.frequency = 'weekly' rice.minimum_allowed_value = 1.4 rice.maximum_allowed_value = 5.6 rice.name = 'Rice' rice.unit.abbreviation = 'kg' rice.unit.name = 'kilogram' rice.unit.plural = 'kilograms' drinking_water = ResourceParameter() drinking_water.value = 17.5 drinking_water.frequency = 'weekly' drinking_water.minimum_allowed_value = 10 drinking_water.maximum_allowed_value = 30 drinking_water.name = 'Drinking Water' drinking_water.unit.abbreviation = 'l' drinking_water.unit.name = 'litre' drinking_water.unit.plural = 'litres' water = ResourceParameter() water.value = 67 water.frequency = 'weekly' water.minimum_allowed_value = 30 water.maximum_allowed_value = 100 water.name = 'Clean Water' water.unit.abbreviation = 'l' water.unit.name = 'litre' water.unit.plural = 'litres' family_kits = ResourceParameter() family_kits.value = 0.2 family_kits.frequency = 'weekly' family_kits.minimum_allowed_value = 0.2 family_kits.maximum_allowed_value = 0.2 family_kits.name = 'Family Kits' toilets = ResourceParameter() toilets.value = 0.05 toilets.frequency = 'single' toilets.minimum_allowed_value = 0.02 toilets.maximum_allowed_value = 0.05 toilets.name = 'Toilets' minimum_needs = [ rice, drinking_water, water, family_kits, toilets, ] return minimum_needs
def default_minimum_needs(): """Helper to get the default minimum needs. .. note:: Key names will be translated. """ # TODO: update this to use parameters rice = ResourceParameter() rice.value = 2.8 rice.frequency = tr("weekly") rice.minimum_allowed_value = 1.4 rice.maximum_allowed_value = 5.6 rice.name = tr("Rice") rice.unit.abbreviation = tr("kg") rice.unit.name = tr("kilogram") rice.unit.plural = tr("kilograms") drinking_water = ResourceParameter() drinking_water.value = 17.5 drinking_water.frequency = tr("weekly") drinking_water.minimum_allowed_value = 10 drinking_water.maximum_allowed_value = 30 drinking_water.name = tr("Drinking Water") drinking_water.unit.abbreviation = tr("l") drinking_water.unit.name = tr("litre") drinking_water.unit.plural = tr("litres") water = ResourceParameter() water.value = 67 water.frequency = tr("weekly") water.minimum_allowed_value = 30 water.maximum_allowed_value = 100 water.name = tr("Clean Water") water.unit.abbreviation = tr("l") water.unit.name = tr("litre") water.unit.plural = tr("litres") family_kits = ResourceParameter() family_kits.value = 0.2 family_kits.frequency = tr("weekly") family_kits.minimum_allowed_value = 0.2 family_kits.maximum_allowed_value = 0.2 family_kits.name = tr("Family Kits") toilets = ResourceParameter() toilets.value = 0.05 toilets.frequency = tr("single") toilets.minimum_allowed_value = 0.02 toilets.maximum_allowed_value = 0.05 toilets.name = tr("Toilets") toilets.help_text = tr( "Toilets are not provided on a regular basis - it is expected that " "installed toilets will continue to be usable." ) provenance = default_provenance() minimum_needs = [rice, drinking_water, water, family_kits, toilets, provenance] return minimum_needs
def get_needs_parameters(self): """Get the minimum needs resources in parameter format :returns: The minimum needs resources wrapped in parameters. :rtype: list """ parameters = [] for resource in self.minimum_needs['resources']: parameter = ResourceParameter() parameter.name = resource['Resource name'] parameter.help_text = resource['Resource description'] # Adding in the frequency property. This is not in the # FloatParameter by default, so maybe we should subclass. parameter.frequency = resource['Frequency'] parameter.description = self.format_sentence( resource['Readable sentence'], resource) parameter.minimum_allowed_value = float( resource['Minimum allowed']) parameter.maximum_allowed_value = float( resource['Maximum allowed']) parameter.unit.name = resource['Unit'] parameter.unit.plural = resource['Units'] parameter.unit.abbreviation = resource['Unit abbreviation'] parameter.value = float(resource['Default']) parameters.append(parameter) return parameters
def test_init(self): unit_feet = Unit("130790") unit_feet.load_dictionary(unit_feet_depth) unit_metres = Unit("900713") unit_metres.load_dictionary(unit_metres_depth) resource_parameter = ResourceParameter() resource_parameter.name = "Flood Depth" resource_parameter.is_required = True resource_parameter.precision = 3 resource_parameter.minimum_allowed_value = 1.0 resource_parameter.maximum_allowed_value = 2.0 resource_parameter.help_text = "The depth of flood." resource_parameter.description = ( "A <b>test _description</b> that is very long so that you need " "to read it for one minute and you will be tired after read this " "description. You are the best user so far. Even better if you " "read this description loudly so that all of your friends will be " "able to hear you" ) resource_parameter.unit = unit_feet resource_parameter.allowed_units = [unit_metres, unit_feet] resource_parameter.value = 1.12 widget = ResourceParameterWidget(resource_parameter) expected_value = resource_parameter.name real_value = widget._label.text() message = "Expected %s get %s" % (expected_value, real_value) self.assertEqual(expected_value, real_value, message) expected_value = resource_parameter.value real_value = widget.get_parameter().value message = "Expected %s get %s" % (expected_value, real_value) self.assertEqual(expected_value, real_value, message) widget.set_value(1.5) expected_value = 1.5 real_value = widget.get_parameter().value message = "Expected %s get %s" % (expected_value, real_value) self.assertEqual(expected_value, real_value, message) widget.set_value(1.55555) expected_value = 1.556 real_value = widget.get_parameter().value message = "Expected %s get %s" % (expected_value, real_value) self.assertEqual(expected_value, real_value, message) widget.set_value(7) expected_value = 2 real_value = widget.get_parameter().value message = "Expected %s get %s" % (expected_value, real_value) self.assertEqual(expected_value, real_value, message)
def test_init(self): unit_feet = Unit('130790') unit_feet.load_dictionary(unit_feet_depth) unit_metres = Unit('900713') unit_metres.load_dictionary(unit_metres_depth) resource_parameter = ResourceParameter() resource_parameter.name = 'Flood Depth' resource_parameter.is_required = True resource_parameter.precision = 3 resource_parameter.minimum_allowed_value = 1.0 resource_parameter.maximum_allowed_value = 2.0 resource_parameter.help_text = 'The depth of flood.' resource_parameter.description = ( 'A <b>test _description</b> that is very long so that you need ' 'to read it for one minute and you will be tired after read this ' 'description. You are the best user so far. Even better if you ' 'read this description loudly so that all of your friends will be ' 'able to hear you') resource_parameter.unit = unit_feet resource_parameter.allowed_units = [unit_metres, unit_feet] resource_parameter.value = 1.12 widget = ResourceParameterWidget(resource_parameter) expected_value = resource_parameter.name real_value = widget._label.text() message = 'Expected %s get %s' % (expected_value, real_value) self.assertEqual(expected_value, real_value, message) expected_value = resource_parameter.value real_value = widget.get_parameter().value message = 'Expected %s get %s' % (expected_value, real_value) self.assertEqual(expected_value, real_value, message) widget.set_value(1.5) expected_value = 1.5 real_value = widget.get_parameter().value message = 'Expected %s get %s' % (expected_value, real_value) self.assertEqual(expected_value, real_value, message) widget.set_value(1.55555) expected_value = 1.556 real_value = widget.get_parameter().value message = 'Expected %s get %s' % (expected_value, real_value) self.assertEqual(expected_value, real_value, message) widget.set_value(7) expected_value = 2 real_value = widget.get_parameter().value message = 'Expected %s get %s' % (expected_value, real_value) self.assertEqual(expected_value, real_value, message)
def test_build_form(self): """Test that we can build a form by passing params. """ dialog = FunctionOptionsDialog() # Define rice for minimum needs rice = ResourceParameter() rice.value = 2.8 rice.frequency = 'weekly' rice.minimum_allowed_value = 1.4 rice.maximum_allowed_value = 5.6 rice.name = 'Rice' rice.unit.abbreviation = 'kg' rice.unit.name = 'kilogram' rice.unit.plural = 'kilograms' # Define threshold threshold = InputListParameter() threshold.name = 'Thresholds [m]' threshold.is_required = True threshold.element_type = float threshold.expected_type = list threshold.ordering = InputListParameter.AscendingOrder threshold.minimum_item_count = 1 threshold.maximum_item_count = 3 threshold.value = [1.0] # default value parameter = { 'thresholds': threshold, 'postprocessors': OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ]), 'minimum needs': [rice] } dialog.build_form(parameter) message = 'There should be %s tabwidget but got %s' % ( 3, dialog.tabWidget.count()) self.assertEqual(dialog.tabWidget.count(), 3, message) children = dialog.tabWidget.findChildren(QLineEdit) message = 'There should be %s QLineEdit but got %s' % (5, len(children)) self.assertEqual(len(children), 5, message)
def get_needs_parameters(self): """Get the minimum needs resources in parameter format :returns: The minimum needs resources wrapped in parameters. :rtype: list """ parameters = [] for resource in self.minimum_needs['resources']: parameter = ResourceParameter() parameter.name = resource['Resource name'] parameter.help_text = resource['Resource description'] # Adding in the frequency property. This is not in the # FloatParameter by default, so maybe we should subclass. parameter.frequency = resource['Frequency'] parameter.description = self.format_sentence( resource['Readable sentence'], resource) parameter.minimum_allowed_value = float( resource['Minimum allowed']) parameter.maximum_allowed_value = float( resource['Maximum allowed']) parameter.unit.name = resource['Unit'] parameter.unit.plural = resource['Units'] parameter.unit.abbreviation = resource['Unit abbreviation'] parameter.value = float(resource['Default']) # choose highest precision between resource's parameters # start with default of 1 precisions = [1] precision_influence = [ 'Maximum allowed', 'Minimum allowed', 'Default'] for element in precision_influence: resource_element = str(resource[element]) if resource[element] is not None and '.' in resource_element: precisions.append(self.precision_of(resource_element)) parameter.precision = max(precisions) parameters.append(parameter) prov_parameter = TextParameter() prov_parameter.name = tr('Provenance') prov_parameter.description = tr('The provenance of minimum needs') prov_parameter.help_text = tr('The provenance of minimum needs') try: prov_parameter.value = self.provenance except TypeError: prov_parameter.value = '' parameters.append(prov_parameter) return parameters
def get_needs_parameters(self): """Get the minimum needs resources in parameter format :returns: The minimum needs resources wrapped in parameters. :rtype: list """ parameters = [] for resource in self.minimum_needs['resources']: parameter = ResourceParameter() parameter.name = resource['Resource name'] parameter.help_text = resource['Resource description'] # Adding in the frequency property. This is not in the # FloatParameter by default, so maybe we should subclass. parameter.frequency = resource['Frequency'] parameter.description = self.format_sentence( resource['Readable sentence'], resource) parameter.minimum_allowed_value = float( resource['Minimum allowed']) parameter.maximum_allowed_value = float( resource['Maximum allowed']) parameter.unit.name = resource['Unit'] parameter.unit.plural = resource['Units'] parameter.unit.abbreviation = resource['Unit abbreviation'] parameter.value = float(resource['Default']) # choose highest precision between resource's parameters # start with default of 1 precisions = [1] precision_influence = [ 'Maximum allowed', 'Minimum allowed', 'Default' ] for element in precision_influence: resource_element = str(resource[element]) if resource[element] is not None and '.' in resource_element: precisions.append(self.precision_of(resource_element)) parameter.precision = max(precisions) parameters.append(parameter) prov_parameter = TextParameter() prov_parameter.name = tr('Provenance') prov_parameter.description = tr('The provenance of minimum needs') prov_parameter.help_text = tr('The provenance of minimum needs') try: prov_parameter.value = self.provenance except TypeError: prov_parameter.value = '' parameters.append(prov_parameter) return parameters
def test_build_form(self): """Test that we can build a form by passing params. """ dialog = FunctionOptionsDialog() # Define rice for minimum needs rice = ResourceParameter() rice.value = 2.8 rice.frequency = 'weekly' rice.minimum_allowed_value = 1.4 rice.maximum_allowed_value = 5.6 rice.name = 'Rice' rice.unit.abbreviation = 'kg' rice.unit.name = 'kilogram' rice.unit.plural = 'kilograms' # Define threshold threshold = InputListParameter() threshold.name = 'Thresholds [m]' threshold.is_required = True threshold.element_type = float threshold.expected_type = list threshold.ordering = InputListParameter.AscendingOrder threshold.minimum_item_count = 1 threshold.maximum_item_count = 3 threshold.value = [1.0] # default value parameter = { 'thresholds': threshold, 'postprocessors': OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ]), 'minimum needs': [rice] } dialog.build_form(parameter) message = 'There should be %s tabwidget but got %s' % ( 3, dialog.tabWidget.count()) self.assertEqual(dialog.tabWidget.count(), 3, message) children = dialog.tabWidget.findChildren(QLineEdit) message = 'There should be %s QLineEdit but got %s' % ( 5, len(children)) self.assertEqual(len(children), 5, message)
def test_build_form(self): """Test that we can build a form by passing it a function and params. """ function_id = 'ITB Fatality Function' function_list = get_plugins(function_id) assert len(function_list) == 1 assert function_list[0].keys()[0] == function_id dialog = FunctionOptionsDialog() # Define rice for minimum needs rice = ResourceParameter() rice.value = 2.8 rice.frequency = 'weekly' rice.minimum_allowed_value = 1.4 rice.maximum_allowed_value = 5.6 rice.name = 'Rice' rice.unit.abbreviation = 'kg' rice.unit.name = 'kilogram' rice.unit.plural = 'kilograms' parameter = { 'thresholds': [1.0], 'postprocessors': { 'Gender': {'on': True}, 'Age': { 'on': True, 'params': { 'youth_ratio': 0.263, 'elderly_ratio': 0.078, 'adult_ratio': 0.659 } } }, 'minimum needs': [rice] } dialog.build_form(parameter) message = 'There should be %s tabwidget but got %s' % ( 3, dialog.tabWidget.count()) self.assertEqual(dialog.tabWidget.count(), 3, message) children = dialog.tabWidget.findChildren(QLineEdit) message = 'There should be %s QLineEdit but got %s' % ( 5, len(children)) self.assertEqual(len(children), 5, message)
def save_resource(self): """Accept the add/edit of the current resource. """ # -- # Hackorama to get this working outside the method that the # parameters where defined in. parameters_widget = [ self.parameters_scrollarea.layout().itemAt(i) for i in range(self.parameters_scrollarea.layout().count())][0] parameters = parameters_widget.widget().get_parameters() # To store parameters, we need the english version. translated_to_english = dict( (y, x) for x, y in self.resource_parameters.iteritems()) resource = {} for parameter in parameters: resource[translated_to_english[parameter.name]] = parameter.value # verify the parameters are ok - create a throw-away resource param try: parameter = ResourceParameter() parameter.name = resource['Resource name'] parameter.help_text = resource['Resource description'] # Adding in the frequency property. This is not in the # FloatParameter by default, so maybe we should subclass. parameter.frequency = resource['Frequency'] parameter.description = NeedsProfile.format_sentence( resource['Readable sentence'], resource) parameter.minimum_allowed_value = float( resource['Minimum allowed']) parameter.maximum_allowed_value = float( resource['Maximum allowed']) parameter.unit.name = resource['Unit'] parameter.unit.plural = resource['Units'] parameter.unit.abbreviation = resource['Unit abbreviation'] parameter.value = float(resource['Default']) except ValueOutOfBounds, e: warning = self.tr( 'Problem - default value is invalid') + '\n' + e.message # noinspection PyTypeChecker,PyArgumentList QMessageBox.warning(None, 'InaSAFE', warning) return
def save_resource(self): """Accept the add/edit of the current resource. """ # -- # Hackorama to get this working outside the method that the # parameters where defined in. parameters_widget = [ self.parameters_scrollarea.layout().itemAt(i) for i in range(self.parameters_scrollarea.layout().count()) ][0] parameters = parameters_widget.widget().get_parameters() # To store parameters, we need the english version. translated_to_english = dict( (y, x) for x, y in self.resource_parameters.iteritems()) resource = {} for parameter in parameters: resource[translated_to_english[parameter.name]] = parameter.value # verify the parameters are ok - create a throw-away resource param try: parameter = ResourceParameter() parameter.name = resource['Resource name'] parameter.help_text = resource['Resource description'] # Adding in the frequency property. This is not in the # FloatParameter by default, so maybe we should subclass. parameter.frequency = resource['Frequency'] parameter.description = NeedsProfile.format_sentence( resource['Readable sentence'], resource) parameter.minimum_allowed_value = float( resource['Minimum allowed']) parameter.maximum_allowed_value = float( resource['Maximum allowed']) parameter.unit.name = resource['Unit'] parameter.unit.plural = resource['Units'] parameter.unit.abbreviation = resource['Unit abbreviation'] parameter.value = float(resource['Default']) except ValueOutOfBounds, e: warning = self.tr( 'Problem - default value is invalid') + '\n' + e.message # noinspection PyTypeChecker,PyArgumentList QMessageBox.warning(None, 'InaSAFE', warning) return
def test_all(self): """Basic test of all properties.""" unit = Unit() unit.name = "meter" unit.plural = "metres" unit.abbreviation = "m" unit.description = (("<b>metres</b> are a metric unit of measure. There are 100 " "centimetres in 1 metre."),) unit.help_text = "Help for meter unit" parameter = ResourceParameter() parameter.is_required = True parameter.minimum_allowed_value = 1.0 parameter.maximum_allowed_value = 2.0 parameter.value = 1.123 parameter.frequency = "weekly" parameter.unit = unit self.assertEqual(1.123, parameter.value) self.assertDictEqual(unit.serialize(), parameter.unit.serialize()) self.assertEqual("weekly", parameter.frequency)
def test_all(self): """Basic test of all properties.""" unit = Unit() unit.name = 'meter' unit.plural = 'metres' unit.abbreviation = 'm' unit.description = ( '<b>metres</b> are a metric unit of measure. There are 100 ' 'centimetres in 1 metre.'), unit.help_text = 'Help for meter unit' parameter = ResourceParameter() parameter.is_required = True parameter.minimum_allowed_value = 1.0 parameter.maximum_allowed_value = 2.0 parameter.value = 1.123 parameter.frequency = 'weekly' parameter.unit = unit self.assertEqual(1.123, parameter.value) self.assertDictEqual(unit.serialize(), parameter.unit.serialize()) self.assertEqual('weekly', parameter.frequency)
def test_build_form(self): """Test that we can build a form by passing params. """ dialog = FunctionOptionsDialog() # Define rice for minimum needs rice = ResourceParameter() rice.value = 2.8 rice.frequency = 'weekly' rice.minimum_allowed_value = 1.4 rice.maximum_allowed_value = 5.6 rice.name = 'Rice' rice.unit.abbreviation = 'kg' rice.unit.name = 'kilogram' rice.unit.plural = 'kilograms' parameter = { 'thresholds': [1.0], 'postprocessors': OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ]), 'minimum needs': [rice] } dialog.build_form(parameter) message = 'There should be %s tabwidget but got %s' % ( 3, dialog.tabWidget.count()) self.assertEqual(dialog.tabWidget.count(), 3, message) children = dialog.tabWidget.findChildren(QLineEdit) message = 'There should be %s QLineEdit but got %s' % ( 5, len(children)) self.assertEqual(len(children), 5, message)
def default_minimum_needs(): """Helper to get the default minimum needs. .. note:: Key names will be translated. """ # TODO: update this to use parameters rice = ResourceParameter() rice.value = 2.8 rice.frequency = tr('weekly') rice.minimum_allowed_value = 1.4 rice.maximum_allowed_value = 5.6 rice.name = tr('Rice') rice.unit.abbreviation = tr('kg') rice.unit.name = tr('kilogram') rice.unit.plural = tr('kilograms') drinking_water = ResourceParameter() drinking_water.value = 17.5 drinking_water.frequency = tr('weekly') drinking_water.minimum_allowed_value = 10 drinking_water.maximum_allowed_value = 30 drinking_water.name = tr('Drinking Water') drinking_water.unit.abbreviation = tr('l') drinking_water.unit.name = tr('litre') drinking_water.unit.plural = tr('litres') water = ResourceParameter() water.value = 67 water.frequency = tr('weekly') water.minimum_allowed_value = 30 water.maximum_allowed_value = 100 water.name = tr('Clean Water') water.unit.abbreviation = tr('l') water.unit.name = tr('litre') water.unit.plural = tr('litres') family_kits = ResourceParameter() family_kits.value = 0.2 family_kits.frequency = tr('weekly') family_kits.minimum_allowed_value = 0.2 family_kits.maximum_allowed_value = 0.2 family_kits.name = tr('Family Kits') toilets = ResourceParameter() toilets.value = 0.05 toilets.frequency = tr('single') toilets.minimum_allowed_value = 0.02 toilets.maximum_allowed_value = 0.05 toilets.name = tr('Toilets') toilets.help_text = tr( 'Toilets are not provided on a regular bases - it is expected that ' 'installed toilets will be usable on a continuous basis.' ) minimum_needs = [ rice, drinking_water, water, family_kits, toilets, ] return minimum_needs