Skip to content

Commit c3f76b6

Browse files
committed
signal on message_sent
1 parent feb3374 commit c3f76b6

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

anthill/people/signals.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.dispatch import Signal
2+
3+
message_sent = Signal(providing_args=['subject', 'body', 'recipient'])

anthill/people/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from django.contrib.auth.decorators import login_required
99
from anthill.people.models import Profile
1010
from anthill.people.forms import SearchForm, ProfileForm, PasswordForm, UserContactForm
11+
from anthill.people.signals import message_sent
1112

1213
def search(request):
1314
context = { 'form': SearchForm() }
@@ -118,6 +119,8 @@ def contact(request, username):
118119
'body': form.cleaned_data['body']}
119120
subject = render_to_string('people/contact_email_subject.txt', data)
120121
body = render_to_string('people/contact_email_body.txt', data)
122+
message_sent.send(sender=request.user, subject=subject, body=body,
123+
recipient=to_user)
121124
to_user.email_user(subject.strip(), body, request.user.email)
122125
request.user.message_set.create(message='Your email has been delivered to %s' % (to_user.first_name or to_user.username))
123126
request.user.profile.record_email_sent()

0 commit comments

Comments
 (0)