From 5763f78e76e609876d09dea074d3bf9fd2330e3b Mon Sep 17 00:00:00 2001 From: Max Nordlund gmail Date: Mon, 9 Apr 2018 14:49:33 +0200 Subject: [PATCH] Add documentation for swappable forms --- README.md | 12 ++++++++++++ invitations/app_settings.py | 9 +++++++++ invitations/utils.py | 9 +++++++++ 3 files changed, 30 insertions(+) diff --git a/README.md b/README.md index fd82560..5c8aeb6 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,18 @@ Bulk invites are supported via JSON. Post a list of comma separated emails to t App registry path of the invitation model used in the current project, for customization purposes. +* `INVITE_FORM` (default=`invitations.forms.InviteForm`) + + Form class used for sending invites outside admin. + +* `ADMIN_ADD_FORM` (default=`invitations.forms.InvitationAdminAddForm`) + + Form class used for sending invites in admin. + +* `ADMIN_CHANGE_FORM` (default=`invitations.forms.InvitationAdminChangeForm`) + + Form class used for updating invitations in admin. + ### Signals The following signals are emitted: diff --git a/invitations/app_settings.py b/invitations/app_settings.py index 183574b..bc23ad7 100644 --- a/invitations/app_settings.py +++ b/invitations/app_settings.py @@ -81,10 +81,16 @@ 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" @@ -92,6 +98,9 @@ def ADMIN_ADD_FORM(self): @property def ADMIN_CHANGE_FORM(self): + """ + Form class used for updating invitations in admin. + """ return self._setting( "ADMIN_CHANGE_FORM", "invitations.forms.InvitationAdminChangeForm" diff --git a/invitations/utils.py b/invitations/utils.py index f966614..f8c2c7b 100644 --- a/invitations/utils.py +++ b/invitations/utils.py @@ -18,14 +18,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)