本文整理汇总了Python中uuslug.uuslug函数的典型用法代码示例。如果您正苦于以下问题:Python uuslug函数的具体用法?Python uuslug怎么用?Python uuslug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uuslug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
def save(self, *args, **kwargs):
if not self.title and self.value_type == 'course_personal':
course = Course.objects.filter(user=self.user, value_type='course_personal')
sum = len(course)+1
self.title = _('Custom course %s') % sum
if not self.slug:
if self.title and self.value_type == 'course_front':
self.slug = uuslug(self.title, instance=self)
else:
self.slug = uuslug('%s' % self.pk, instance=self)
super(Course, self).save(*args, **kwargs)
示例2: save
def save(self,*args, **kwargs):
self.slug = uuslug(self.title, instance=self,max_length=28,).replace('-','')
if not self.productImg:
pass
else:
self.create_thumbnail()
super(ProductArticle, self).save(*args, **kwargs)
示例3: save
def save(self, *args, **kwargs):
if not self.id:
self.slug = uuslug(self.title, instance=self)
self.title = self.title.encode("ascii", "ignore")
self.created = datetime.datetime.now()
assign('djig.group_view', everybody_group, self)
super(Article, self).save(*args, **kwargs)
示例4: add_events
def add_events(apps, schema_editor):
Event = apps.get_model('voting', 'Event')
for event_name in EVENTS:
if not Event.objects.filter(name=event_name).exists():
event = Event(name=event_name)
event.slug = uuslug(event_name, event)
event.save()
示例5: save
def save(self, *args, **kwargs):
if not self.pk:
self.slug = uuslug(self.name, instance=self)
else:
# Update action items
current_poll = Poll.objects.get(id=self.pk)
action_model = ContentType.objects.get_for_model(self)
action_items = ActionItem.objects.filter(content_type=action_model,
object_id=self.pk)
if current_poll.end != self.end:
action_items.update(due_date=self.end.date())
if current_poll.valid_groups != self.valid_groups:
action_items.delete()
if not settings.CELERY_ALWAYS_EAGER:
if self.is_current_voting:
celery_control.revoke(self.task_end_id)
elif self.is_future_voting:
celery_control.revoke(self.task_start_id)
celery_control.revoke(self.task_end_id)
if not self.is_future_voting:
obj = Poll.objects.get(pk=self.id)
if self.end > obj.end:
self.is_extended = True
super(Poll, self).save()
示例6: save
def save(self, *args, **kwargs):
if not self.created:
self.created = datetime.now()
if not self.slug:
self.slug = uuslug(self.name, instance=self)
# self.legacy_username= str(self.user.username)
super(Topic, self).save(*args, **kwargs)
示例7: save
def save(self, *args, **kwargs):
"""TODO: Docstring for save.
:returns: TODO
"""
self.slug = uuslug(self.title, instance=self,
max_length=100)
super(Post, self).save(*args, **kwargs)
示例8: save
def save(self, **kwargs):
if self.slug is None:
self.slug = uuslug(self.title, instance=self)
if self.content_type_id is None:
klass_name = self.__class__.__name__.lower()
ct = ContentType.objects.get(model=klass_name)
self.content_type = ct
super(ECMCatalogEntry, self).save(**kwargs)
示例9: save
def save(self, *args, **kwargs):
keywords = []
self.slug = uuslug(self.title, instance=self)
if not self.keywords_string and getattr(settings, "AUTO_TAG", False):
keywords = self.title.rstrip(punctuation).split()
super(Juba, self).save(*args, **kwargs)
if keywords:
lookup = reduce(ior, [Q(title__iexact=k) for k in keywords])
for keyword in Keyword.objects.filter(lookup):
self.keywords.add(AssignedKeyword(keyword=keyword))
示例10: save
def save(self, *args, **kwargs):
if not self.pk:
self.slug = uuslug(self.name, instance=self)
elif not settings.CELERY_ALWAYS_EAGER:
if self.is_current_voting:
celery_control.revoke(self.task_end_id)
elif self.is_future_voting:
celery_control.revoke(self.task_start_id)
celery_control.revoke(self.task_end_id)
super(Poll, self).save()
示例11: save
def save(self, *args, **kwargs):
"""
Rewrite the `save()` function to handle slug uniqueness
"""
if kwargs.pop('force_slug_update', True):
self.slug = uuslug(self.title, instance=self, max_length=80)
update_date = kwargs.pop('update_date', True)
if update_date:
self.update_date = datetime.now()
super(PublishableContent, self).save(*args, **kwargs)
示例12: save
def save(self):
# tags = Tag.objects.all()
# for tag in tags:
# self.content = re.sub(u'<a class="keyword"\s*[^>]*>%s</a>'%(tag.name),
# u'%s'%(tag.name), self.content)
# for tag in tags:
# self.content = re.sub(u'%s'%(tag.name),
# u'<a class="keyword" href="/tag/%s/">%s</a>'%(tag.slug, tag.name), self.content, 1)
if not self.slug:
self.slug = uuslug(self.title, instance=self)
return super(Blog, self).save()
示例13: save
def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):
self.slug = uuslug(self.name,
instance=self,
max_length=100,
start_no=2,
word_boundary=True,
save_order=True)
if not self.slug:
self.slug = uuslug(self.heading + '_blog',
instance=self,
max_length=100,
start_no=2,
word_boundary=True,
save_order=True)
self.slug = self.slug.lower()
super(Blog, self).save(force_insert, force_update, using, update_fields)
示例14: save
def save(self, *args, **kwargs):
self.sku = uuslug(self.name, instance=self, slug_field='sku')
variants = ProductVariant.objects.filter(product=self)
stock = 0
for item in variants:
stock += item.inventory
if (stock > 0):
self.status = 'IN'
else:
self.status = 'OUT'
super(Product, self).save(**kwargs)
示例15: slugify
def slugify(self, tag, i=None):
slug = uuslug(tag,
instance=self,
max_length=100,
start_no=2,
word_boundary=True,
save_order=True)
if not slug:
slug = uuslug(tag + '_tag',
instance=self,
max_length=100,
start_no=2,
word_boundary=True,
save_order=True)
slug = slug.lower()
if i is not None:
slug += "_%d" % i
return slug