intranet.apps.announcements package¶
Submodules¶
intranet.apps.announcements.admin module¶
intranet.apps.announcements.api module¶
-
class
intranet.apps.announcements.api.
IsAnnouncementAdminOrReadOnly
[source]¶ Bases:
rest_framework.permissions.BasePermission
-
class
intranet.apps.announcements.api.
ListCreateAnnouncement
(**kwargs)[source]¶ Bases:
rest_framework.generics.ListCreateAPIView
-
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
-
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
¶
-
-
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
-
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
= {}¶
-
class
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
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
¶
-
exception
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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
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.
-
property
content_no_links
¶ 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 aReverseManyToOneDescriptor
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.
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
andTopping.pizzas
areManyToManyDescriptor
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.
-
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 aForwardManyToOneDescriptor
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
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.
-
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
¶
-
exception
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.
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 aForwardManyToOneDescriptor
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 aForwardManyToOneDescriptor
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 aForwardManyToOneDescriptor
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
andTopping.pizzas
areManyToManyDescriptor
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
andTopping.pizzas
areManyToManyDescriptor
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 aForwardManyToOneDescriptor
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
-
class
intranet.apps.announcements.models.
AnnouncementRequestQuerySet
(model=None, query=None, using=None, hints=None)[source]¶
-
class
intranet.apps.announcements.models.
AnnouncementRequest_teachers_approved
(id, announcementrequest, user)¶ Bases:
django.db.models.base.Model
-
exception
DoesNotExist
¶
-
exception
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 aForwardManyToOneDescriptor
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 aForwardManyToOneDescriptor
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.
-
exception
-
class
intranet.apps.announcements.models.
AnnouncementRequest_teachers_requested
(id, announcementrequest, user)¶ Bases:
django.db.models.base.Model
-
exception
DoesNotExist
¶
-
exception
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 aForwardManyToOneDescriptor
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 aForwardManyToOneDescriptor
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.
-
exception
-
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
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
¶
-
exception
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 aForwardOneToOneDescriptor
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
andTopping.pizzas
areManyToManyDescriptor
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
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
Bases:
django.db.models.base.Model
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 aForwardManyToOneDescriptor
instance.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
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 aForwardManyToOneDescriptor
instance.
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
¶
-
exception
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 aForwardManyToOneDescriptor
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 aForwardManyToOneDescriptor
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.
-
exception
-
class
intranet.apps.announcements.models.
Announcement_groups
(id, announcement, group)¶ Bases:
django.db.models.base.Model
-
exception
DoesNotExist
¶
-
exception
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 aForwardManyToOneDescriptor
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 aForwardManyToOneDescriptor
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>¶
-
exception
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.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
¶
-
-
class
intranet.apps.announcements.tests module¶
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