Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Commit

Permalink
イベント参加後のメッセージを実装した
Browse files Browse the repository at this point in the history
  • Loading branch information
giginet committed Oct 7, 2014
1 parent cc2251d commit a8712c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/kawaz/apps/events/views.py
Expand Up @@ -3,6 +3,7 @@
from django.views.generic.list import ListView, MultipleObjectMixin
from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.views.generic.dates import YearArchiveView, MonthArchiveView, BaseArchiveIndexView
from django.contrib import messages
from django.http.response import HttpResponseNotFound
from django.core.urlresolvers import reverse_lazy
from django.core.exceptions import PermissionDenied
Expand Down Expand Up @@ -86,6 +87,7 @@ def attend(self, request, *args, **kwargs):
"""
self.object = self.get_object()
success_url = self.get_success_url()
messages.add_message(request, messages.SUCCESS, 'You have been attended this event.')
try:
self.object.attend(request.user)
return HttpResponseRedirect(success_url)
Expand Down Expand Up @@ -113,6 +115,7 @@ def quit(self, request, *args, **kwargs):
"""
self.object = self.get_object()
success_url = self.get_success_url()
messages.add_message(request, messages.SUCCESS, 'You have been quited from this event.')
try:
self.object.quit(request.user)
return HttpResponseRedirect(success_url)
Expand Down
6 changes: 6 additions & 0 deletions src/kawaz/settings.py
Expand Up @@ -210,6 +210,12 @@
# 環境依存の設定(デプロイサーバー固有の設定など)を読み込む
LOCAL_SETTINGS_LOADED = False

# DjangoのMessageをBootstrap3に適応させている
from django.contrib.messages import constants as messages
MESSAGE_TAGS = {
messages.ERROR: 'danger'
}

if not 'test' in sys.argv:
try:
from .local_settings import *
Expand Down
5 changes: 5 additions & 0 deletions src/kawaz/templates/base.html
Expand Up @@ -81,6 +81,11 @@
{% block carousel %}
{% endblock %}
<div class="container">
{% block messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }}">{{ message }}</div>
{% endfor %}
{% endblock %}
{% block content %}
{% endblock %}
</div>
Expand Down

0 comments on commit a8712c5

Please sign in to comment.