Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #86 from postatum/104979708_last_login
Browse files Browse the repository at this point in the history
Add `register` event to `set` events
  • Loading branch information
jstoiko committed Oct 7, 2015
2 parents 5f727d2 + 58e2dff commit f2b2629
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions docs/source/event_handlers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ When you define event handlers in your ``__init__.py`` as described above, you c
Is either ``before`` or ``after``, depending on when handler should run - before view method call or after respectively.

**action**
Exact name of Nefertari view method that processes the request (action).
Exact name of Nefertari view method that processes the request (action) and special names for authentication actions.

* **index** - Collection GET
* **create** - Collection POST
Expand All @@ -43,7 +43,10 @@ When you define event handlers in your ``__init__.py`` as described above, you c
* **replace** - Item PUT
* **delete** - Item DELETE
* **item_options** - Item OPTIONS
* **set** - triggers on all the following actions: ``create``, ``update``, ``replace`` and ``update_many``
* **set** - triggers on all the following actions: ``create``, ``update``, ``replace`` and ``update_many``, ``register``.
* **login** - User login (POST /auth/login)
* **logout** - User logout (POST /auth/logout)
* **register** - User register (POST /auth/register)

E.g. This example connects the ``lowercase`` handler to the ``before_set`` event.

Expand Down
2 changes: 1 addition & 1 deletion ramses/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def get_events_map():
* Returns map of {before/after: {action: event class(es)}}
"""
from nefertari import events
set_keys = ('create', 'update', 'replace', 'update_many')
set_keys = ('create', 'update', 'replace', 'update_many', 'register')
before_events = events.BEFORE_EVENTS.copy()
before_events['set'] = [before_events[key] for key in set_keys]
after_events = events.AFTER_EVENTS.copy()
Expand Down
2 changes: 2 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,14 @@ def test_get_events_map(self):
events.AfterUpdate,
events.AfterReplace,
events.AfterUpdateMany,
events.AfterRegister,
]
assert before_set == [
events.BeforeCreate,
events.BeforeUpdate,
events.BeforeReplace,
events.BeforeUpdateMany,
events.BeforeRegister,
]

def test_patch_view_model(self):
Expand Down

0 comments on commit f2b2629

Please sign in to comment.