Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp-polls
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Applications
etuc
djangoldp-polls
Commits
be895ea0
Commit
be895ea0
authored
4 years ago
by
maxime_senza
Browse files
Options
Downloads
Patches
Plain Diff
models & first migration
parent
fcf0c392
No related branches found
No related tags found
1 merge request
!1
Feature : sib polls
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
djangoldp_polls/migrations/0001_initial.py
+6
-25
6 additions, 25 deletions
djangoldp_polls/migrations/0001_initial.py
djangoldp_polls/models.py
+5
-5
5 additions, 5 deletions
djangoldp_polls/models.py
djangoldp_polls/serializers.py
+1
-1
1 addition, 1 deletion
djangoldp_polls/serializers.py
with
12 additions
and
31 deletions
djangoldp_polls/migrations/0001_initial.py
+
6
−
25
View file @
be895ea0
# -*- coding: utf-8 -*-
# Generated by Django 1.11.26 on 2020-0
4
-2
3 10:11
# Generated by Django 1.11.26 on 2020-0
5
-2
5 00:56
from
__future__
import
unicode_literals
from
django.conf
import
settings
...
...
@@ -17,24 +17,6 @@ class Migration(migrations.Migration):
]
operations
=
[
migrations
.
CreateModel
(
name
=
'
Debate
'
,
fields
=
[
(
'
id
'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'
ID
'
)),
(
'
urlid
'
,
djangoldp
.
fields
.
LDPUrlField
(
blank
=
True
,
null
=
True
,
unique
=
True
)),
(
'
created_at
'
,
models
.
DateTimeField
(
auto_now_add
=
True
)),
(
'
comment
'
,
models
.
TextField
(
verbose_name
=
'
Long description
'
)),
(
'
author
'
,
models
.
ForeignKey
(
blank
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
createdDebated
'
,
to
=
settings
.
AUTH_USER_MODEL
)),
],
),
migrations
.
CreateModel
(
name
=
'
Option
'
,
fields
=
[
(
'
id
'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'
ID
'
)),
(
'
urlid
'
,
djangoldp
.
fields
.
LDPUrlField
(
blank
=
True
,
null
=
True
,
unique
=
True
)),
(
'
name
'
,
models
.
CharField
(
max_length
=
250
,
verbose_name
=
'
Options available for a vote
'
)),
],
),
migrations
.
CreateModel
(
name
=
'
Poll
'
,
fields
=
[
...
...
@@ -47,8 +29,7 @@ class Migration(migrations.Migration):
(
'
endDate
'
,
models
.
DateField
(
verbose_name
=
'
Date de fin
'
)),
(
'
shortDescription
'
,
models
.
CharField
(
max_length
=
250
,
verbose_name
=
'
Short description
'
)),
(
'
longDescription
'
,
models
.
TextField
(
verbose_name
=
'
Long description
'
)),
(
'
author
'
,
models
.
ForeignKey
(
blank
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
createdVotes
'
,
to
=
settings
.
AUTH_USER_MODEL
)),
(
'
debate
'
,
models
.
ManyToManyField
(
blank
=
True
,
related_name
=
'
debate
'
,
to
=
'
djangoldp_polls.Debate
'
)),
(
'
author
'
,
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
createdVotes
'
,
to
=
settings
.
AUTH_USER_MODEL
)),
],
),
migrations
.
CreateModel
(
...
...
@@ -72,15 +53,15 @@ class Migration(migrations.Migration):
fields
=
[
(
'
id
'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'
ID
'
)),
(
'
urlid
'
,
djangoldp
.
fields
.
LDPUrlField
(
blank
=
True
,
null
=
True
,
unique
=
True
)),
(
'
author
'
,
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
author
'
,
to
=
settings
.
AUTH_USER_MODEL
)),
(
'
chosenOption
'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
chosenOption
'
,
to
=
'
djangoldp_polls.Poll
Option
'
)),
(
'
relatedPoll
'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
relatedPoll
'
,
to
=
'
djangoldp_polls.Poll
'
)),
(
'
chosenOption
'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
userVote
'
,
to
=
'
djangoldp_polls.PollOption
'
)),
(
'
relatedPoll
'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
votes
'
,
to
=
'
djangoldp_polls.Poll
'
)),
(
'
user
'
,
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
user
'
,
to
=
settings
.
AUTH_USER_MODEL
)),
],
),
migrations
.
AddField
(
model_name
=
'
poll
'
,
name
=
'
pollOptions
'
,
field
=
models
.
ManyToManyField
(
blank
=
True
,
related_name
=
'
p
ollOptions
'
,
to
=
'
djangoldp_polls.PollOption
'
),
field
=
models
.
ManyToManyField
(
blank
=
True
,
related_name
=
'
relatedP
ollOptions
'
,
to
=
'
djangoldp_polls.PollOption
'
),
),
migrations
.
AddField
(
model_name
=
'
poll
'
,
...
...
This diff is collapsed.
Click to expand it.
djangoldp_polls/models.py
+
5
−
5
View file @
be895ea0
...
...
@@ -32,7 +32,7 @@ class PollOption (Model):
class
Meta
:
serializer_fields
=
[
'
@id
'
,
'
name
'
]
nested_fields
=
[
'
userVote
'
,
'
p
ollOptions
'
]
nested_fields
=
[
'
userVote
'
,
'
relatedP
ollOptions
'
]
anonymous_perms
=
[
'
view
'
,
'
add
'
]
authenticated_perms
=
[
'
inherit
'
,
'
add
'
]
...
...
@@ -50,13 +50,13 @@ class Poll (Model):
shortDescription
=
models
.
CharField
(
max_length
=
250
,
verbose_name
=
"
Short description
"
)
longDescription
=
models
.
TextField
(
verbose_name
=
"
Long description
"
)
tags
=
models
.
ManyToManyField
(
Tag
,
related_name
=
'
tags
'
,
blank
=
True
)
pollOptions
=
models
.
ManyToManyField
(
PollOption
,
related_name
=
'
p
ollOptions
'
,
blank
=
True
)
pollOptions
=
models
.
ManyToManyField
(
PollOption
,
related_name
=
'
relatedP
ollOptions
'
,
blank
=
True
)
#debate = models.ManyToManyField(Debate, related_name='debate', blank=True)
#relatedVotes = models.ManyToManyField(Vote, related_name='relatedVotes', blank=True)
class
Meta
:
serializer_fields
=
[
'
@id
'
,
'
created_at
'
,
'
votes
'
,
'
author
'
,
'
title
'
,
'
image
'
,
'
hostingOrganisation
'
,
'
endDate
'
,
'
shortDescription
'
,
'
longDescription
'
,
'
tags
'
]
nested_fields
=
[
'
tags
'
,
'
votes
'
]
serializer_fields
=
[
'
@id
'
,
'
created_at
'
,
'
pollOptions
'
,
'
votes
'
,
'
author
'
,
'
title
'
,
'
image
'
,
'
hostingOrganisation
'
,
'
endDate
'
,
'
shortDescription
'
,
'
longDescription
'
,
'
tags
'
]
nested_fields
=
[
'
tags
'
,
'
votes
'
,
'
pollOptions
'
]
anonymous_perms
=
[
'
view
'
,
'
add
'
,
'
change
'
]
authenticated_perms
=
[
'
inherit
'
,
'
add
'
]
...
...
@@ -66,7 +66,7 @@ class Poll (Model):
class
Vote
(
Model
):
user
=
models
.
ForeignKey
(
settings
.
AUTH_USER_MODEL
,
related_name
=
'
user
'
)
user
=
models
.
ForeignKey
(
settings
.
AUTH_USER_MODEL
,
related_name
=
'
user
'
,
null
=
True
,
blank
=
True
)
chosenOption
=
models
.
ForeignKey
(
PollOption
,
related_name
=
'
userVote
'
)
relatedPoll
=
models
.
ForeignKey
(
Poll
,
related_name
=
'
votes
'
)
...
...
This diff is collapsed.
Click to expand it.
djangoldp_polls/serializers.py
+
1
−
1
View file @
be895ea0
...
...
@@ -8,7 +8,7 @@ class PollOptionSerializer(LDPSerializer):
class
Meta
:
model
=
PollOption
fields
=
[
'
urlid
'
,
'
total_votes
'
]
fields
=
[
'
urlid
'
,
'
name
'
,
'
total_votes
'
]
def
get_total_votes
(
self
,
obj
):
votes_queryset
=
self
.
context
.
get
(
"
votes_queryset
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment