
There are three main sub parts to the admin tool

------------------------------------------------------------

Moderate Messages:
- list all messages that are 
  + not published
- messages can be OKed, NOed, or held
- message category and order can be set
  + no check on category setting
- message order is
  1 unflagged messaged
    a undated
    b in order of active date
  2 rejected messages
  3 accepted messages in the order they'd appear in an email

NOTE: rejected messages are deleted each day at midnight! (when the
email is built)

------------------------------------------------------------

Build Email
- list all messages that are 
  + flagged as to_publish and do not have an active date > today and not flagged as published
  + unflagged and have an active date of today or earlier
- messages can be OKed, NOed, or held
- message category and order can be set
  + category must be set to OK the message
- message order is
  1 accepted messages with no category
  2 unflagged messaged
    b in order of active date
  3 accepted messages as they'd appear in the email

NOTE: unflagged messages without an active date do NOT show up in the
build email tool!

------------------------------------------------------------

Manage Categories
- alter name
- alter order
- add new
- delete


















The admin tool needs to fulfill these functions:
  - manage messages
    + look at each message (audience(s), title, body, 1-line summary (optional),
submitter (name, contact, on behalf), active datetime) with the option
of editing it.
    + include, keep for later, or refuse a message
      * a refused message is never shown again. 
      * A kept-for-later essage is still in the potentials list but
is not in the email this day
      * an included message is in today's email and will show up on
future lists
    + assign the message to a category
      * assigning it to 'Upcoming' causes special handling
    + give the message an ordering within that category
  - manage the email
    + see what the email will look like when it's sent out
      * one version for each audience
  - system config
    + add/remove categories
    + set category ordering
	  

Each day all the messages that are potentially included in the email
are displayed. A message is potentially included if
(it's not refused) 
AND
(
 (the current date is between (inclusive) the active dates of the
message and the message has a body)
 OR
 (the current date is between (inclusive) the upcoming dates of the
message and the message has a summary line)
)



---------------------------------


	eligible messages are (all messages that have active date <= 
current date and not refused and not published) + (all messages that
have no active date and which are not refused and not published), and
these ones also with the foreshadow flag set (all messages that have
active_date < curdate + 7 and not foreshadowed). This list is
constructed every weekday at 3:00 PM. The admin interface can alter
the refuse and publish flag for these records, and the category and
ordering.
        When the actual emails for that date are sent out, there are 4
passes, 1 for each audience. Each pass the email collects all eligible
messages with the publish flag set, ordering them according to the
category and ordering number, and filtered for that audience. Also at
this time the published and foreshadowed flags are set as appropriate
on all eligible messages that don't have the refuse flag set.
         When the admin refuses a message the refuse_flag on the
email, AND the refuseD_flag on the message are both set. WHen the
admin OKs a message then the refuse flag on the email in unset, the
refuseD_flag on the message is unset, and the publish flag on the
email is set.


---------------------------------


The email building process:
1. Display all messages
   A. First undecided (i.e. neither accepted nor rejected)
   B. Second all the accepted, in the order in which they'll appear in
the email.
   C. Third all the rejected for the current day.
2. As each message is approved, rejected, or held...
       - when a button is pressed an ajax call occurs
         + which submits the current info for that message
         + which sets the accepted and rejected flags as appropriate
       - the message positions on the page do not change until the
page is reloaded.

NOTE: the routines (accept, reject, hold) are run even if the message
is already in the given state because the routines save the current
message info to the DB - i.e. pressing a button does a Save for the
message in addition to whatever else happens.

NOTE: Whenever the category, ordering, or admin comment changes, if
the message was not already undecided, then set the table class to
'undecided' (and the 'hold' AJAX routine is called).

QUESTION: Should the NO button even be active/available if there's no
admin comment? Before actually rejeting a message, chack to see if
there's an admin comment, and ask to confirm rejection if there is none?


---------------------------------

The AJAX-called APIs that are needed:
1. Accept message X (with given category, ordering, admin comment,
body, etc.)
      - set reject and accept flags as appropriate
2. Reject message X (with given category, ordering, admin comment,
body, etc.)
      - set reject and accept flags as appropriate
      - send email to submitter with comment (if comment exists)
3. Hold message X (with given category, ordering, admin comment,
body, etc.)
      - set reject and accept flags as appropriate

---------------------------------

How to handle Upcoming messages? 

A message appears in the Upcoming section if it
a) has an active date > the day for which the email is being built
b) has an active date < 1 week from the day for which the email is
being built
c) has a short summary

They appear in the order of their active dates, and in order of
submission after that (unless Jo wants to be able to order these as
well).

On the build email page the messages that might someday appear in the upcoming
section (i.e. have an active date and a short summary) are grouped
together...

Sounds like maybe the Upcoming stuff needs it's own interface?
Need to talk to Jo about this, and perhaps Jonathan, Gayle, Comb, etc.
