Commit 3cc948c1 authored by Daniel W Bond's avatar Daniel W Bond

count the number of emails a student sends

parent c1596b5b
......@@ -14,6 +14,8 @@ class Student(TimeStampedModel):
slug = AutoSlugField(populate_from='user', unique=True)
emails_sent = models.PositiveIntegerField(default=0)
def get_absolute_url(self):
return reverse('profile', kwargs={'slug': self.slug})
......
......@@ -403,6 +403,9 @@ class ExchangeListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
msg.attach_alternative(html_content, "text/html")
msg.send()
self.obj.poster.emails_sent += 2
self.obj.poster.save()
return super(ExchangeListing, self).form_valid(form)
def get_context_data(self, **kwargs):
......@@ -468,6 +471,9 @@ class UnExchangeListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
msg.attach_alternative(html_content, "text/html")
msg.send()
self.obj.poster.emails_sent += 2
self.obj.poster.save()
# this has to come after the email has been sent, otherwise these are
# cleaned out
form.instance.exchanged = False
......
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