Ejemplo n.º 1
0
    def testMakeSlugs(self):
        self.assertEqual(
            'django',
            make_slug('http://svn.example.com/django/trunk/'))

        self.assertEqual(
            'example',
            make_slug('http://svn.example.com'))
        self.assertEqual(
            'example',
            make_slug('http://svn.example.com/trunk/'))
        self.assertEqual(
            'django-django-contrib',
            make_slug('http://svn.example.com/django/trunk/django/contrib/'))
        self.assertEqual(
            'django-new-admin',
            make_slug('http://svn.example.com/django/branches/new-admin/'))
        self.assertEqual(
            'django-1-1',
            make_slug('http://svn.example.com/django/tags/1.1/'))
        self.assertEqual(
            'mock',
            make_slug('http://mock.googlecode.com/svn/'))
        self.assertEqual(
            'django-grappelli-2-5',
            make_slug('http://django-grappelli.googlecode.com/svn/branches/2.5'))
Ejemplo n.º 2
0
    def save(self):
        repository = Repository.objects.find_one(
            {'url': self.cleaned_data['url']})

        data = {
            'public': True,
            'slug': None,
        }
        data.update(self.cleaned_data)

        if repository:
            if not data['slug']:
                del data['slug']
            for key, value in data.iteritems():
                setattr(repository, key, value)
        else:
            slug = data['slug']
            if not slug:
                slug = make_slug(data['url'])

            real_slug = find_unused_slug(slug)
            if data['slug'] != real_slug:
                data['original_slug'] = data['slug']
                data['slug'] = real_slug

            repository = Repository(**data)

        return repository.save()
Ejemplo n.º 3
0
    def save(self):
        repository = Repository.objects.find_one({'url': self.cleaned_data['url']})

        data = {
            'public': True,
            'slug': None,
        }
        data.update(self.cleaned_data)

        if repository:
            if not data['slug']:
                del data['slug']
            for key, value in data.iteritems():
                setattr(repository, key, value)
        else:
            slug = data['slug']
            if not slug:
                slug = make_slug(data['url'])

            real_slug = find_unused_slug(slug)
            if data['slug'] != real_slug:
                data['original_slug'] = data['slug']
                data['slug'] = real_slug

            repository = Repository(**data)

        return repository.save()
Ejemplo n.º 4
0
    def testMakeSlugs(self):
        self.assertEqual('django',
                         make_slug('http://svn.example.com/django/trunk/'))

        self.assertEqual('example', make_slug('http://svn.example.com'))
        self.assertEqual('example', make_slug('http://svn.example.com/trunk/'))
        self.assertEqual(
            'django-django-contrib',
            make_slug('http://svn.example.com/django/trunk/django/contrib/'))
        self.assertEqual(
            'django-new-admin',
            make_slug('http://svn.example.com/django/branches/new-admin/'))
        self.assertEqual('django-1-1',
                         make_slug('http://svn.example.com/django/tags/1.1/'))
        self.assertEqual('mock', make_slug('http://mock.googlecode.com/svn/'))
        self.assertEqual(
            'django-grappelli-2-5',
            make_slug(
                'http://django-grappelli.googlecode.com/svn/branches/2.5'))