Skip to content

Commit

Permalink
Merge pull request #39 from salceson/email-notifications
Browse files Browse the repository at this point in the history
Email notifications
  • Loading branch information
ant6 committed Jun 14, 2015
2 parents 1f379f6 + 5846741 commit be16be6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
3 changes: 0 additions & 3 deletions TermMarket/local_settings.py

This file was deleted.

15 changes: 14 additions & 1 deletion TermMarket/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,17 @@

TERM_MARKET_NO_SOLVER = True

from local_settings import *
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'term.market.iiet'
EMAIL_HOST_PASSWORD = 'termmarket123'
EMAIL_PORT = 587

OAUTH_CLIENT_ID = '62fc662fffaac9cd8cc7fd1a5da2540d54e8a43127de231df0bd71f890822e87'
OAUTH_CLIENT_SECRET = '2b821b0995eff7d088b7f7521681b37faf0dab2fb9e24205e9212abc50fc8e61'
TEMP_DIR = '/tmp/'

try:
from local_settings import *
except ImportError:
pass
5 changes: 5 additions & 0 deletions term_market/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.contrib import auth, messages
from django.contrib.messages.views import SuccessMessageMixin
from django.core.exceptions import PermissionDenied
from django.core.mail import send_mail
from django.core.urlresolvers import reverse, reverse_lazy
from django.db.models import F, Prefetch
from django.shortcuts import redirect, get_object_or_404
Expand Down Expand Up @@ -219,6 +220,10 @@ def post(self, request, *args, **kwargs):
success_url = self.get_success_url()
self.object.trade_to(self.request.user)
messages.success(self.request, self.success_message)
msg = 'Trade succeed!\n' + str(self.object.offer.donor) + ' took your offer: ' + str(
self.object.offer.offered_term)
send_mail('Offer accepted!', msg, settings.EMAIL_HOST_USER, [self.object.offer.donor.email],
fail_silently=False)
return HttpResponseRedirect(success_url)

# This is to mimic "generic" behavior of Django built-in views
Expand Down

0 comments on commit be16be6

Please sign in to comment.