This repository has been archived by the owner on Mar 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/thraxil/spokehub
- Loading branch information
Showing
12 changed files
with
108 additions
and
41 deletions.
There are no files selected for viewing
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class BroadcastConfig(AppConfig): | ||
name = 'broadcast' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django import forms | ||
|
||
|
||
class BroadcastForm(forms.Form): | ||
subject = forms.CharField(label='Subject', required=True) | ||
body = forms.CharField( | ||
label='message body', | ||
required=True, | ||
widget=forms.Textarea(attrs={'style': 'width: 100%'}), | ||
) |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from django.core import mail | ||
from django.core.urlresolvers import reverse | ||
from django.test import TestCase, Client | ||
from spokehub.main.tests.factories import UserFactory | ||
|
||
|
||
class BroadcastViewTest(TestCase): | ||
def setUp(self): | ||
self.c = Client() | ||
|
||
def test_get(self): | ||
r = self.c.get(reverse('broadcast', args=[])) | ||
self.assertEqual(r.status_code, 200) | ||
|
||
def test_post(self): | ||
UserFactory() | ||
r = self.c.post( | ||
reverse('broadcast', args=[]), | ||
{ | ||
'subject': 'cat', | ||
'body': 'kitty cat', | ||
} | ||
) | ||
self.assertEqual(r.status_code, 302) | ||
self.assertEqual(len(mail.outbox), 1) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.conf.urls import patterns, url | ||
from .views import BroadcastView | ||
|
||
|
||
urlpatterns = patterns( | ||
'', | ||
url(r'^$', BroadcastView.as_view(), name='broadcast'), | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django.contrib.auth.models import User | ||
from django.views.generic.edit import FormView | ||
from .forms import BroadcastForm | ||
|
||
|
||
class BroadcastView(FormView): | ||
template_name = "broadcast/broadcast.html" | ||
form_class = BroadcastForm | ||
success_url = "/" | ||
|
||
def form_valid(self, form): | ||
for u in User.objects.all().exclude(username='AnonymousUser'): | ||
u.email_user( | ||
form.cleaned_data['subject'], | ||
form.cleaned_data['body'], | ||
'Hub Conversation <hello@spokehub.org>', | ||
) | ||
return super(BroadcastView, self).form_valid(form) |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% extends 'base.html' %} | ||
{% load bootstrap %} | ||
|
||
{% block content %} | ||
<div id="site-wrapper"> | ||
<div class="content-wrapper content-container recover-password user-page"> | ||
<div class="page-heading"><h2><b>Send Broadcast Email to All Users</b></h2></div> | ||
<div class="form-container"> | ||
{% if request.user.is_superuser %} | ||
|
||
<form action="." method="post"> | ||
{{form|bootstrap}} | ||
<input type="submit" value="send broadcast message" /> | ||
</form> | ||
{% else %} | ||
<p>Sorry, superuser only</p> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
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
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