Andriy Kornatskyy avatar 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'))
+    )
 }
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.