Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding message middleware to notify users of moderation.

  • Loading branch information...
commit d413e97dd460d0769c2a43fc316a36cd0041a7e2 1 parent 0c02a2a
Justin Abrahms justinabrahms authored
3  django_website/aggregator/views.py
View
@@ -3,6 +3,7 @@
import logging
from django.shortcuts import render_to_response, get_object_or_404, redirect
from django.template import RequestContext
+from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
@@ -59,6 +60,8 @@ def add_feed(request, feed_type_slug):
f = FeedModelForm(request.POST or None, instance=instance)
if f.is_valid():
f.save()
+ messages.add_message(
+ request, messages.INFO, 'Your feed has entered moderation. Please allow up to 1 week for processing.')
return redirect('community-index')
ctx = {'form': f, 'feed_type': ft, 'adding': True}
7 django_website/settings/www.py
View
@@ -65,6 +65,7 @@
'django.contrib.contenttypes',
'django.contrib.flatpages',
'django.contrib.humanize',
+ 'django.contrib.messages',
'django.contrib.redirects',
'django.contrib.sessions',
'django.contrib.sitemaps',
@@ -80,6 +81,8 @@
'djangosecure',
]
+MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
+
CACHE_MIDDLEWARE_SECONDS = 60 * 5 # 5 minutes
CACHE_MIDDLEWARE_KEY_PREFIX = 'djangoproject'
CACHE_MIDDLEWARE_GZIP = True
@@ -88,6 +91,7 @@
MIDDLEWARE_CLASSES = [
'djangosecure.middleware.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.common.CommonMiddleware',
@@ -108,7 +112,8 @@
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django_website.context_processors.recent_release",
-]
+ "django.contrib.messages.context_processors.messages",
+ ]
DEFAULT_FROM_EMAIL = "noreply@djangoproject.com"
20 django_website/templates/aggregator/index.html
View
@@ -1,9 +1,27 @@
{% extends "base_community.html" %}
+{% block extrahead %}
+{{ block.super }}
+<style type="text/css">
+ul.messages li {
+ font-weight: 600;
+ list-style: none;
+ padding: 20px 0;
+</style>
+{% endblock %}
+
{% block content %}
<h1>Community</h1>
<h2 class="deck">This page, updated regularly, aggregates what's going on in the community.</h2>
+{% if messages %}
+<ul class="messages">
+ {% for message in messages %}
+ <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
+ {% endfor %}
+</ul>
+{% endif %}
+
{% for feedtype in feedtype_list %}
<div id="{{ feedtype.slug }}" class="module {% cycle "first" "last" %}">
<h3 class="header">
@@ -19,7 +37,7 @@ <h3 class="header">
<a href="{% url community-feed-list feedtype.slug %}">View more</a>
{% endif %}
{% if feedtype.items and feedtype.can_self_add %}
- or
+ or
{% endif %}
{% if feedtype.can_self_add %}
<a href="{% url community-add-feed feedtype.slug %}">Add your feed</a>
Please sign in to comment.
Something went wrong with that request. Please try again.