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
75624fd4
Commit
75624fd4
authored
4 years ago
by
Benoit Alessandroni
Browse files
Options
Downloads
Patches
Plain Diff
Update models.py
parent
340ebe4c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!5
bugfix: update accessor name from polls to circle
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
djangoldp_polls/models.py
+81
-81
81 additions, 81 deletions
djangoldp_polls/models.py
with
81 additions
and
81 deletions
djangoldp_polls/models.py
+
81
−
81
View file @
75624fd4
from
django.conf
import
settings
from
django.db
import
models
from
djangoldp.models
import
Model
from
django.contrib.auth
import
get_user_model
from
django.db.models
import
Sum
from
djangoldp_conversation.models
import
Conversation
from
djangoldp_circle.models
import
Circle
User
=
get_user_model
()
User
.
name
=
User
.
get_full_name
#========================
#========================
class
Tag
(
Model
):
name
=
models
.
CharField
(
max_length
=
250
,
verbose_name
=
"
Name
"
)
class
Meta
:
serializer_fields
=
[
'
@id
'
,
'
name
'
]
anonymous_perms
=
[
'
view
'
]
authenticated_perms
=
[
'
inherit
'
,
'
add
'
]
def
__str__
(
self
):
return
self
.
name
class
PollOption
(
Model
):
name
=
models
.
CharField
(
max_length
=
250
,
verbose_name
=
"
Options available for a vote
"
)
class
Meta
:
serializer_fields
=
[
'
@id
'
,
'
name
'
]
nested_fields
=
[
'
userVote
'
,
'
relatedPollOptions
'
]
anonymous_perms
=
[
'
view
'
,
'
add
'
]
authenticated_perms
=
[
'
inherit
'
,
'
add
'
]
def
__str__
(
self
):
return
self
.
name
class
Poll
(
Model
):
created_at
=
models
.
DateTimeField
(
auto_now_add
=
True
)
author
=
models
.
ForeignKey
(
settings
.
AUTH_USER_MODEL
,
related_name
=
'
createdVotes
'
,
null
=
True
,
blank
=
True
)
title
=
models
.
CharField
(
max_length
=
250
,
verbose_name
=
"
Title
"
)
image
=
models
.
URLField
(
blank
=
True
,
null
=
True
,
verbose_name
=
"
Illustration de l
'
évènement
"
)
hostingOrganisation
=
models
.
CharField
(
max_length
=
250
,
verbose_name
=
"
Name of the hosting organisation
"
)
startDate
=
models
.
DateField
(
verbose_name
=
"
Date de début
"
,
blank
=
True
,
null
=
True
)
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
"
)
tags
=
models
.
ManyToManyField
(
Tag
,
related_name
=
'
tags
'
,
blank
=
True
)
pollOptions
=
models
.
ManyToManyField
(
PollOption
,
related_name
=
'
relatedPollOptions
'
,
blank
=
True
)
debate
=
models
.
ManyToManyField
(
Conversation
,
related_name
=
'
debates
'
,
blank
=
True
)
circle
=
models
.
ForeignKey
(
Circle
,
null
=
True
,
related_name
=
"
resource
s
"
)
class
Meta
:
serializer_fields
=
[
'
@id
'
,
'
created_at
'
,
'
debate
'
,
'
pollOptions
'
,
'
votes
'
,
'
author
'
,
'
title
'
,
'
image
'
,
'
hostingOrganisation
'
,
'
startDate
'
,
'
endDate
'
,
'
shortDescription
'
,
'
longDescription
'
,
'
tags
'
]
nested_fields
=
[
'
tags
'
,
'
votes
'
,
'
pollOptions
'
,
'
debate
'
]
anonymous_perms
=
[
'
view
'
,
'
add
'
,
'
change
'
]
authenticated_perms
=
[
'
inherit
'
,
'
add
'
]
def
__str__
(
self
):
return
self
.
title
class
Vote
(
Model
):
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
'
)
class
Meta
:
auto_author
=
"
user
"
serializer_fields
=
[
'
@id
'
,
'
chosenOption
'
,
'
relatedPoll
'
]
nested_fields
=
[]
anonymous_perms
=
[
'
view
'
,
'
add
'
,
'
change
'
]
authenticated_perms
=
[
'
inherit
'
,
'
add
'
]
from
django.conf
import
settings
from
django.db
import
models
from
djangoldp.models
import
Model
from
django.contrib.auth
import
get_user_model
from
django.db.models
import
Sum
from
djangoldp_conversation.models
import
Conversation
from
djangoldp_circle.models
import
Circle
User
=
get_user_model
()
User
.
name
=
User
.
get_full_name
#========================
#========================
class
Tag
(
Model
):
name
=
models
.
CharField
(
max_length
=
250
,
verbose_name
=
"
Name
"
)
class
Meta
:
serializer_fields
=
[
'
@id
'
,
'
name
'
]
anonymous_perms
=
[
'
view
'
]
authenticated_perms
=
[
'
inherit
'
,
'
add
'
]
def
__str__
(
self
):
return
self
.
name
class
PollOption
(
Model
):
name
=
models
.
CharField
(
max_length
=
250
,
verbose_name
=
"
Options available for a vote
"
)
class
Meta
:
serializer_fields
=
[
'
@id
'
,
'
name
'
]
nested_fields
=
[
'
userVote
'
,
'
relatedPollOptions
'
]
anonymous_perms
=
[
'
view
'
,
'
add
'
]
authenticated_perms
=
[
'
inherit
'
,
'
add
'
]
def
__str__
(
self
):
return
self
.
name
class
Poll
(
Model
):
created_at
=
models
.
DateTimeField
(
auto_now_add
=
True
)
author
=
models
.
ForeignKey
(
settings
.
AUTH_USER_MODEL
,
related_name
=
'
createdVotes
'
,
null
=
True
,
blank
=
True
)
title
=
models
.
CharField
(
max_length
=
250
,
verbose_name
=
"
Title
"
)
image
=
models
.
URLField
(
blank
=
True
,
null
=
True
,
verbose_name
=
"
Illustration de l
'
évènement
"
)
hostingOrganisation
=
models
.
CharField
(
max_length
=
250
,
verbose_name
=
"
Name of the hosting organisation
"
)
startDate
=
models
.
DateField
(
verbose_name
=
"
Date de début
"
,
blank
=
True
,
null
=
True
)
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
"
)
tags
=
models
.
ManyToManyField
(
Tag
,
related_name
=
'
tags
'
,
blank
=
True
)
pollOptions
=
models
.
ManyToManyField
(
PollOption
,
related_name
=
'
relatedPollOptions
'
,
blank
=
True
)
debate
=
models
.
ManyToManyField
(
Conversation
,
related_name
=
'
debates
'
,
blank
=
True
)
circle
=
models
.
ForeignKey
(
Circle
,
null
=
True
,
related_name
=
"
poll
s
"
)
class
Meta
:
serializer_fields
=
[
'
@id
'
,
'
created_at
'
,
'
debate
'
,
'
pollOptions
'
,
'
votes
'
,
'
author
'
,
'
title
'
,
'
image
'
,
'
hostingOrganisation
'
,
'
startDate
'
,
'
endDate
'
,
'
shortDescription
'
,
'
longDescription
'
,
'
tags
'
]
nested_fields
=
[
'
tags
'
,
'
votes
'
,
'
pollOptions
'
,
'
debate
'
]
anonymous_perms
=
[
'
view
'
,
'
add
'
,
'
change
'
]
authenticated_perms
=
[
'
inherit
'
,
'
add
'
]
def
__str__
(
self
):
return
self
.
title
class
Vote
(
Model
):
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
'
)
class
Meta
:
auto_author
=
"
user
"
serializer_fields
=
[
'
@id
'
,
'
chosenOption
'
,
'
relatedPoll
'
]
nested_fields
=
[]
anonymous_perms
=
[
'
view
'
,
'
add
'
,
'
change
'
]
authenticated_perms
=
[
'
inherit
'
,
'
add
'
]
\ No newline at end of file
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