Commits

Andriy Kornatskyy committed 8f69aa4

Added example for vocabulary that honor user order.

Comments (0)

Files changed (2)

demos/template/src/membership/repository/mock.py

         return tuple(sorted_items(self.password_questions(locale)))
 
     def account_types(self, locale):
-        return map_values(ref_gettext(translations[locale]),
-                          db['account_type'])
+        return dict(self.list_account_types(locale))
 
     def list_account_types(self, locale):
-        return tuple(sorted_items(self.account_types(locale)))
+        gettext = ref_gettext(translations[locale])
+        return tuple((k, gettext(v)) for k, v in db['account_type'])
 
     def authenticate(self, credential):
         return credential.password == db['user'].get(

demos/template/src/membership/repository/samples.py

         'demo': ['user'],
         'biz': ['business']
     },
+    # the order is set by key
     'password_question': {
         '1': _('Favorite number'),
         '2': _('City of birth'),
         '3': _('Favorite color')
     },
-    'account_type': {
-        'user': _('User'),
-        'business': _('Business')
-    }
+    # honor custom order
+    'account_type': (
+        ('user', _('User')),
+        ('business', _('Business'))
+    )
 }