Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b8e19b76
authored
Apr 27, 2015
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: invalidate template fragment cache in Message*Views
parent
c6ef1eb4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
circle/dashboard/views/message.py
+15
-5
No files found.
circle/dashboard/views/message.py
View file @
b8e19b76
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.core.cache
import
cache
from
django.core.cache.utils
import
make_template_fragment_key
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
from
django.views.generic
import
CreateView
,
DeleteView
,
UpdateView
from
django.views.generic
import
CreateView
,
DeleteView
,
UpdateView
...
@@ -28,29 +30,37 @@ from ..models import Message
...
@@ -28,29 +30,37 @@ from ..models import Message
from
..tables
import
MessageListTable
from
..tables
import
MessageListTable
class
InvalidateMessageCacheMixin
(
object
):
def
post
(
self
,
*
args
,
**
kwargs
):
key
=
make_template_fragment_key
(
'broadcast_messages'
)
cache
.
delete
(
key
)
return
super
(
InvalidateMessageCacheMixin
,
self
)
.
post
(
*
args
,
**
kwargs
)
class
MessageList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
class
MessageList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
template_name
=
"dashboard/message-list.html"
template_name
=
"dashboard/message-list.html"
model
=
Message
model
=
Message
table_class
=
MessageListTable
table_class
=
MessageListTable
class
MessageDetail
(
LoginRequiredMixin
,
Superuser
RequiredMixin
,
class
MessageDetail
(
InvalidateMessageCacheMixin
,
Login
RequiredMixin
,
SuccessMessageMixin
,
UpdateView
):
Su
peruserRequiredMixin
,
Su
ccessMessageMixin
,
UpdateView
):
model
=
Message
model
=
Message
template_name
=
"dashboard/message-edit.html"
template_name
=
"dashboard/message-edit.html"
form_class
=
MessageForm
form_class
=
MessageForm
success_message
=
_
(
"Broadcast message successfully updated."
)
success_message
=
_
(
"Broadcast message successfully updated."
)
class
MessageCreate
(
LoginRequiredMixin
,
Superuser
RequiredMixin
,
class
MessageCreate
(
InvalidateMessageCacheMixin
,
Login
RequiredMixin
,
SuccessMessageMixin
,
CreateView
):
Su
peruserRequiredMixin
,
Su
ccessMessageMixin
,
CreateView
):
model
=
Message
model
=
Message
template_name
=
"dashboard/message-create.html"
template_name
=
"dashboard/message-create.html"
form_class
=
MessageForm
form_class
=
MessageForm
success_message
=
_
(
"New broadcast message successfully created."
)
success_message
=
_
(
"New broadcast message successfully created."
)
class
MessageDelete
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
DeleteView
):
class
MessageDelete
(
InvalidateMessageCacheMixin
,
LoginRequiredMixin
,
SuperuserRequiredMixin
,
DeleteView
):
model
=
Message
model
=
Message
template_name
=
"dashboard/confirm/base-delete.html"
template_name
=
"dashboard/confirm/base-delete.html"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment