Changeset - a283988896b3
[Not reviewed]
0 1 0
Lance Edgar (lance) - 2 years ago 2022-08-09 14:35:57
lance@edbob.org
Add `choice_uses_dropdown()` method for customer handler
1 file changed with 15 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rattail/clientele.py
Show inline comments
 
# -*- coding: utf-8; -*-
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2021 Lance Edgar
 
#  Copyright © 2010-2022 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
#  Rattail is free software: you can redistribute it and/or modify it under the
 
#  terms of the GNU General Public License as published by the Free Software
 
#  Foundation, either version 3 of the License, or (at your option) any later
 
@@ -32,12 +32,26 @@ from rattail.app import GenericHandler
 

	
 
class ClienteleHandler(GenericHandler):
 
    """
 
    Base class and default implementation for clientele handlers.
 
    """
 

	
 
    def choice_uses_dropdown(self):
 
        """
 
        Returns boolean indicating whether a customer choice should be
 
        presented to the user via a dropdown (select) element, vs.  an
 
        autocomplete field.  The latter is the default because
 
        potentially the customer list can be quite large, so we avoid
 
        loading them all in the dropdown unless so configured.
 

	
 
        :returns: Boolean; if true then a dropdown should be used;
 
           otherwise (false) autocomplete is used.
 
        """
 
        return self.config.getbool('rattail', 'customers.choice_uses_dropdown',
 
                                   default=False)
 

	
 
    def ensure_customer(self, person):
 
        """
 
        Returns the customer record associated with the given person, creating
 
        it first if necessary.
 
        """
 
        customer = self.get_customer(person)
0 comments (0 inline, 0 general)