Add 'index title' setting to master view
This was needed due to a new way of showing the index link when e.g. viewing a record, particularly with regard to messaging and a new template design.
This commit is contained in:
parent
c9afae3a44
commit
f3cab67aaf
|
@ -296,6 +296,13 @@ class MasterView(View):
|
||||||
"""
|
"""
|
||||||
return self.request.route_url(self.get_route_prefix())
|
return self.request.route_url(self.get_route_prefix())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_index_title(cls):
|
||||||
|
"""
|
||||||
|
Returns the title for the index page.
|
||||||
|
"""
|
||||||
|
return getattr(cls, 'index_title', cls.get_model_title_plural())
|
||||||
|
|
||||||
def get_action_url(self, action, instance):
|
def get_action_url(self, action, instance):
|
||||||
"""
|
"""
|
||||||
Generate a URL for the given action on the given instance.
|
Generate a URL for the given action on the given instance.
|
||||||
|
@ -317,6 +324,7 @@ class MasterView(View):
|
||||||
'model_title_plural': self.get_model_title_plural(),
|
'model_title_plural': self.get_model_title_plural(),
|
||||||
'route_prefix': self.get_route_prefix(),
|
'route_prefix': self.get_route_prefix(),
|
||||||
'permission_prefix': self.get_permission_prefix(),
|
'permission_prefix': self.get_permission_prefix(),
|
||||||
|
'index_title': self.get_index_title(),
|
||||||
'index_url': self.get_index_url(),
|
'index_url': self.get_index_url(),
|
||||||
'action_url': self.get_action_url,
|
'action_url': self.get_action_url,
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,18 @@ class MessagesView(MasterView):
|
||||||
replying = False
|
replying = False
|
||||||
reply_header_sent_format = '%a %d %b %Y at %I:%M %p'
|
reply_header_sent_format = '%a %d %b %Y at %I:%M %p'
|
||||||
|
|
||||||
|
def get_index_title(self):
|
||||||
|
if self.listing:
|
||||||
|
return self.index_title
|
||||||
|
if self.viewing:
|
||||||
|
message = self.get_instance()
|
||||||
|
recipient = self.get_recipient(message)
|
||||||
|
if recipient and recipient.status == enum.MESSAGE_STATUS_ARCHIVE:
|
||||||
|
return "Message Archive"
|
||||||
|
elif not recipient:
|
||||||
|
return "Sent Messages"
|
||||||
|
return "Message Inbox"
|
||||||
|
|
||||||
def get_index_url(self):
|
def get_index_url(self):
|
||||||
# not really used, but necessary to make certain other code happy
|
# not really used, but necessary to make certain other code happy
|
||||||
return self.request.route_url('messages.inbox')
|
return self.request.route_url('messages.inbox')
|
||||||
|
@ -344,11 +356,7 @@ class MessagesView(MasterView):
|
||||||
Move a message, either to the archive or back to the inbox.
|
Move a message, either to the archive or back to the inbox.
|
||||||
"""
|
"""
|
||||||
message = self.get_instance()
|
message = self.get_instance()
|
||||||
recipient = None
|
recipient = self.get_recipient(message)
|
||||||
for recip in message.recipients:
|
|
||||||
if recip.recipient is self.request.user:
|
|
||||||
recipient = recip
|
|
||||||
break
|
|
||||||
if not recipient:
|
if not recipient:
|
||||||
raise httpexceptions.HTTPForbidden
|
raise httpexceptions.HTTPForbidden
|
||||||
|
|
||||||
|
@ -414,6 +422,7 @@ class InboxView(MessagesView):
|
||||||
"""
|
"""
|
||||||
url_prefix = '/messages/inbox'
|
url_prefix = '/messages/inbox'
|
||||||
grid_key = 'messages.inbox'
|
grid_key = 'messages.inbox'
|
||||||
|
index_title = "Message Inbox"
|
||||||
|
|
||||||
def get_index_url(self):
|
def get_index_url(self):
|
||||||
return self.request.route_url('messages.inbox')
|
return self.request.route_url('messages.inbox')
|
||||||
|
@ -429,6 +438,7 @@ class ArchiveView(MessagesView):
|
||||||
"""
|
"""
|
||||||
url_prefix = '/messages/archive'
|
url_prefix = '/messages/archive'
|
||||||
grid_key = 'messages.archive'
|
grid_key = 'messages.archive'
|
||||||
|
index_title = "Message Archive"
|
||||||
|
|
||||||
def get_index_url(self):
|
def get_index_url(self):
|
||||||
return self.request.route_url('messages.archive')
|
return self.request.route_url('messages.archive')
|
||||||
|
@ -445,6 +455,7 @@ class SentView(MessagesView):
|
||||||
url_prefix = '/messages/sent'
|
url_prefix = '/messages/sent'
|
||||||
grid_key = 'messages.sent'
|
grid_key = 'messages.sent'
|
||||||
checkboxes = False
|
checkboxes = False
|
||||||
|
index_title = "Sent Messages"
|
||||||
|
|
||||||
def get_index_url(self):
|
def get_index_url(self):
|
||||||
return self.request.route_url('messages.sent')
|
return self.request.route_url('messages.sent')
|
||||||
|
|
Loading…
Reference in a new issue