Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Commit

Permalink
Merge remote branch 'andym/addon-default-name'
Browse files Browse the repository at this point in the history
  • Loading branch information
zalun committed Jan 5, 2011
2 parents ac0febe + 2002cc4 commit 2e6bae5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
7 changes: 5 additions & 2 deletions apps/jetpack/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,11 @@ def _get_full_name(full_name, username, type_id, i=0):
i = i + 1
return _get_full_name(full_name, username, type_id, i)

name = settings.DEFAULT_PACKAGE_FULLNAME.get(self.type,
self.author.username)
username = self.author.username
if self.author.get_profile():
username = self.author.get_profile().nickname or username

name = settings.DEFAULT_PACKAGE_FULLNAME.get(self.type, username)
self.full_name = _get_full_name(name, self.author.username, self.type)

def set_name(self):
Expand Down
16 changes: 16 additions & 0 deletions apps/jetpack/tests/package_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ def test_addon_creation(self):
self.failUnless(package.name)
self.assertEqual(package.full_name, self.author.username)

def test_addon_creation_with_nickname(self):
"""In production if you log in with an AMO user, the username
is set to a number and the nickname on the profile is set to the
real username."""
profile = self.author.get_profile()
profile.nickname = 'Gordon'
profile.save()

package = Package(
author=self.author,
type='a'
)
package.save()

eq_(package.full_name, 'Gordon')

def test_automatic_numbering(self):
Package(
author=self.author,
Expand Down

0 comments on commit 2e6bae5

Please sign in to comment.