loc = loc.parent # are we at the top? if loc is None: return locs def descendants(self, include_self=False): """Returns all of the locations which are descended from this location, optionally including itself in the output. This is very inefficient (it recurses once for EACH), so consider caching the output.""" locs = [self] if include_self else [] for loc in self.children.all(): locs.extend(loc.descendants(True)) return locs # TODO # WARNING # OH SHIT Reporter.add_to_class( "location", models.ForeignKey( Location, null=True, blank=True ) )
translation came from the database or a locale dict. It is created and returned by the Token.translate method when no "real" String instance exists, but a translation was found in a locale dict.""" def __init__(self, language, token, string): self.language = language self.token = token self.string = string def __unicode__(self): return self.string def __repr__(self): return '<%s: %s>' %\ (type(self).__name__, self.token) # if the reporters app happens to also be running, we # can provide some optional integration (see: app.py) if "reporters" in settings.RAPIDSMS_APPS: from reporters.models import Reporter Reporter.add_to_class( "language", models.ForeignKey( Language, null=True, blank=True))