Commits

offline  committed fb04c30

first version of API implemented

  • Participants
  • Parent commits b94c240

Comments (0)

Files changed (4)

 syntax: glob
 *.pyc
-django_openauth.egg-info
+django_notify.egg-info
 *.kpf
-openauth/.project
-openauth/.pydevproject
+notify/.project
+notify/.pydevproject

File notify/__init__.py

+from django.shortcuts import redirect
+
+import notify
+from notify import settings
+
+
+class Adapter(object):
+    def __init__(self, priority, message):
+        self.priority = priority
+        self.message = message
+
+    def __call__(self, request=None, _redirect=None):
+        if notify.settings.NOTIFY_TYPE == "flashcookie":
+            request.flash[self.priority] = self.message
+            return redirect(_redirect)
+        
+        if notify.settings.NOTIFY_TYPE == "html":
+            return {'TEMPLATE': 'notify/message.html', 'message': self.message}
+
+
+
+class Notify(object):
+    def __init__(self, message):
+        self.message = message
+
+    def __getattr__(self, name):
+        return Adapter(name, self.message)
+    
+    def send(self, *args, **kwargs):
+        return {'TEMPLATE': 'notify/message.html', 'message': self.message}
+
+
+        
+

File notify/settings.py

+
+
+NOTIFY_TYPE = "html"
+
+NOTIFY_TYPES = ("flashcookie",)

File notify/templates/notify/message.html

+{% extends 'base.html' %}
+
+{% block content %}
+{{ message }}
+{% endblock %}