Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOTIFICATION_UNCONFIGURABLE_MEDIA #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ NOTIFICATION_BACKENDS
TODO: Describe usage. Look at Pinax


NOTIFICATION_UNCONFIGURABLE_MEDIA
---------------------------------

**Default**::

[]

A list of backends (see above) which the user cannot configure using the `notifications_settings` view's form.


DEFAULT_HTTP_PROTOCOL
---------------------

Expand Down
15 changes: 13 additions & 2 deletions notification/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from django.template import RequestContext
from django.conf import settings

from django.contrib.auth.decorators import login_required

from notification.models import NoticeSetting, NoticeType, NOTICE_MEDIA

NOTIFICATION_UNCONFIGURABLE_MEDIA = getattr(settings, 'NOTIFICATION_UNCONFIGURABLE_MEDIA', [])

@login_required
def notice_settings(request):
Expand All @@ -29,9 +31,18 @@ def notice_settings(request):
"""
notice_types = NoticeType.objects.all()
settings_table = []

notice_media = []

for medium_id, medium_display in NOTICE_MEDIA:
if medium_display in NOTIFICATION_UNCONFIGURABLE_MEDIA:
continue
else:
notice_media.append((medium_id, medium_display))

for notice_type in notice_types:
settings_row = []
for medium_id, medium_display in NOTICE_MEDIA:
for medium_id, medium_display in notice_media:
form_label = "%s_%s" % (notice_type.label, medium_id)
setting = NoticeSetting.for_user(request.user, notice_type, medium_id)
if request.method == "POST":
Expand All @@ -51,7 +62,7 @@ def notice_settings(request):
return HttpResponseRedirect(next_page)

notice_settings = {
"column_headers": [medium_display for medium_id, medium_display in NOTICE_MEDIA],
"column_headers": [medium_display for medium_id, medium_display in notice_media],
"rows": settings_table,
}

Expand Down