Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nuages
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etch
nuages
Commits
88cbcf49
Commit
88cbcf49
authored
May 10, 2013
by
Christophe Siraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Going on.
parent
df083e8e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
39 additions
and
31 deletions
+39
-31
README
README
+2
-0
accounts/admin.py
accounts/admin.py
+4
-0
accounts/forms.py
accounts/forms.py
+8
-0
accounts/models.py
accounts/models.py
+11
-1
accounts/views.py
accounts/views.py
+1
-2
sondage/models.py
sondage/models.py
+1
-1
sondage/views.py
sondage/views.py
+1
-0
templates/index.html
templates/index.html
+11
-13
urls.py
urls.py
+0
-14
No files found.
README
View file @
88cbcf49
...
...
@@ -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
=============
...
...
accounts/admin.py
0 → 100644
View file @
88cbcf49
from
models
import
*
from
django.contrib
import
admin
admin
.
site
.
register
(
UserProfile
)
accounts/forms.py
0 → 100644
View file @
88cbcf49
from
django.forms
import
ModelForm
from
accounts.models
import
UserProfile
class
UserProfileForm
(
ModelForm
):
class
Meta
:
model
=
UserProfile
fields
=
(
'email_notification'
,)
accounts/models.py
View file @
88cbcf49
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
)
accounts/views.py
View file @
88cbcf49
...
...
@@ -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
)
sondage/models.py
View file @
88cbcf49
...
...
@@ -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
...
...
sondage/views.py
View file @
88cbcf49
...
...
@@ -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...
...
...
templates/index.html
View file @
88cbcf49
...
...
@@ -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 poll
s 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
/>
...
...
urls.py
View file @
88cbcf49
...
...
@@ -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}),
)
'''
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment