def save(self, *args, **kwargs): if not self.name: # populate the field taxonomy_helper.populate_top_levels() if (self.name) and (not self.slug): self.slug = common_helper.slugify(self.name) super(TopLevelCategory, self).save(*args, **kwargs)
def get_lineage_slugs(lineage_tags): ''' Slugify all lineage tags in lineage_str and return a string object. ''' lineage_slugs = [] # the type of the object changes to unicode if it has already been saved # to the db but not if we're in the middle of creating the model object if not isinstance(lineage_tags, list): # cast the unicode object to a list if not already in this type lineage_tags = eval(lineage_tags) for tag in lineage_tags: slug = common_helper.slugify(tag) lineage_slugs.append(slug) return lineage_slugs
def save(self, *args, **kwargs): # assign a unique internal id if not self.frsku: self.frsku = helper.get_frsku() # generate a unique slug for the product name if not self.base_slug: # TODO: change self.temp_title to self.name in production self.base_slug = common_helper.slugify(self.product_name) if (self.base_slug) and (not self.slug): self.slug = common_helper.unique_slugify(self.base_slug, Product) lda_topics_name = self._get_lda_name() self.predicted_topics_name = lda_topics_name if not self.created_at: self.created_at = datetime.datetime.now() self.updated_at = datetime.datetime.now() super(Product, self).save(*args, **kwargs)
def map_reviews(self): for index, aspect_name in enumerate(self.aspect_set): msg = "Mapping topical reviews for '{}' for frsku={}" msg = msg.format(aspect_name, self.frsku) logger.info(msg) print msg aspect_slug = ch.slugify(aspect_name) params = { 'crawl_cache__crawl_queue__product_raw__product__frsku': self.frsku, 'aspect_slugs__contains': aspect_slug, 'aspects__contains': aspect_name, } review_set = p_models.ReviewRaw.objects.using('data_alias').filter( **params) self._create(review_set, aspect_name, aspect_slug, index)
def save(self, *args, **kwargs): if not self.base_slug: self.base_slug = common_helper.slugify(self.name) self.slug = common_helper.unique_slugify(self.base_slug, Slug) super(Slug, self).save()