Skip to content

Commit

Permalink
Add documentation for swappable forms
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnordlund committed Apr 9, 2018
1 parent bd1874d commit 5763f78
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions invitations/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,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 @@ -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)


Expand Down

0 comments on commit 5763f78

Please sign in to comment.