Permalink
Browse files

Avoid DRY violation.

Signed-off-by: Chris Lamb <lamby@debian.org>
  • Loading branch information...
1 parent eb0d597 commit 20b2e4e204a49e8e2871d1b2d1e0b048b9a63ab8 @lamby lamby committed with Sep 28, 2012
Showing with 5 additions and 11 deletions.
  1. +5 −11 src/librement/profile/forms.py
@@ -62,17 +62,11 @@ class AccountForm(dict):
def __init__(self, user, *args, **kwargs):
self.user = user
- self['user'] = AccountUserForm(
- instance=user,
- *args,
- **kwargs
- )
-
- self['profile'] = AccountProfileForm(
- instance=user.profile,
- *args,
- **kwargs
- )
+ for key, klass, fn in (
+ ('user', AccountUserForm, lambda x: x),
+ ('profile', AccountProfileForm, lambda x: x.profile),
+ ):
+ self[key] = klass(instance=fn(user), *args, **kwargs)
def save(self):
return [x.save() for x in self.values()]

0 comments on commit 20b2e4e

Please sign in to comment.