intranet.apps.polls package

Submodules

intranet.apps.polls.admin module

intranet.apps.polls.forms module

class intranet.apps.polls.forms.PollForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: ModelForm

class Meta[source]

Bases: object

fields = ['title', 'description', 'start_time', 'end_time', 'visible', 'is_secret', 'is_election', 'groups']
help_texts = {'is_election': 'Enable election formatting and results features.', 'is_secret': "This will prevent Ion administrators from viewing individual users' votes."}
labels = {'is_election': 'Election', 'is_secret': 'Secret'}
model

alias of Poll

widgets = {'description': <django.forms.widgets.Textarea object>}
clean_description()[source]
declared_fields = {}

intranet.apps.polls.models module

class intranet.apps.polls.models.Answer(id, question, user, choice, answer, clear_vote, other_vote, weight, rank)[source]

Bases: Model

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

answer

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

choice

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

choice_id
clear_vote

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

display_votes()[source]

Convert rank to votes for displaying by assigning rank 1 the max number of votes and continuing down.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
other_vote

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

question

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

question_id
rank

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

user

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

user_id
weight

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class intranet.apps.polls.models.AnswerVote(id, question, choice, votes, is_writing)[source]

Bases: Model

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

choice

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

choice_id
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_writing

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
question

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

question_id
users

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

votes

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class intranet.apps.polls.models.AnswerVote_users(id, answervote, user)

Bases: Model

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

answervote

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

answervote_id
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
user

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

user_id
class intranet.apps.polls.models.Choice(*args, **kwargs)[source]

Bases: Model

A choice for a Question.

question

A ForeignKey to the question this choice is for.

num

An integer order in which the choice should appear; the primary sort.

info

Textual information about this answer choice.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

answer_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

answervote_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

display_name()[source]
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

info

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

num

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
question

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

question_id
trunc_info()[source]
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()

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

before_end_time()[source]

Has the poll not ended yet?

before_start_time()[source]

Has the poll not started yet?

can_vote(user)[source]
description

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

end_time

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_end_time(*, field=<django.db.models.fields.DateTimeField: end_time>, is_next=True, **kwargs)
get_next_by_start_time(*, field=<django.db.models.fields.DateTimeField: start_time>, is_next=True, **kwargs)
get_num_eligible_voters()[source]
get_percentage_voted(voted, able)[source]
get_previous_by_end_time(*, field=<django.db.models.fields.DateTimeField: end_time>, is_next=False, **kwargs)
get_previous_by_start_time(*, field=<django.db.models.fields.DateTimeField: start_time>, is_next=False, **kwargs)
get_users_voted()[source]
get_voted_string()[source]
groups

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

has_user_voted(user)[source]
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

in_time_range()[source]

Is it within the poll time range?

is_election

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_secret

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <intranet.apps.polls.models.PollManager object>
question_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

start_time

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

title

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

visible

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class intranet.apps.polls.models.PollManager(*args, **kwargs)[source]

Bases: Manager

get_queryset()[source]
visible_to_user(user)[source]

Get a list of visible polls for a given user (usually request.user).

These visible polls will be those that either have no groups assigned to them (and are therefore public) or those in which the user is a member.

class intranet.apps.polls.models.PollQuerySet(model=None, query=None, using=None, hints=None)[source]

Bases: QuerySet

this_year()[source]

Get Polls from this school year only.

class intranet.apps.polls.models.Poll_groups(id, poll, group)

Bases: Model

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

group

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

group_id
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
poll

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

poll_id
class intranet.apps.polls.models.Question(*args, **kwargs)[source]

Bases: Model

A question for a Poll.

poll

A ForeignKey to the Poll object the question is for.

question

A text field for entering the question, of which there are choices the user can make.

num

An integer order in which the question should appear; the primary sort.

type
One of:

Question.STD: Standard Question.ELECTION: Election (randomized choice order) Question.RANK: Rank choice election Question.APP: Approval (can select up to max_choices entries) Question.SPLIT_APP: Split approval Question.FREE_RESP: Free response Question.STD_OTHER: Standard Other field

max_choices

The maximum number of choices that can be selected. Only applies for approval questions.

Access possible choices for this question through question.choice_set.all()
APP = 'APP'
exception DoesNotExist

Bases: ObjectDoesNotExist

ELECTION = 'ELC'
FREE_RESP = 'FRE'
exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

RANK = 'RAN'
SHORT_RESP = 'SRE'
SPLIT_APP = 'SAP'
STD = 'STD'
STD_OTHER = 'STO'
TYPE = (('STD', 'Standard'), ('ELC', 'Election'), ('RAN', 'Rank choice'), ('APP', 'Approval'), ('SAP', 'Split approval'), ('FRE', 'Free response'), ('SRE', 'Short response'), ('STO', 'Standard other'))
answer_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

answervote_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

choice_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

classmethod get_question_types()[source]
get_total_votes()[source]
get_type_display(*, field=<django.db.models.fields.CharField: type>)
get_users_voted()[source]
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_choice()[source]
is_many_choice()[source]
is_rank_choice()[source]
is_single_choice()[source]
is_writing()[source]
max_choices

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

num

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
poll

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

poll_id
question

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property random_choice_set
trunc_question()[source]
type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

intranet.apps.polls.tests module

class intranet.apps.polls.tests.ApiTest(methodName='runTest')[source]

Bases: IonTestCase

Tests for the polls module.

test_can_vote()[source]
test_csv_results()[source]

Tests the view to generate a CSV of the results.

test_free_response_voting()[source]
test_multi_select_voting()[source]
test_poll()[source]
test_polls_view()[source]

Tests the polls view (the index page).

test_single_select_voting()[source]

intranet.apps.polls.urls module

intranet.apps.polls.views module

intranet.apps.polls.views.determine_ranked_choice_winners(poll)[source]
intranet.apps.polls.views.fmt(num)[source]
intranet.apps.polls.views.generate_choice(name, votes, total_count, show_answers=False)[source]
intranet.apps.polls.views.handle_choice(q, show_answers=False)[source]
intranet.apps.polls.views.handle_rank_choice(q, show_answers=False)[source]
intranet.apps.polls.views.handle_sap(q)[source]
intranet.apps.polls.views.perc(num, den)[source]
intranet.apps.polls.views.process_question_data(instance, question_data)[source]

Module contents