# HG changeset patch # User Brian Neal # Date 1409443892 18000 # Node ID dbc389a409f5879a0ba4092321fe15d77d801f28 # Parent 6bbd1473d48e04b1cfc041db32a5e61d13f89033 Work in progress: rework private messages. Add trash view. diff -r 6bbd1473d48e -r dbc389a409f5 messages/urls.py --- a/messages/urls.py Sat Aug 30 17:25:38 2014 -0500 +++ b/messages/urls.py Sat Aug 30 19:11:32 2014 -0500 @@ -15,9 +15,9 @@ url(r'^outbox/$', 'messages.views.outbox', name='messages-outbox'), -# url(r'^trash/$', -# 'messages.views.trash', -# name='messages-trash'), + url(r'^trash/$', + 'messages.views.trash', + name='messages-trash'), # url(r'^options/$', # 'messages.views.options', # name='messages-options'), diff -r 6bbd1473d48e -r dbc389a409f5 messages/views.py --- a/messages/views.py Sat Aug 30 17:25:38 2014 -0500 +++ b/messages/views.py Sat Aug 30 19:11:32 2014 -0500 @@ -97,6 +97,21 @@ @login_required +def trash(request): + + msg_list = Message.objects.trash(request.user) + + page = _get_page(request, msg_list) + + return render(request, 'messages/trash.html', { + 'tab': 'trash', + 'page': page, + 'inbox_pct': None, + 'outbox_pct': None, + }) + + +@login_required def compose_to(request, receiver): """ This function displays the base tabbed private messages view, @@ -113,27 +128,6 @@ }) -def trash(request): - """ - Returns the trash for the user. - - """ - if not request.user.is_authenticated(): - return HttpResponseForbidden() - - msg_list = Message.objects.trash(request.user) - paginator = Paginator(msg_list, MSGS_PER_PAGE) - try: - msgs = paginator.page(_get_page(request)) - except (EmptyPage, InvalidPage): - msgs = paginator.page(paginator.num_pages) - - return render(request, 'messages/trash_tab.html', { - 'msgs': msgs, - 'url': reverse('messages-trash'), - }) - - def message(request): """ This view function retrieves a message and returns it as a JSON object. diff -r 6bbd1473d48e -r dbc389a409f5 sg101/templates/messages/inbox.html --- a/sg101/templates/messages/inbox.html Sat Aug 30 17:25:38 2014 -0500 +++ b/sg101/templates/messages/inbox.html Sat Aug 30 19:11:32 2014 -0500 @@ -6,6 +6,7 @@ Messages in italics have been replied to.

{% if page.object_list %} + {% include "messages/pagination.html" %}
diff -r 6bbd1473d48e -r dbc389a409f5 sg101/templates/messages/messages_base.html --- a/sg101/templates/messages/messages_base.html Sat Aug 30 17:25:38 2014 -0500 +++ b/sg101/templates/messages/messages_base.html Sat Aug 30 19:11:32 2014 -0500 @@ -23,8 +23,8 @@ {% endcomment %}
  • {% if tab != 'outbox' %}{% endif %}Outbox{% if tab != 'outbox' %}{% endif %} {% if outbox_pct %}({{ outbox_pct }}% used){% endif %}
  • +
  • {% if tab != 'trash' %}{% endif %}Trash{% if tab != 'trash' %}{% endif %}
  • {% comment %} -
  • {% if tab != 'trash' %}{% endif %}Trash{% if tab != 'trash' %}{% endif %}
  • {% if tab != 'options' %}{% endif %}Options{% if tab != 'options' %}{% endif %}
  • {% endcomment %} diff -r 6bbd1473d48e -r dbc389a409f5 sg101/templates/messages/outbox.html --- a/sg101/templates/messages/outbox.html Sat Aug 30 17:25:38 2014 -0500 +++ b/sg101/templates/messages/outbox.html Sat Aug 30 19:11:32 2014 -0500 @@ -6,6 +6,7 @@ by the recipient. Messages in italics have been replied to.

    {% if page.object_list %} + {% include "messages/pagination.html" %}
    diff -r 6bbd1473d48e -r dbc389a409f5 sg101/templates/messages/trash.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sg101/templates/messages/trash.html Sat Aug 30 19:11:32 2014 -0500 @@ -0,0 +1,44 @@ +{% extends 'messages/messages_base.html' %} +{% block messages_content %} +

    Trash (Page {{ page.number }} of {{ page.paginator.num_pages }})

    +

    +This is your trash folder. It contains messages that you have deleted. The messages will be gone +forever when the other party deletes their copies. Until that happens you can undelete them to move +them back to either the inbox or outbox. +

    +

    +Messages in bold are unread. Messages in italics have been replied to. +

    +{% if page.object_list %} + {% include "messages/pagination.html" %} + +
    + + + + + + + + {% for msg in page.object_list %} + + + + + + + + {% endfor %} + +
    FromToSubjectDate
    + {{ msg.sender.username }} + {{ msg.receiver.username }} + {{ msg.subject }} + {{ msg.send_date|date:"M j, Y g:i:s A T" }}
    +
    + {% include "messages/pagination.html" %} +{% else %} +

    Your Trash is empty.

    +{% endif %} +{% endblock %} diff -r 6bbd1473d48e -r dbc389a409f5 sg101/templates/messages/trash_tab.html --- a/sg101/templates/messages/trash_tab.html Sat Aug 30 17:25:38 2014 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -{% if messages %} - -{% endif %} -{% if msgs.object_list %} -
    - - - - - - - - - {% for msg in msgs.object_list %} - - - - - - - - {% endfor %} - -
    FromToSubjectDate
    - {{ msg.sender.username }} - {{ msg.receiver.username }} - {{ msg.subject }} - {{ msg.send_date|date:"M j, Y g:i:s A T" }}
    -
    - {% include "messages/pagination.html" %} - -{% else %} -

    Your Trash is empty.

    -{% endif %}