intranet.apps.announcements package

Submodules

intranet.apps.announcements.admin module

class intranet.apps.announcements.admin.AnnouncementAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ('title', 'user', 'author', 'added')
list_filter = ('added', 'updated')
ordering = ('-added',)
raw_id_fields = ('user',)

intranet.apps.announcements.api module

class intranet.apps.announcements.api.IsAnnouncementAdminOrReadOnly[source]

Bases: rest_framework.permissions.BasePermission

has_permission(request, view)[source]
class intranet.apps.announcements.api.ListCreateAnnouncement(**kwargs)[source]

Bases: rest_framework.generics.ListCreateAPIView

get_queryset()[source]
permission_classes = (<class 'intranet.apps.announcements.api.IsAnnouncementAdminOrReadOnly'>,)
serializer_class

alias of intranet.apps.announcements.serializers.AnnouncementSerializer

class intranet.apps.announcements.api.RetrieveUpdateDestroyAnnouncement(**kwargs)[source]

Bases: rest_framework.generics.RetrieveUpdateDestroyAPIView

get_queryset()[source]
permission_classes = (<class 'intranet.apps.announcements.api.IsAnnouncementAdminOrReadOnly'>,)
serializer_class

alias of intranet.apps.announcements.serializers.AnnouncementSerializer

intranet.apps.announcements.forms module

class intranet.apps.announcements.forms.AnnouncementForm(*args, **kwargs)[source]

Bases: django.forms.models.ModelForm

A form for generating an announcement.

class Meta[source]

Bases: object

fields = ['title', 'author', 'content', 'groups', 'expiration_date', 'notify_post', 'notify_email_all', 'update_added_date', 'pinned']
model

alias of intranet.apps.announcements.models.Announcement

declared_fields = {'notify_email_all': <django.forms.fields.BooleanField object>, 'update_added_date': <django.forms.fields.BooleanField object>}
expiration_date = <django.forms.widgets.DateTimeInput object>
class intranet.apps.announcements.forms.AnnouncementRequestForm(*args, **kwargs)[source]

Bases: django.forms.models.ModelForm

A form for generating an announcement request.

class Meta[source]

Bases: object

fields = ['title', 'author', 'content', 'expiration_date', 'teachers_requested', 'notes']
model

alias of intranet.apps.announcements.models.AnnouncementRequest

declared_fields = {}

intranet.apps.announcements.models module

