[GH-ISSUE #531] ExtraAccountForm Documentation #505

Closed
opened 2026-02-27 11:12:07 +03:00 by kerem · 4 comments
Owner

Originally created by @jag3773 on GitHub (Mar 21, 2014).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/531

Originally assigned to: @tonioo on GitHub.

Hello,

I'm attempting to write a plugin to add another tab to the Account Form (the one that has "General" and "Mail"). I don't think any of the existing plugins do this and there is not very detailed documentation on how to accomplish it. I'm not looking to add admin or user parameters (those docs are great!), but rather a form tab on each user's account page.

I do see the ExtraAccountForm and CheckExtraAccountForm decorators, but I must be missing something in my code as I can't get my tab to show up.

Could you provide a minimal viable sketch of the required components to add a tab to the Account Form please?

Originally created by @jag3773 on GitHub (Mar 21, 2014). Original GitHub issue: https://github.com/modoboa/modoboa/issues/531 Originally assigned to: @tonioo on GitHub. Hello, I'm attempting to write a plugin to add another tab to the Account Form (the one that has "General" and "Mail"). I don't think any of the existing plugins do this and there is not very detailed documentation on how to accomplish it. I'm _not_ looking to add admin or user parameters (those docs are great!), but rather a form tab on each user's account page. I do see the ExtraAccountForm and CheckExtraAccountForm decorators, but I must be missing something in my code as I can't get my tab to show up. Could you provide a minimal viable sketch of the required components to add a tab to the Account Form please?
kerem 2026-02-27 11:12:07 +03:00
Author
Owner

@jag3773 commented on GitHub (Mar 21, 2014):

To describe my particular problem a bit further, I think something in my form definition is wrong. I am seeing the following traceback, if it helps at all:

Internal Server Error: /admin/accounts/edit/353/
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 115, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python2.6/site-packages/django/contrib/auth/decorators.py", line 25, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/django/contrib/auth/decorators.py", line 25, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/django/db/transaction.py", line 223, in inner
    return func(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/modoboa/extensions/admin/views/identity.py", line 199, in editaccount
    'tabs': AccountForm(request.user, instances=instances)
  File "/usr/lib/python2.6/site-packages/modoboa/extensions/admin/forms/account.py", line 338, in __init__
    super(AccountForm, self).__init__(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/modoboa/lib/formutils.py", line 115, in __init__
    kwargs["instance"] = instances[fd["id"]]
KeyError: 'radius'

Note that radius is the name of the plugin I'm developing.

For my form, I'm subclassing ModelForm, like so:
class RadiusForm(forms.ModelForm):

I'm using the following decorators:

    @events.observe("CheckExtraAccountForm")
    def check_radius_form(account, form):
        return [True]

    @events.observe("ExtraAccountForm")
    def radius_form(user, account):
        """Defines RADIUS form for account form dialog."""
        from app_settings import RadiusForm
        return [{ "id" : "radius",
                 "title" : ("RADIUS"),
                 "cls" : RadiusForm
               }]
<!-- gh-comment-id:38320438 --> @jag3773 commented on GitHub (Mar 21, 2014): To describe my particular problem a bit further, I think something in my form definition is wrong. I am seeing the following traceback, if it helps at all: ``` Internal Server Error: /admin/accounts/edit/353/ Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 115, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.6/site-packages/django/contrib/auth/decorators.py", line 25, in _wrapped_view return view_func(request, *args, **kwargs) File "/usr/lib/python2.6/site-packages/django/contrib/auth/decorators.py", line 25, in _wrapped_view return view_func(request, *args, **kwargs) File "/usr/lib/python2.6/site-packages/django/db/transaction.py", line 223, in inner return func(*args, **kwargs) File "/usr/lib/python2.6/site-packages/modoboa/extensions/admin/views/identity.py", line 199, in editaccount 'tabs': AccountForm(request.user, instances=instances) File "/usr/lib/python2.6/site-packages/modoboa/extensions/admin/forms/account.py", line 338, in __init__ super(AccountForm, self).__init__(*args, **kwargs) File "/usr/lib/python2.6/site-packages/modoboa/lib/formutils.py", line 115, in __init__ kwargs["instance"] = instances[fd["id"]] KeyError: 'radius' ``` Note that radius is the name of the plugin I'm developing. For my form, I'm subclassing ModelForm, like so: `class RadiusForm(forms.ModelForm):` I'm using the following decorators: ``` @events.observe("CheckExtraAccountForm") def check_radius_form(account, form): return [True] @events.observe("ExtraAccountForm") def radius_form(user, account): """Defines RADIUS form for account form dialog.""" from app_settings import RadiusForm return [{ "id" : "radius", "title" : ("RADIUS"), "cls" : RadiusForm }] ```
Author
Owner

@tonioo commented on GitHub (Mar 22, 2014):

Hi,

actually some extensions already define such tabs. Take a look a the "limits" extension for example, it defines a new tab to setup domain administrator limits.

In your particular case, it seems you forgot to listen to the FillAccountInstances event (http://modoboa.readthedocs.org/en/latest/extending/events.html#fillaccountinstances).

And you're right about the documentation, I should present the way to add tabs in a cleaner way.

<!-- gh-comment-id:38345764 --> @tonioo commented on GitHub (Mar 22, 2014): Hi, actually some extensions already define such tabs. Take a look a the "limits" extension for example, it defines a new tab to setup domain administrator limits. In your particular case, it seems you forgot to listen to the _FillAccountInstances_ event (http://modoboa.readthedocs.org/en/latest/extending/events.html#fillaccountinstances). And you're right about the documentation, I should present the way to add tabs in a cleaner way.
Author
Owner

@tonioo commented on GitHub (Apr 11, 2014):

Hi,
did you solve your issue?

<!-- gh-comment-id:40191754 --> @tonioo commented on GitHub (Apr 11, 2014): Hi, did you solve your issue?
Author
Owner

@jag3773 commented on GitHub (Apr 11, 2014):

Yes, sorry I should have verified that here. Adding the hook
for FillAccountInstances is exactly what I needed.

Thank you!

Thank you,
Jesse Griffin
www.ekfocus.com

On Fri, Apr 11, 2014 at 4:51 AM, Antoine Nguyen notifications@github.comwrote:

Hi,
did you solve your issue?


Reply to this email directly or view it on GitHubhttps://github.com/tonioo/modoboa/issues/531#issuecomment-40191754
.

<!-- gh-comment-id:40197320 --> @jag3773 commented on GitHub (Apr 11, 2014): Yes, sorry I should have verified that here. Adding the hook for FillAccountInstances is exactly what I needed. Thank you! Thank you, Jesse Griffin www.ekfocus.com On Fri, Apr 11, 2014 at 4:51 AM, Antoine Nguyen notifications@github.comwrote: > Hi, > did you solve your issue? > > — > Reply to this email directly or view it on GitHubhttps://github.com/tonioo/modoboa/issues/531#issuecomment-40191754 > .
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#505
No description provided.