Poll¶
Qualified name: intranet.apps.polls.models.Poll
- class intranet.apps.polls.models.Poll(*args, **kwargs)[source]¶
Bases:
ModelA 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 (
ManyToManyFieldtoGroup) – Groups (related name:poll)
Reverse relationships:
- Parameters:
question (Reverse
ForeignKeyfromQuestion) – All questions of this poll (related name ofpoll)
Methods
Has the poll not ended yet?
Has the poll not started yet?
can_voteget_next_by_end_timeFinds next instance based on
end_time.get_next_by_start_timeFinds next instance based on
start_time.get_num_eligible_votersget_percentage_votedget_previous_by_end_timeFinds previous instance based on
end_time.get_previous_by_start_timeFinds previous instance based on
start_time.get_users_votedget_voted_stringhas_user_votedIs it within the poll time range?
Attributes
Type:
CharFieldType:
DateTimeFieldType:
ManyToManyFieldtoGroupidType:
AutoFieldType:
BooleanFieldType:
BooleanFieldobjectsquestion_setType: Reverse
ForeignKeyfromQuestionType:
DateTimeFieldType:
CharFieldType:
BooleanField