def customer_catalogs_to_transmit(self): """ Return the list of EnterpriseCustomerCatalog objects. """ catalogs_list = [] if self.catalogs_to_transmit: catalogs_list = EnterpriseCustomerCatalog.objects.filter( uuid__in=convert_comma_separated_string_to_list( self.catalogs_to_transmit)) return catalogs_list
def clean(self): invalid_uuids = [] for uuid in convert_comma_separated_string_to_list( self.catalogs_to_transmit): try: EnterpriseCustomerCatalog.objects.get( uuid=uuid, enterprise_customer=self.enterprise_customer) except (EnterpriseCustomerCatalog.DoesNotExist, ValidationError): invalid_uuids.append(str(uuid)) if invalid_uuids: raise ValidationError({ 'catalogs_to_transmit': [ "These are the invalid uuids: {invalid_uuids}".format( invalid_uuids=invalid_uuids) ] })
def get_locales(self, default_locale=None): """ Get the list of all(default + additional) locales Args: default_locale (str): Value of the default locale Returns: list: available locales """ locales = [] if default_locale is None: locales.append('English') else: locales.append(default_locale) return set( locales + convert_comma_separated_string_to_list(self.additional_locales))