Ejemplo n.º 1
0
 def test_auto_slug(self):
     name = 'The Metro Denver Regional Equity Atlas'
     project = Project()
     project.save()
     project_translation = ProjectTranslation(name=name, project=project)
     project_translation.save()
     self.assertEqual(project.slug, slugify(name))
Ejemplo n.º 2
0
 def test_auto_slug(self):
     name = 'Mile High Connects'
     organization = Organization()
     organization.save()
     organization_translation = OrganizationTranslation(name=name, organization=organization)
     organization_translation.save()
     self.assertEqual(organization.slug, slugify(name))
Ejemplo n.º 3
0
def set_organization_slug(sender, instance, **kwargs):
    """
    When an OrganizationTranslation is saved, set its Organization's slug if it
    doesn't have one
    
    Should be connected to OrganizationTranslation's post_save signal.
    """
    if not instance.organization.slug:
        instance.organization.slug = slugify(instance.name)
        instance.organization.save()
Ejemplo n.º 4
0
def set_project_slug(sender, instance, **kwargs):
    """
    When an ProjectTranslation is saved, set its Project's slug if it
    doesn't have one
    
    Should be connected to ProjectTranslation's post_save signal.
    """
    if not instance.project.slug:
        instance.project.slug = slugify(instance.name)
        instance.project.save()
Ejemplo n.º 5
0
def set_organization_slug(sender, instance, **kwargs):
    """
    When an OrganizationTranslation is saved, set its Organization's slug if it
    doesn't have one
    
    Should be connected to OrganizationTranslation's post_save signal.
    """
    if not instance.organization.slug:
        instance.organization.slug = slugify(instance.name)
	instance.organization.save()
Ejemplo n.º 6
0
def set_project_slug(sender, instance, **kwargs):
    """
    When an ProjectTranslation is saved, set its Project's slug if it
    doesn't have one
    
    Should be connected to ProjectTranslation's post_save signal.
    """
    if not instance.project.slug:
        instance.project.slug = slugify(instance.name)
	instance.project.save()
Ejemplo n.º 7
0
def set_story_slug(sender, instance, **kwargs):
    """
    When a StoryTranslation is saved, set its Story's slug if it doesn't have 
    one
    
    Should be connected to StoryTranslation's post_save signal.
    """
    try:
        if not instance.story.slug:
            instance.story.slug = slugify(instance.title)
        instance.story.save()
    except Story.DoesNotExist:
        # Instance doesn't have a related story.
        # Encountered this when loading fixture
        pass
Ejemplo n.º 8
0
def set_story_slug(sender, instance, **kwargs):
    """
    When a StoryTranslation is saved, set its Story's slug if it doesn't have 
    one
    
    Should be connected to StoryTranslation's post_save signal.
    """
    try:
        if not instance.story.slug:
            instance.story.slug = slugify(instance.title)
        instance.story.save()
    except Story.DoesNotExist:
        # Instance doesn't have a related story.
        # Encountered this when loading fixture
        pass
Ejemplo n.º 9
0
    def save(self, *args, **kwargs):
        if not self.slug:
            self.slug = slugify(SLUG_TRANSLITERATOR(self.name))[:50]

        super(CategoryTranslationBase, self).save(*args, **kwargs)
Ejemplo n.º 10
0
 def clean_slug(self):
     if self.instance is None or not ALLOW_SLUG_CHANGE:
         self.cleaned_data['slug'] = slugify(self.cleaned_data['name'])
     return self.cleaned_data['slug'][:50]
Ejemplo n.º 11
0
    def save(self, *args, **kwargs):
        if not self.slug:
            self.slug = slugify(SLUG_TRANSLITERATOR(self.name))[:50]

        super(CategoryTranslationBase, self).save(*args, **kwargs)