Skip to content

Commit

Permalink
Merge pull request #181 from valberg/add_missing_configuration_docs
Browse files Browse the repository at this point in the history
Add documentation for swappable forms.
  • Loading branch information
valberg authored Apr 5, 2022
2 parents a51c5d9 + 9c5d293 commit 97172f8
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
39 changes: 39 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,45 @@ App registry path of the invitation model used in the current project, for custo

----

INVITE_FORM
***********

Setting name: ``INVITATIONS_INVITE_FORM``

Type: String

Default: ``invitations.forms.InviteForm``

Form class used for sending invites outside admin.

----

ADMIN_ADD_FORM
**************

Setting name: ``INVITATIONS_ADMIN_ADD_FORM``

Type: String

Default: ``invitations.forms.InvitationAdminAddForm``

Form class used for sending invites in admin.

----

ADMIN_CHANGE_FORM
*****************

Setting name: ``INVITATIONS_ADMIN_CHANGE_FORM``

Type: String

Default: ``invitations.forms.InvitationAdminChangeForm``

Form class used for updating invites in admin.

----

CONFIRMATION_URL_NAME
*********************
Setting name: ``INVITATIONS_CONFIRMATION_URL_NAME``
Expand Down
11 changes: 9 additions & 2 deletions invitations/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ def __init__(self, prefix):
self.prefix = prefix

def _setting(self, name, dflt):
from django.conf import settings

return getattr(settings, self.prefix + name, dflt)

@property
Expand Down Expand Up @@ -81,17 +79,26 @@ def INVITATION_MODEL(self):

@property
def INVITE_FORM(self):
"""
Form class used for sending invites outside admin.
"""
return self._setting("INVITE_FORM", "invitations.forms.InviteForm")

@property
def ADMIN_ADD_FORM(self):
"""
Form class used for sending invites in admin.
"""
return self._setting(
"ADMIN_ADD_FORM",
"invitations.forms.InvitationAdminAddForm",
)

@property
def ADMIN_CHANGE_FORM(self):
"""
Form class used for updating invitations in admin.
"""
return self._setting(
"ADMIN_CHANGE_FORM",
"invitations.forms.InvitationAdminChangeForm",
Expand Down
9 changes: 9 additions & 0 deletions invitations/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,23 @@ def import_attribute(path):


def get_invite_form():
"""
Returns the form for sending an invite.
"""
return import_attribute(app_settings.INVITE_FORM)


def get_invitation_admin_add_form():
"""
Returns the form for creating a new invitation in admin.
"""
return import_attribute(app_settings.ADMIN_ADD_FORM)


def get_invitation_admin_change_form():
"""
Returns the form for changing invitations in admin.
"""
return import_attribute(app_settings.ADMIN_CHANGE_FORM)


Expand Down

0 comments on commit 97172f8

Please sign in to comment.