On 07/29/2009 05:05 AM, Daniel Pope wrote:
> My suggestion is a system for administrators to be notified about
> specific model instances about which they need to take action. At
> present administrators have to identify where to make changes by
> browsing the site. Some example use cases:
>
> 1. Comments - a list of new comments requiring moderation.
> 2. Stock level low - a list of SKUs with fewer than say, 5 items left in 
> stock.
> 3. Draft articles - a list of unpublished articles, for the
> convenience of administrators.
> 4. Data inconsistencies - while model validation should do for any
> really functional inconsistencies, I often come across situations
> where I want to warn admins rather than outright forbid the model to
> be saved. Case in point: I want to warn if the number of products in a
> category would require me to paginate them onto 2 pages as this is
> undesirable for usability.
>
> I would propose a way to register notification querysets in the admin.
> If a non-zero number of results present, a message appears in the
> admin, including the number of items to administer, and a link to a
> changelist that displays only matching models. I'd ideally like to
> select an icon too, so that I can differentiate between alerts,
> warnings and mere information.
>
> Dan
>    

Hi Dan,

One fairly simple way to do this would be to set up a Notification model 
to hold these kinds of notifications, build a nice admin.py and some 
admin templates for it, and then build post_save signal handlers for 
each (Stock, Comments, etc.) that create new Notifications when 
appropriate.  You can add in email, SMS, and/or Twitter alerts in the 
signal handlers in order to get push notifications.

This seems like a straight-forward approach, but it isn't particularly 
generic.  You'd need to code custom logic for each of your post_save 
signal handlers -- if any new comment is posted, then notify; if stock 
is reduced and total amount of stock is < 5, then notify; if # of 
products in a category > 10, then notify.

Hmm.  One could code up a base signal handler, and a library of signal 
handler subclasses that handle configurable logic variations.  
Similarly, one could create a base notify action, and a library of 
notification subclasses to implement various features.  And perhaps some 
means of chaining them -- base Notify creates a Notification, then do an 
Email notification, then do a Twitter notification.

I'd say, though, such a framework should start life as a third-party 
reusable app.  Neat idea, this would be something I would likely use.

---Peter

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to