Skip to content

Commit

Permalink
Merge pull request #15 from worthwhile/feat/improved-preview
Browse files Browse the repository at this point in the history
Improved the preview list and related functionality
  • Loading branch information
raiderrobert committed Aug 19, 2016
2 parents 27fbdda + 2d57227 commit 6684378
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 9 deletions.
29 changes: 26 additions & 3 deletions herald/templates/herald/test/notification_list.html
@@ -1,3 +1,26 @@
{% for index, name, types in notifications %}
{{ name }} ({% for type in types %}<a href="{% url 'herald_preview' index type %}">{{ type }}</a>{% if not forloop.last %}, {% endif %}{% endfor %})<br/>
{% endfor %}
<style>
table {
width:100%;
}

th {
text-align: left;
}
</style>

<h1>Notification Preview</h1>

<table>
<tr>
<th>Name</th>
<th>Preview Link(s)</th>
<th>Bases</th>
</tr>
{% for index, name, types, bases in notifications %}
<tr>
<td>{{ name }}</td>
<td>{% for type in types %}<a href="{% url 'herald_preview' index type %}">{{ type }}</a>{% if not forloop.last %}, {% endif %}{% endfor %} </td>
<td>{% for base in bases %}{{ base }}{% if not forloop.last %}, {% endif %}{% endfor %}</td>
</tr>
{% endfor %}
</table>
4 changes: 3 additions & 1 deletion herald/views.py
@@ -1,6 +1,8 @@
"""
Views for testing notifications. Should not be present in production
"""
import inspect


from django.http import HttpResponse
from django.views.generic import TemplateView, View
Expand All @@ -19,7 +21,7 @@ def get_context_data(self, **kwargs):
context = super(TestNotificationList, self).get_context_data(**kwargs)

context['notifications'] = [
(index, x.__name__, x.render_types) for index, x in enumerate(registry._registry) # pylint: disable=W0212
(index, x.__name__, x.render_types, (y.__name__ for y in x.__bases__)) for index, x in enumerate(registry._registry) # pylint: disable=W0212
]

return context
Expand Down
7 changes: 7 additions & 0 deletions manage.py
@@ -0,0 +1,7 @@
#!/usr/bin/env python
import os, sys
sys.path.append(os.path.join(os.path.dirname(__file__), 'herald'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
from django.core import management
if __name__ == "__main__":
management.execute_from_command_line()
10 changes: 9 additions & 1 deletion tests/notifications.py
@@ -1,4 +1,4 @@
from herald.base import EmailNotification
from herald.base import EmailNotification, TwilioTextNotification
from herald import registry


Expand All @@ -8,3 +8,11 @@ class MyNotification(EmailNotification):
to_emails = ['test@test.com']

registry.register(MyNotification)


class MyTwilioNotification(TwilioTextNotification):
context = {'hello': 'world'}
template_name = 'hello_world'
to_emails = ['test@test.com']

registry.register(MyTwilioNotification)
2 changes: 2 additions & 0 deletions tests/settings.py
Expand Up @@ -28,6 +28,8 @@

ROOT_URLCONF = 'tests.urls'

DEBUG = True

USE_TZ = True

SECRET_KEY = 'foobar'
Expand Down
4 changes: 2 additions & 2 deletions tests/test_init.py
Expand Up @@ -11,8 +11,8 @@ class TestNotification(EmailNotification):

registry.register(TestNotification)

self.assertEqual(len(registry._registry), 2)
self.assertEqual(len(registry._registry), 3)

registry.unregister(TestNotification)

self.assertEqual(len(registry._registry), 1)
self.assertEqual(len(registry._registry), 2)
2 changes: 0 additions & 2 deletions tests/test_views.py
@@ -1,7 +1,5 @@
from django.test import TestCase, Client

from herald.base import NotificationBase


class ViewsTests(TestCase):
def test_index(self):
Expand Down

0 comments on commit 6684378

Please sign in to comment.