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: django.forms.models.ModelForm

class Meta[source]

Bases: object

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

alias of intranet.apps.polls.models.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, weight)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.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

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

clear_vote

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

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>
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

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

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

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: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.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

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

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

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

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: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.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

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

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

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.Choice(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A choice for a Question.

question

A ForeignKey to the question this choice is for.

num

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

info

Textual information about this answer choice.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.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.

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

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

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

Bases: django.db.models.base.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.

groups

The Group’s 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: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.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_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[source]

Bases: django.db.models.manager.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: django.db.models.query.QuerySet

this_year()[source]

Get AnnouncementRequests from this school year only.

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

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.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

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

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

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.Question(*args, **kwargs)[source]

Bases: django.db.models.base.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.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: django.core.exceptions.ObjectDoesNotExist

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

Bases: django.core.exceptions.MultipleObjectsReturned

SHORT_RESP = 'SRE'
SPLIT_APP = 'SAP'
STD = 'STD'
STD_OTHER = 'STO'
TYPE = (('STD', 'Standard'), ('ELC', 'Election'), ('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_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_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

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

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: intranet.test.ion_test.IonTestCase

Tests for the polls module.

test_can_vote()[source]
test_poll()[source]

intranet.apps.polls.urls module

intranet.apps.polls.views module

intranet.apps.polls.views.fmt(num)[source]
intranet.apps.polls.views.generate_choice(name, votes, total_count, do_gender=True, show_answers=False)[source]
intranet.apps.polls.views.handle_choice(q, do_gender=True, 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