Commit 84742fb9 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

Merge branch 'email'

parents fccc11cb 97b5e7dc
......@@ -15,5 +15,11 @@ DB_HOST = 'localhost'
# often left blank
DB_PORT = ''
# configurations for your piwik tracking server
PIWIK_SITE_ID = ''
PIWIK_URL = ''
# configurations to send email via Amazon SES
EMAIL_HOST = 'email-smtp.region-code.amazonaws.com'
EMAIL_HOST_USER = 'ses-smtp-username'
EMAIL_HOST_PASSWORD = 'ses-smtp-password'
......@@ -151,3 +151,10 @@ HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
# Piwik configurations
PIWIK_SITE_ID = secret.PIWIK_SITE_ID
PIWIK_URL = secret.PIWIK_URL
# Email configurations
EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend'
EMAIL_HOST = secret.EMAIL_HOST
EMAIL_PORT = '465'
EMAIL_HOST_USER = secret.EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = secret.EMAIL_HOST_PASSWORD
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{% extends 'layouts/base.html' %}
{% block title %}
SRCT Bookshare • Help
{% endblock title %}
{% block content %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-md-12 text-center">
<h1><strong>SRCT</strong>BOOKSHARE</h1>
<p class="lead"><strong>Help</strong></p>
</div>
</div>
</div>
<div class="row text-center">
<div class="col-md-12">
<h3>
<a href="#Buying">Buying</a> &bull;
<a href="#Selling">Selling</a> &bull;
<a href="#Lookouts">Lookouts</a> &bull;
<a href="#Flagging">Flagging</a> &bull;
<a href="#API">API</a>
</h3>
</div>
</div>
<legend><a name="Buying" href="#Buying">Buying</a></legend>
<div class="row">
</div>
<legend><a name="Selling" href="#Selling">Selling</a></legend>
<div class="row">
</div>
<legend><a name="Lookouts" href="#Lookouts">Lookouts</a></legend>
<div class="row">
</div>
<legend><a name="Flagging" href="#Flagging">Flagging</a></legend>
<div class="row">
</div>
<legend><a name="API" href="#API">API</a></legend>
<div class="row">
</div>
{% endblock content %}
......@@ -50,7 +50,7 @@
{% include 'layouts/footer.html' %}
</div>
{% block javascript %}
<script type="text/javascript" src="/static/js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="/static/js/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/static/js/isbn.js"></script>
{% endblock %}
......
......@@ -134,6 +134,7 @@ class Bid(TimeStampedModel):
bidder = models.ForeignKey(Student)
listing = models.ForeignKey(Listing)
price = models.PositiveIntegerField(
default = 0,
validators = [MaxValueValidator(1000)],)
text = models.CharField(
blank = True,
......
<html>
<head>
<title>Your bid has been selected on Bookshare!</title>
<style type="text/css">
body { font-family: "Verdana", sans-serif; }
a { color: #006633; }
a:active { color: #FFCC33; }
a:visited { color: #004C25; }
</style>
</head>
<body>
<p>Hey there, <strong>{{ bidder_first_name }}</strong>!</p>
<p>Great news!</p>
<p>Seller <strong>{{ seller_name }}</strong> has picked your ${{ bid_num }}
bid for <strong><em>{{ listing_title }}</em></strong> on
<a href="http://bookshare.srct.gmu.edu/">SRCT Bookshare</a>.
They're the cc'ed email address-- <strong>{{ seller_email }}</strong>. Watch
your email to arrange all the final touches to get your book.</p>
<p><em>Seller message</em>: {{ email_message }}</p>
<p>Thanks for using SRCT Bookshare! :-)</p>
<p><em>(Heads up: no one watches this email address. If you need to get in touch
with us, for any reason, see srct.gmu.edu/contact.)</em></p>
<p>---</p>
<p>Mason SRCT</p>
<p>
<small><a href="http://srct.gmu.edu/">SRCT</a> is a
<a href="https://si.gmu.edu/registered-student-organizations/">
registered student organization</a> at
<a href="http://www.gmu.edu/">George Mason University</a>. We have written and
provide this project for the benefit of our school's community, but offer no
claims to the accuracy of the information posted on our site by other students.
The source code for this project is available and
<a href="https://www.gnu.org/licenses/gpl-3.0.html/">freely licensed</a> at
<a href="http://git.gmu.edu/srct/bookshare/">git.gmu.edu/srct/bookshare</a>.</small>
</p>
</body>
</html>
Hey there, {{ bidder_first_name }}!
Great news!
Seller {{ seller_name }} has picked your ${{ bid_num }} bid for
{{ listing_title }} on SRCT Bookshare. They're the cc'ed email address--
{{ seller_email }}. Watch your email to arrange all the final touches to get
your book.
Seller message: {{ email_message }}
Thanks for using SRCT Bookshare! :-)
(Heads up: no one watches this email address. If you need to get in touch with
us, for any reason, see srct.gmu.edu/contact.)
---
Mason SRCT
SRCT is a registered student organization at George Mason University. We have
written and provide this project for the benefit of our school's community, but
offer no claims to the accuracy of the information posted on our site by other
students. The source code for this project is available and freely licensed at
git.gmu.edu/srct/bookshare.
......@@ -11,6 +11,10 @@ from django.http import Http404, HttpResponseForbidden
from django.forms.widgets import HiddenInput
from django.core.urlresolvers import reverse
from django.core.mail import EmailMultiAlternatives
from django.template.loader import get_template
from django.template import Context
import math
import pyisbn
import requests
......@@ -254,10 +258,40 @@ class SellListing(LoginRequiredMixin, UpdateView):
login_url = '/'
def form_valid(self, form):
# filling out fields
today = date.today()
self.obj = self.get_object()
print self.obj
print form.instance.winning_bid
form.instance.sold = True
form.instance.date_closed = today
# sending email
# I'm still second guessing as to whether this should be in this method
text_email = get_template('email/sold.txt')
html_email = get_template('email/sold.html')
email_context = Context(
{ 'bidder_first_name' : form.instance.winning_bid.bidder.user.first_name,
'seller_name' : self.obj.seller.user.get_full_name(),
'bid_num' : form.instance.winning_bid.price,
'listing_title' : self.obj.title,
'seller_email' : self.obj.seller.user.email,
'email_message' : form.instance.email_message, }
)
subject, from_email, to, cc = ('Your bid has been selected on Bookshare!',
'no-reply@bookshare.srct.io',
form.instance.winning_bid.bidder.user.email,
self.obj.seller.user.email)
#your-test-email@example.com')
text_content = text_email.render(email_context)
html_content = html_email.render(email_context)
msg = EmailMultiAlternatives(subject, text_content, from_email, [to], [cc])
msg.attach_alternative(html_content, "text/html")
msg.send()
return super(SellListing, self).form_valid(form)
def get_context_data(self, **kwargs):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment