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
Incidents
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
2398b719
Commit
2398b719
authored
Jun 10, 2013
by
Christophe Siraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better random key generation.
parent
d0eea9ea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
README
README
+1
-1
meetingpoll/models.py
meetingpoll/models.py
+7
-6
nuages/urls.py
nuages/urls.py
+3
-0
No files found.
README
View file @
2398b719
...
...
@@ -7,7 +7,7 @@ Nuages - Easy poll sharing
The project uses the following django application:
- django-registration: https://bitbucket.org/ubernostrum/django-registration
On debian
they can be installed
as follow:
On debian
one can install it
as follow:
# aptitude install python-django-registration
...
...
meetingpoll/models.py
View file @
2398b719
from
django.contrib.auth.models
import
User
from
django.contrib.sites.models
import
Site
import
os
from
binascii
import
hexlify
from
django.db
import
models
from
django.utils.translation
import
ugettext_lazy
as
_
import
string
import
random
def
_createId
():
# Random 4 caracters string
return
hexlify
(
os
.
urandom
(
2
))
def
_createId
(
length
):
firstchar
=
string
.
ascii_letters
# First char: Always a letter
chars
=
string
.
digits
+
string
.
ascii_letters
# Letters and digits for the rest
return
random
.
choice
(
firstchar
)
+
''
.
join
([
random
.
choice
(
chars
)
for
dummy
in
xrange
(
0
,
length
-
1
)])
class
Poll
(
models
.
Model
):
# Override django id AutoField with randomly generatyed hash
id
=
models
.
CharField
(
primary_key
=
True
,
unique
=
True
,
max_length
=
8
,
default
=
_createId
)
id
=
models
.
CharField
(
primary_key
=
True
,
unique
=
True
,
max_length
=
8
,
default
=
_createId
(
5
)
)
title
=
models
.
CharField
(
_
(
'Title'
),
max_length
=
80
)
pub_date
=
models
.
DateField
(
auto_now_add
=
True
)
upd_date
=
models
.
DateField
(
auto_now
=
True
)
...
...
nuages/urls.py
View file @
2398b719
...
...
@@ -16,6 +16,7 @@ urlpatterns = patterns('',
url
(
r
'^nuages/$'
,
TemplateView
.
as_view
(
template_name
=
'nuages.html'
),
name
=
'documentation'
),
url
(
r
'^languages/$'
,
TemplateView
.
as_view
(
template_name
=
'languages.html'
),
name
=
'languages'
),
url
(
r
'^(?P<poll_id>\w{4})/$'
,
'meetingpoll.views.vote'
),
url
(
r
'^(?P<poll_id>\w{5})/$'
,
'meetingpoll.views.vote'
),
url
(
r
'^new/$'
,
'meetingpoll.views.new'
,
name
=
'new'
),
url
(
r
'^(?P<pk>\w+)/edit/$'
,
login_required
(
UpdateView
.
as_view
(
queryset
=
Poll
.
objects
.
all
(),
...
...
@@ -24,11 +25,13 @@ urlpatterns = patterns('',
url
(
r
'^(?P<poll_id>\w+)/delete/$'
,
'meetingpoll.views.delete'
),
url
(
r
'^(?P<poll_id>\w+)/edit/choices/$'
,
'meetingpoll.views.editchoices'
,
name
=
'choices'
),
url
(
r
'^(?P<poll_id>\w{4})/vote/$'
,
'meetingpoll.views.vote'
,
name
=
'vote'
),
url
(
r
'^(?P<poll_id>\w{5})/vote/$'
,
'meetingpoll.views.vote'
,
name
=
'vote'
),
url
(
r
'^(?P<poll_id>\w+)/csv/$'
,
'meetingpoll.views.exp_csv'
),
url
(
r
'^accounts/profile/$'
,
'account.views.profile'
,
name
=
'profile'
),
url
(
r
'^accounts/'
,
include
(
'registration.backends.default.urls'
)),
url
(
r
'^i18n/'
,
include
(
'django.conf.urls.i18n'
)),
url
(
r
'^(?P<poll_id>\w{4})/clear/'
,
'meetingpoll.userviews.clear_cookie'
),
url
(
r
'^(?P<poll_id>\w{5})/clear/'
,
'meetingpoll.userviews.clear_cookie'
),
url
(
r
'^admin/'
,
include
(
admin
.
site
.
urls
)),
url
(
r
'^admin/doc/'
,
include
(
'django.contrib.admindocs.urls'
)),
)
...
...
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