class StoryTemplateTranslation(TranslationModel): """Translatable fields for the StoryTemplate model""" story_template = models.ForeignKey('StoryTemplate') title = ShortTextField() tag_line = ShortTextField(blank=True) description = models.TextField(blank=True) def __unicode__(self): return self.title
class Location(LocationPermission, DirtyFieldsMixin, models.Model): """A location with a specific address or latitude and longitude""" location_id = UUIDField(auto=True, verbose_name=_("Location ID"), db_index=True) name = ShortTextField(_("Name"), blank=True) address = ShortTextField(_("Address"), blank=True) address2 = ShortTextField(_("Address 2"), blank=True) city = models.CharField(_("City"), max_length=255, blank=True) state = models.CharField(_("State"), max_length=255, blank=True, choices=STATE_CHOICES) postcode = models.CharField(_("Postal Code"), max_length=255, blank=True) lat = models.FloatField(_("Latitude"), blank=True, null=True) lng = models.FloatField(_("Longitude"), blank=True, null=True) point = models.PointField(_("Point"), blank=True, null=True) # I'm not sure what the best solution for parsing addresses is, or # what the best geocoder is for our application, or how users are # going to use this feature. So rather than spending a bunch of time # writing/testing an address parser (or picking a particular geocoder # that breaks an address into pieces), just have a place to store # the raw address provided by the user. This will, at the very least, # give us a domain-specific set of addresses to test against. raw = models.TextField(_("Raw Address"), blank=True) owner = models.ForeignKey(User, related_name="locations", blank=True, null=True) objects = models.GeoManager() def __unicode__(self): if self.name: unicode_rep = u"%s" % self.name elif self.address or self.city or self.state or self.postcode: unicode_rep = u", ".join([self.address, self.city, self.state]) unicode_rep = u" ".join([unicode_rep, self.postcode]) else: return u"Location %s" % self.location_id return unicode_rep def _geocode(self, address): point = None geocoder = get_geocoder() # There might be more than one matching location. For now, just # assume the first one. results = list(geocoder.geocode(address, exactly_one=False)) if results: place, (lat, lng) = results[0] point = (lat, lng) return point
class SectionLayoutTranslation(TranslationModel): """Translatable fields for the SectionLayout model""" layout = models.ForeignKey('SectionLayout') name = ShortTextField() def __unicode__(self): return self.name
class Place(node_factory('PlaceRelation')): """ A larger scale geographic area such as a neighborhood or zip code Places are related hierachically using a directed graph as a place can have multiple parents. """ name = ShortTextField(_("Name")) geolevel = models.ForeignKey(GeoLevel, null=True, blank=True, related_name='places', verbose_name=_("GeoLevel")) boundary = models.MultiPolygonField(blank=True, null=True, verbose_name=_("Boundary")) place_id = UUIDField(auto=True, verbose_name=_("Place ID"), db_index=True) slug = models.SlugField(blank=True) def get_absolute_url(self): return reverse('place_stories', kwargs={'slug': self.slug}) def __unicode__(self): return self.name
class DataSetTranslation(TranslationModel): """Translatable fields for a DataSet model instance""" dataset = models.ForeignKey('DataSet', related_name="%(app_label)s_%(class)s_related") title = ShortTextField() description = models.TextField(blank=True) class Meta: unique_together = (('dataset', 'language'))
class ProjectTranslation(TranslationModel): project = models.ForeignKey('Project') name = ShortTextField(verbose_name=_("Project Name")) description = models.TextField() class Meta: unique_together = (('project', 'language')) def __unicode__(self): return self.name
class OrganizationTranslation(TranslationModel, TimestampedModel): organization = models.ForeignKey('Organization') name = ShortTextField(verbose_name=_("Organization Name")) description = models.TextField() class Meta: unique_together = (('organization', 'language')) def __unicode__(self): return self.name
class SiteContactMessage(models.Model): """A message to the site administrators""" name = ShortTextField(_("Your Name")) email = models.EmailField(_("Your Email")) phone = models.CharField(_("Your Phone Number"), max_length=20, blank=True) message = models.TextField(_("Your Message")) created = models.DateTimeField(_("Message Created"), auto_now_add=True) def __unicode__(self): return unicode(_("Message from ") + self.email)
class SectionTranslation(TranslationModel): """Translated fields of a Section""" section = models.ForeignKey('Section') title = ShortTextField() class Meta: """Model metadata options""" unique_together = (('section', 'language')) def __unicode__(self): return self.title
class NewsItemTranslation(TranslationModel): news_item = models.ForeignKey('NewsItem') title = ShortTextField(blank=True) body = models.TextField(blank=True) image = FilerImageField(null=True) class Meta: """Model metadata options""" unique_together = (('news_item', 'language')) def __unicode__(self): return self.title
class AssetTranslation(TranslationModel): """ Abstract base class for common translated metadata fields for Asset instances """ asset = models.ForeignKey('Asset', related_name="%(app_label)s_%(class)s_related") title = ShortTextField(blank=True) caption = models.TextField(blank=True) class Meta: abstract = True unique_together = (('asset', 'language'))
class StoryTranslation(TranslationModel): """Encapsulates translated fields of a Story""" story = models.ForeignKey('Story') title = ShortTextField(blank=True) summary = models.TextField(blank=True) call_to_action = models.TextField(_("Call to Action"), blank=True) class Meta: """Model metadata options""" unique_together = (('story', 'language')) def __unicode__(self): return self.title
class ActivityTranslation(TranslationModel): activity = models.ForeignKey('Activity') title = ShortTextField() description = models.TextField() supplies = models.TextField(blank=True, verbose_name=_("Required supplies")) time = models.CharField(max_length=200, blank=True, verbose_name=_("Time it takes to do")) num_participants = models.CharField( max_length=200, blank=True, verbose_name=_("Number of participants")) # This is a text field, rather than something more structured, # because there are a variable number of handouts, and each handout # can have a variable number of formats (PDF, Google Doc, Floodlight # Story, etc.) links = models.TextField( blank=True, verbose_name=_("Links to the full activity"), help_text=_("These are materials/handouts we have been using in " "Story-Rasings"))
class HelpTranslation(TranslationModel): help = models.ForeignKey('Help') title = ShortTextField(blank=True) body = models.TextField(blank=True)
class MessageTranslation(TranslationModel): subject = ShortTextField() body = models.TextField() class Meta: abstract = True