Display notifications on the site, and provide a ajaxy way to acknowledge them
This commit is contained in:
@@ -5,6 +5,7 @@ from django.db.models import Sum
|
||||
from donate.models import Donation
|
||||
from datetime import datetime
|
||||
from django.conf import settings
|
||||
from notification.models import Notice
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
def random_quote(request):
|
||||
@@ -35,6 +36,10 @@ def donation_info(request):
|
||||
progress = donationTotal/goal*100
|
||||
return {'donation_month_total': donationTotal, 'donation_month_goal': goal, 'donation_goal_progress': progress}
|
||||
|
||||
def notifications(request):
|
||||
if request.user.is_authenticated():
|
||||
return {'notices': Notice.objects.filter(unseen=True, user=request.user, on_site=True)}
|
||||
|
||||
def javascript_uris(request):
|
||||
uris = (
|
||||
'local.views.mark_notifications_read',
|
||||
|
@@ -4,6 +4,7 @@ from django.views.generic.simple import direct_to_template
|
||||
|
||||
urlpatterns = patterns('local',
|
||||
url(r'^me$', 'views.profile', name='user_profile'),
|
||||
url(r'^me/notifications/mark_read$', 'views.mark_notifications_read'),
|
||||
url(r'^user/(?P<username>.+)$', 'views.profile'),
|
||||
url(r'^player/(?P<mc_username>.+)$', 'views.profile'),
|
||||
url(r'^list$', 'views.list'),
|
||||
|
@@ -130,3 +130,10 @@ def index(request):
|
||||
latestNews = None
|
||||
forums = Forum.objects.filter(parent=None)
|
||||
return render_to_response('local/index.html', {'news': latestNews, 'forums': forums}, context_instance = RequestContext(request))
|
||||
|
||||
@login_required
|
||||
def mark_notifications_read(request):
|
||||
for notice in notification.Notice.objects.notices_for(request.user, unseen=True):
|
||||
notice.unseen = False
|
||||
notice.save()
|
||||
return HttpResponseRedirect(reverse('user_profile'))
|
||||
|
Reference in New Issue
Block a user