# HG changeset patch # User Lennard de Rijk # Date 1250185613 25200 # Node ID 97a1569b2743031cbf2866d6289ba86de7b286b6 # Parent 4011d44ba0b6061e59b1eccaf64072c762320bbb Added methods that give the shipping information for a role entity. The shipping fields are only given when all the required address fields are set. Otherwise the residential fields are returned. diff -r 4011d44ba0b6 -r 97a1569b2743 app/soc/models/role.py --- a/app/soc/models/role.py Thu Aug 13 10:23:31 2009 -0700 +++ b/app/soc/models/role.py Thu Aug 13 10:46:53 2009 -0700 @@ -374,6 +374,43 @@ else: return self.name() + def shipping_street(self): + """Property shipping_street that returns shipping street if + shipping address is set else the residential street. + """ + return self.ship_street if self.hasShippingAddress() else self.res_street + + def shipping_city(self): + """Property shipping_city that returns shipping city if + shipping address is set else the residential city. + """ + return self.ship_city if self.hasShippingAddress() else self.res_city + + def shipping_state(self): + """Property shipping_state that returns shipping state if + shipping address is set else the residential state. + """ + return self.ship_state if self.hasShippingAddress() else self.res_state + + def shipping_country(self): + """Property shipping_country that returns shipping country if + shipping address is set else the residential country. + """ + return self.ship_country if self.hasShippingAddress() else self.res_country + + def shipping_postalcode(self): + """Property shipping_postalcode that returns the shipping postal code if + shipping address set else the residential postal code. + """ + return self.ship_postalcode if self.hasShippingAddress() else \ + self.res_postalcode + + def hasShippingAddress(self): + """Checks if the required fields for the shipping address are set. + """ + return self.ship_city and self.ship_country and self.ship_postalcode and \ + self.ship_street + def ccTld(self): """Property as 'ccTld' for use in Maps. """