Пример #1
0
    def save(self, *args, **kwargs):
        slug_field = self._meta.get_field('slug')

        # we need to manually use autoslug utils here with ModelManager, because automatic slug populating
        # uses our default manager, which can lead to a slug collision between this and a deleted hearing
        self.slug = generate_unique_slug(slug_field, self, self.slug,
                                         Hearing.original_manager)

        self.geometry = get_geometry_from_geojson(self.geojson)

        super().save(*args, **kwargs)
Пример #2
0
 def save(self, *args, **kwargs):
     if not any(
         (getattr(self, field) for field in self.fields_to_check_for_data)):
         raise ValidationError(
             "You must supply at least one of the following data in a comment: "
             + str(self.fields_to_check_for_data))
     if not self.author_name and self.created_by_id:
         self.author_name = (self.created_by.get_display_name() or None)
     if not self.language_code and self.content:
         self._detect_lang()
     self.geometry = get_geometry_from_geojson(self.geojson)
     return super(BaseComment, self).save(*args, **kwargs)