class intranet.apps.announcements.models.Announcement(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Represents an announcement.

title

The title of the announcement

content

The HTML content of the news post

authors

The name of the author

added

The date the announcement was added

updated

The most recent date the announcement was updated

user_map

An attribute corresponding with an AnnouncementUserMap object. A new object is automatically created if it does not exist.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

added

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

property announcementrequest
announcementrequest_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.

author

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

content

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

Returns the content of this announcement with all links nullified.

Returns

The content of this announcement with all links nullified.

property dashboard_type
event

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.

expiration_date

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

get_author()str[source]

Returns ‘author’ if it is set. Otherwise, returns the name of the user who created the announcement.

Returns

The name of the author as it should be displayed with the announcement.

get_next_by_added(*, field=<django.db.models.fields.DateTimeField: added>, is_next=True, **kwargs)
get_next_by_expiration_date(*, field=<django.db.models.fields.DateTimeField: expiration_date>, is_next=True, **kwargs)
get_next_by_updated(*, field=<django.db.models.fields.DateTimeField: updated>, is_next=True, **kwargs)
get_previous_by_added(*, field=<django.db.models.fields.DateTimeField: added>, is_next=False, **kwargs)
get_previous_by_expiration_date(*, field=<django.db.models.fields.DateTimeField: expiration_date>, is_next=False, **kwargs)
get_previous_by_updated(*, field=<django.db.models.fields.DateTimeField: updated>, is_next=False, **kwargs)
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.

id

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

property is_this_year

Return whether the announcement was created after July 1st of this school year.

is_visible(user)[source]
is_visible_requester(user)[source]
is_visible_submitter(user)[source]
notify_email_all

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

notify_post

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.announcements.models.AnnouncementManager object>
pinned

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.

updated

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.

property user_map
class intranet.apps.announcements.models.AnnouncementManager[source]

Bases: django.db.models.manager.Manager

hidden_announcements(user)[source]

Get a list of announcements marked as hidden for a given user (usually request.user).

These are all announcements visible to the user – they have just decided to hide them.

this_year()[source]

Get AnnouncementRequests from this school year only.

visible_to_user(user)[source]

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

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

Apparently this .filter() call occasionally returns duplicates, hence the .distinct()…

class intranet.apps.announcements.models.AnnouncementRequest(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Represents a request for an announcement.

title

The title of the announcement

content

The HTML content of the news post

notes

Notes for the person who approves the announcement

added

The date the request was added

updated

The most recent date the request was updated

user

The user who submitted the request

teachers_requested

The teachers requested to approve the request

teachers_approved

The teachers who have approved the request

posted

ForeignKey to Announcement if posted

posted_by

The user (administrator) that approved the request

rejected

Boolean describing whether the post was rejected by an administrator. This will hide it.

admin_email_sent

Boolean describing whether an email was sent to an Intranet administrator to post the announcement.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

added

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

admin_email_sent

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

author

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

content

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

expiration_date

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_added(*, field=<django.db.models.fields.DateTimeField: added>, is_next=True, **kwargs)
get_next_by_expiration_date(*, field=<django.db.models.fields.DateTimeField: expiration_date>, is_next=True, **kwargs)
get_next_by_updated(*, field=<django.db.models.fields.DateTimeField: updated>, is_next=True, **kwargs)
get_previous_by_added(*, field=<django.db.models.fields.DateTimeField: added>, is_next=False, **kwargs)
get_previous_by_expiration_date(*, field=<django.db.models.fields.DateTimeField: expiration_date>, is_next=False, **kwargs)
get_previous_by_updated(*, field=<django.db.models.fields.DateTimeField: updated>, is_next=False, **kwargs)
id

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

notes

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.announcements.models.AnnouncementRequestManager object>
posted

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.

posted_by

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.

posted_by_id

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

posted_id

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

rejected

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

rejected_by

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.

rejected_by_id

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

teachers_approved

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.

teachers_requested

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.

title

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

updated

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.

class intranet.apps.announcements.models.AnnouncementRequestManager[source]

Bases: django.db.models.manager.Manager

get_queryset()[source]
class intranet.apps.announcements.models.AnnouncementRequestQuerySet(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.announcements.models.AnnouncementRequest_teachers_approved(id, announcementrequest, user)

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

announcementrequest

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.

announcementrequest_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.announcements.models.AnnouncementRequest_teachers_requested(id, announcementrequest, user)

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

announcementrequest

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.

announcementrequest_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.announcements.models.AnnouncementUserMap(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Represents mapping fields between announcements and users.

These attributes would be a part of the Announcement model, but if they are, the last updated date is changed whenever a student sees or hides an announcement.

Access these through announcement.user_map

If you are checking to see whether a user has hidden an announcement, use:

Announcement.objects.hidden_announcements(user)

announcement

The one-to-one mapping between this object and the Announcement it is for

users_hidden

A many-to-many field of Users who have hidden this announcement

users_seen

A many-to-many field of Users who have seen this announcement

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

announcement

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

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

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.

users_seen

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.

class intranet.apps.announcements.models.AnnouncementUserMap_users_hidden(id, announcementusermap, user)

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

announcementusermap

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.

announcementusermap_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.announcements.models.AnnouncementUserMap_users_seen(id, announcementusermap, user)

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

announcementusermap

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.

announcementusermap_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.announcements.models.Announcement_groups(id, announcement, group)

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

announcement

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.

announcement_id

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

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>

intranet.apps.announcements.notifications module

intranet.apps.announcements.notifications.admin_request_announcement_email(request, form, obj)[source]

Send an admin announcement request email.

form: The announcement request form obj: The announcement request object

intranet.apps.announcements.notifications.announcement_approved_email(request, obj, req)[source]

Email the requested teachers and submitter whenever an administrator approves an announcement request.

obj: the Announcement object req: the AnnouncementRequest object

intranet.apps.announcements.notifications.announcement_posted_email(request, obj, send_all=False)[source]

Send a notification posted email.

obj: The announcement object

intranet.apps.announcements.notifications.announcement_posted_twitter(request, obj)[source]
intranet.apps.announcements.notifications.notify_twitter(status)[source]
intranet.apps.announcements.notifications.request_announcement_email(request, form, obj)[source]

Send an announcement request email.

form: The announcement request form obj: The announcement request object

intranet.apps.announcements.serializers module

class intranet.apps.announcements.serializers.AnnouncementSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)[source]

Bases: rest_framework.serializers.HyperlinkedModelSerializer

class Meta[source]

Bases: object

fields = ('url', 'id', 'title', 'content', 'author', 'user', 'added', 'updated', 'groups', 'pinned')
model

alias of intranet.apps.announcements.models.Announcement

get_author(obj)[source]

intranet.apps.announcements.tests module

class intranet.apps.announcements.tests.AnnouncementTest(methodName='runTest')[source]

Bases: intranet.test.ion_test.IonTestCase

Tests for the announcements module.

setUp()[source]
test_change_announcements()[source]
test_get_announcements()[source]

intranet.apps.announcements.urls module

intranet.apps.announcements.views module

intranet.apps.announcements.views.announcement_approved_hook(request, obj, req)[source]

Runs whenever an administrator approves an announcement request.

obj: the Announcement object req: the AnnouncementRequest object

intranet.apps.announcements.views.announcement_posted_hook(request, obj)[source]

Runs whenever a new announcement is created, or a request is approved and posted.

obj: The Announcement object

intranet.apps.announcements.views.request_announcement_success_self_view(request)[source]
intranet.apps.announcements.views.request_announcement_success_view(request)[source]
intranet.apps.announcements.views.request_announcement_view(request)[source]

The request announcement page.

Module contents