Commit b4d02956 authored by Christophe Siraut's avatar Christophe Siraut
Browse files

initial experimental work.

parent 1ac41277
from django.db import models
from django.contrib.auth.models import User
class UserProfile(models.Model):
user = models.OneToOneField(User)
email_notification = models.BooleanField()
This file demonstrates writing tests using the unittest module. These will pass
when you run " test".
Replace this with more appropriate tests for your application.
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
Tests that 1 + 1 always equals 2.
self.assertEqual(1 + 1, 2)
from django.conf import settings
from django.contrib.auth.models import User
def email_notify(author, voter):
print 'a'
user = User.objects.get(username=author)
subject = "Django email notification"
message = "User %s has voted" % voter
user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
print author, user, voter
......@@ -127,5 +127,6 @@ INSTALLED_APPS = (
from django.contrib.auth.models import User
import os
from binascii import hexlify
from django.db import models
......@@ -15,7 +16,9 @@ class Poll(models.Model):
upd_date = models.DateField(auto_now=True)
author = models.CharField(max_length=40)
description = models.CharField(max_length=300)
username = models.OneToOneField(User)
m django.contrib.auth.models import User
def __unicode__(self):
return self.title
......@@ -217,6 +217,9 @@ def vote(request, poll_id):
old.comment = vorm.cleaned_data['comment']
error_message = "Your vote has been updated, thank you."
if has_voted:
if poll.username:
email_notify(poll.username, voter)
error_message = 'Did you forget to provide your name?'
Supports Markdown
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