Commits

Hynek Cernoch committed 8e2a043

Fixed PercentValue by set it deprecated. Closes #29

Comments (0)

Files changed (4)

     * Duration
     * Float
     * Integer
-    * Percent
     * Positive Integer
     * String
     * Long string
     {   1: {   'DB': False,
                'SETTINGS': {   u'MyApp': {   u'DECIMAL_TEST': u'34.0923443',
                                              u'MEASUREMENT_SYSTEM': u'["metric"]',
-                                             u'PERCENT_TEST': u'0.251'}}}}
+                                             u'STRING_TEST': u'Orange'}}}}
 
 In order to restrict or enable DB access, use the following line in your settings::
 

livesettings/tests.py

         test_empty_value_type(DurationValue, protocol)
         test_empty_value_type(FloatValue, protocol)
         test_empty_value_type(IntegerValue, protocol)
-        test_empty_value_type(PercentValue, protocol)
         test_empty_value_type(PositiveIntegerValue, protocol)
         test_empty_value_type(StringValue, protocol)
         test_empty_value_type(LongStringValue, protocol)
         test_empty_value_type(PasswordValue, protocol)
         # verify completness of the test
         classes_to_test = set(getattr(livesettings.values, k) for k in livesettings.values.__all__ if \
-                not k in ('BASE_GROUP', 'ConfigurationGroup', 'Value', 'SortedDotDict'))
+                not k in ('BASE_GROUP', 'ConfigurationGroup', 'Value', 'SortedDotDict', 'PercentValue'))
         self.assertEqual(protocol, classes_to_test, msg='The tested classes have been not all exactly the same as expected')
 
     def test_csrf(self):

livesettings/values.py

             return unicode(value)
 
 
+# Deprecated PercentValue does not work good and can not be fixed
+# without duplicating long modified parts of Django. #29
+# It is better to Replace PercentValue(...) by DecimalValue(... min_value=0, max_value=100, max_decimal_places=2)
+# and easily divide result value by 100 in the user application.
 class PercentValue(Value):
 
     class field(forms.DecimalField):
 
         def __init__(self, *args, **kwargs):
+            import warnings
+            warnings.warn(
+                "class livesettings.PercentValue is deprecated. It should be replaced in config.py by " \
+                "DecimalValue(... min_value=0, max_value=100) and the result divided by 100 in the app.",
+                DeprecationWarning
+            )
             kwargs['required'] = False
             forms.DecimalField.__init__(self, 100, 0, 5, 2, *args, **kwargs)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.