Poll¶
Qualified name: intranet.apps.polls.models.Poll
- class intranet.apps.polls.models.Poll(*args, **kwargs)[source]¶
Bases:
Model
A Poll, for the TJ community.
- title¶
A title for the poll, that will be displayed to identify it uniquely.
- description¶
A longer description, possibly explaining how to complete the poll.
- start_time¶
A time that the poll should open.
- end_time¶
A time that the poll should close.
- visible¶
Whether the poll is visible to the users it is for.
- is_secret¶
Whether the poll is a ‘secret’ poll. Poll admins will not be able to view individual user responses for secret polls.
- is_election¶
Whether the poll is an election.
- groups¶
The Groups that can view and vote in the poll. Like Announcements, if there are none set, then it is public to all.
Access questions for the poll through poll.question_set.all()
- Parameters:
id (AutoField) – Primary key: ID
title (CharField) – Title
description (CharField) – Description
start_time (DateTimeField) – Start time
end_time (DateTimeField) – End time
visible (BooleanField) – Visible
is_secret (BooleanField) – Is secret
is_election (BooleanField) – Is election
Relationship fields:
- Parameters:
groups (
ManyToManyField
toGroup
) – Groups (related name:poll
)
Reverse relationships:
- Parameters:
question (Reverse
ForeignKey
fromQuestion
) – All questions of this poll (related name ofpoll
)
Methods
Has the poll not ended yet?
Has the poll not started yet?
can_vote
get_next_by_end_time
Finds next instance based on
end_time
.get_next_by_start_time
Finds next instance based on
start_time
.get_num_eligible_voters
get_percentage_voted
get_previous_by_end_time
Finds previous instance based on
end_time
.get_previous_by_start_time
Finds previous instance based on
start_time
.get_users_voted
get_voted_string
has_user_voted
Is it within the poll time range?
Attributes
Type:
CharField
Type:
DateTimeField
Type:
ManyToManyField
toGroup
id
Type:
AutoField
Type:
BooleanField
Type:
BooleanField
objects
question_set
Type: Reverse
ForeignKey
fromQuestion
Type:
DateTimeField
Type:
CharField
Type:
BooleanField