Created
July 9, 2010 15:50
-
-
Save michaelgodshall/469628 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Taken from http://groups.google.com/group/django-users/browse_thread/thread/a743280fd76845e3# | |
class OfflineNotification(models.Model): | |
user = models.ForeignKey(User) | |
message = models.TextField() | |
level = models.PositiveSmallIntegerField(default=20) | |
created = models.DateTimeField(auto_now_add=True) | |
class OfflineNotificationsMiddleware: | |
def process_request(self, request): | |
if request.user.is_authenticated(): | |
notifications = OfflineNotification.objects.filter(user=request.user).distinct('message') | |
for notification in notifications: | |
messages.add_message(request, notification.level, notification.message) | |
if notifications: | |
OfflineNotification.objects.filter(user=request.user).delete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment