#-*- coding: utf-8 -*-
#=============================================================================== # Addresses handling #===============================================================================
""" Get the shipping address from the request. This abstracts the fact that users can be either registered (and thus, logged in), or only session-based guests """ # There is a logged-in user here, but he might not have an address defined. else: # The client is a guest - let's use the session instead.
""" Get the billing address from the request. This abstracts the fact that users can be either registered (and thus, logged in), or only session-based guests """ # There is a logged-in user here, but he might not have an address defined. else: # The client is a guest - let's use the session instead.
""" Sets the passed address as either the shipping or the billing address for the passed request. This abstracts the difference between logged-in users and session-based guests.
The `shipping` parameter controls whether the address is a shipping address (default) or a billing address. """ # There is a logged-in user here. else: else: # The client is a guest - let's use the session instead. # There has to be a session. Otherwise it's fine to get an AttributeError else:
""" Simple helper to return the username from the request, or '' if the user is AnonymousUser. """ name = '' if request.user and not isinstance(request.user, AnonymousUser): name = request.user.get_full_name() # TODO: Administrators! return name |