Skip to content

Client Server Workflow

computercolin edited this page Apr 26, 2012 · 2 revisions

Example: Example: Adding thread marks (aka grades). (TODO: Put references to corresponding git check-ins)

We want to add marks at the thread level in order to let users mark that thread (ex: Reply requested, Star).

  • We start by creating our model in base/models.py (ThreadMark and if we want to keep History, ThreadMarkHistory), and do a db sync.
  • Input: I find it more natural to start from the client, but feel free to do it differently.
    • Design the control (simplistic toggle button in threadview)
    • ...which calls the "mark_thread" component, defined in pers2.js ,
    • ...which calls the rpc function markThread. Don't worry about payload details at this point.
    • ...add the markThread method in rpc/views.py (don't forget to add it to __EXPORTS). Since we already have a markNote function, it provides a good template, i.e.
      • get user id
      • check if user allowed to do the proposed action, and return a "NOT ALLOWED" if not.
      • call the corresponding annotation method, where we now get a clear idea of what needs to be in the payload
      • return objects so that the client can update its model and views.
  • update calls with the right payload information.
  • Test w/ Firebug if errors, (Net panel, open in new tab)
  • Output

Clone this wiki locally