Commit 88cbcf49 authored by Christophe Siraut's avatar Christophe Siraut

Going on.

parent df083e8e
......@@ -97,6 +97,8 @@ Fix permission for apache user
sudo chown -R www-data /usr/local/lib/nuages
Set domain name: login to the /admin/ url of your installation, modify the "Site" entry from "example.com" to your domain name.
Email Service
=============
......
from models import *
from django.contrib import admin
admin.site.register(UserProfile)
from django.forms import ModelForm
from accounts.models import UserProfile
class UserProfileForm(ModelForm):
class Meta:
model = UserProfile
fields = ('email_notification',)
from django.db import models
from django.contrib.auth.models import User
from django.contrib.auth.signals import user_logged_in
class UserProfile(models.Model):
user = models.OneToOneField(User)
email_notification = models.BooleanField()
def login_handler(user, **kwargs):
try:
profile = UserProfile.objects.get(user=user)
except:
profile = UserProfile(user=user)
profile.save()
return
user_logged_in.connect(login_handler)
......@@ -14,6 +14,5 @@ def email_notify(poll, voter):
message += _("Current results:")
message += "\n\n"
for choice in poll.choice_set.all():
message += "%s: %i" % (choice.choice, choice.votecount)
message += "\n\n"
message += "%s: %i\n" % (choice.choice, choice.votecount)
poll.user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
......@@ -17,7 +17,7 @@ class Poll(models.Model):
upd_date = models.DateField(auto_now=True)
author = models.CharField(max_length=40)
description = models.CharField(max_length=300)
user = models.OneToOneField(User,blank=True,null=True)
user = models.ForeignKey(User,blank=True,null=True)
def __unicode__(self):
return self.title
......
......@@ -14,6 +14,7 @@ from django.contrib.auth.decorators import login_required
#from django.contrib.sites.models import Site
from django.conf import settings
from accounts.views import email_notify
from accounts.forms import UserProfileForm
def new(request):
if request.method == 'POST': # If the form has been submitted...
......
......@@ -26,25 +26,24 @@
<br /><div style="display:block;clear:both"></div> <br /><br />
{% block userspecific %}
{% if user.is_authenticated %}
<h2>{% trans "My polls" %}</h2>
{% if object_list %}
<ul>
{% for object in object_list %}
{% ifequal object.author user.username %}
<li><a href="{{ object.id }}/">{{ object.title }}</a> :
<a href="{{ object.id }}/edit/">{% trans "edit" %}</a> -
<a href="{{ object.id }}/delete/" onclick="return confirm('{% trans "Are you sure you want to delete this poll?" %}');">{% trans "delete" %}</a></li>
{% endifequal %}
{% with user.poll_set.all as polls %}
{% if polls %}
<ul>
{% for poll in polls %}
<li><a href="{{ poll.link }}">{{ poll.title }}</a> :
<a href="{{ poll.link }}edit/">{% trans "edit" %}</a> -
<a href="{{ poll.link }}delete/" onclick="return confirm('{% trans "Are you sure you want to delete this poll?" %}');">{% trans "delete" %}</a></li>
{% endfor %}
</ul>
{% else %}
<p>{% trans "No polls are available." %}</p>
<p>{% trans "No poll created yet." %}</p>
{% endif %}
{% endwith %}
<br />
<h2>{% trans "My account" %}</h2>
......@@ -54,9 +53,7 @@
<!--<li><a href="/user/email/change/">{% trans 'Change email address' %}</a></li>-->
<li><a href="{% url 'auth_logout' %}">{% trans 'Logout' %}</a></li>
</ul>
{% else %}
<h2>{% trans "Examples" %}</h2>
<ul>
......@@ -64,6 +61,7 @@
</ul>
{% endif %}
{% endblock %}
<br /><br /><br /><br />
......
......@@ -19,12 +19,8 @@ poll_dict = {
}
urlpatterns = patterns('',
# Example:
# (r'^nuage/', include('nuage.foo.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^$', 'django.views.generic.list_detail.object_list', dict(info_dict, template_name='index.html'), name='home'),
url(r'^nuages$', 'django.views.generic.simple.direct_to_template', {'template': 'nuages.html'}, name='documentation'),
url(r'^(?P<lang_id>\w{2})/nuages$', 'sondage.views.translation'),
......@@ -40,13 +36,3 @@ urlpatterns = patterns('',
url(r'^(?P<poll_id>\w{4})/clear/', 'sondage.userviews.clear_cookie'),
)
'''
from django.conf import settings
if settings.DEBUG:
urlpatterns += patterns('',
(r'^%s/(?P<path>.*)$' % settings.MEDIA_URL[1:-1],
'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT, 'show_indexes': 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