diff --git a/docs/settings.rst b/docs/settings.rst index 0f409d3b..ed6b5fce 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -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 --------------------- diff --git a/notification/views.py b/notification/views.py index cc524f2a..0ecdd318 100644 --- a/notification/views.py +++ b/notification/views.py @@ -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): @@ -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": @@ -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, }