implement automatic creation of mailbox names

- create mailbox name when saving new mailboxes in admin
- add MailboxManager that implement get_next_mailbox_name as manager for
  Mailbox
This commit is contained in:
Jan Dittberner 2014-12-27 00:24:05 +01:00
parent 8f5812ff29
commit 92c6b39e12
3 changed files with 24 additions and 1 deletions

View file

@ -67,6 +67,8 @@ class MailboxCreationForm(forms.ModelForm):
"""
mailbox = super(MailboxCreationForm, self).save(commit=False)
mailbox.username = Mailbox.objects.get_next_mailbox_name(
mailbox.osuser)
mailbox.set_password(self.cleaned_data['password1'])
if commit:
mailbox.save()
@ -118,7 +120,7 @@ class MailboxAdmin(ActivationChangeMixin, admin.ModelAdmin):
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('osuser', 'username', 'password1', 'password2')}),
'fields': ('osuser', 'password1', 'password2')}),
)
search_fields = ('username',)
ordering = ('username',)