def test_no_translation(): """ `no_translation` provides a context where only the default language is active. """ lang = translation.get_language() translation.activate('pt-br') with no_translation(): eq_(translation.get_language(), settings.LANGUAGE_CODE) eq_(translation.get_language(), 'pt-br') with no_translation('es'): eq_(translation.get_language(), 'es') eq_(translation.get_language(), 'pt-br') translation.activate(lang)
def get_iarc_app_title(app): """Delocalized app name.""" from mkt.webapps.models import Webapp with no_translation(app.default_locale): delocalized_app = Webapp.with_deleted.get(pk=app.pk) return unicode(delocalized_app.name)
def app_data(app): """App data that IARC needs in PushCert response / AttachToCert request.""" author = app.listed_authors[0] if app.listed_authors else UserProfile() with no_translation(app.default_locale): app_name = unicode(Webapp.with_deleted.get(pk=app.pk).name) data = { 'Publish': app.is_public(), 'ProductName': app_name, 'StoreProductID': app.guid, 'StoreProductURL': absolutify(app.get_url_path()), # We want an identifier that does not change when users attached to # an app are shuffled around, so just use the app PK as developer id. 'StoreDeveloperID': app.pk, # PushCert and AttachToCert docs use a different property for the # developer email address, use both just in case. 'DeveloperEmail': author.email, 'EmailAddress': author.email, 'CompanyName': app.developer_name, } return data
def get_device_types(self, app): with no_translation(): return [n.api_name for n in app.device_types]
def device_names(self): device_ids = self.devices or [] with no_translation(): return [DEVICE_TYPES[d].api_name for d in device_ids]