summaryrefslogtreecommitdiffstats
path: root/hyperkitty
diff options
context:
space:
mode:
Diffstat (limited to 'hyperkitty')
-rw-r--r--hyperkitty/lib/mailman.py4
-rw-r--r--hyperkitty/templates/user_posts.html77
-rw-r--r--hyperkitty/urls.py1
-rw-r--r--hyperkitty/views/accounts.py55
-rw-r--r--hyperkitty/views/search.py3
5 files changed, 134 insertions, 6 deletions
diff --git a/hyperkitty/lib/mailman.py b/hyperkitty/lib/mailman.py
index 3e47e77..0e940ee 100644
--- a/hyperkitty/lib/mailman.py
+++ b/hyperkitty/lib/mailman.py
@@ -69,8 +69,8 @@ def get_subscriptions(store, client, mm_user):
likes, dislikes, _myvote = get_votes(mlist, email_hashes)
posts_count = len(email_hashes)
cache.set(cache_key, (likes, dislikes, posts_count))
- all_posts_url = "%s?list=%s&query=user_id:%s" % \
- (reverse("search"), mlist, urlquote(mm_user.user_id))
+ all_posts_url = "%s?list=%s" % \
+ (reverse("user_posts", mm_user.user_id), mlist)
likestatus = "neutral"
if likes - dislikes >= 10:
likestatus = "likealot"
diff --git a/hyperkitty/templates/user_posts.html b/hyperkitty/templates/user_posts.html
new file mode 100644
index 0000000..bd6a1a9
--- /dev/null
+++ b/hyperkitty/templates/user_posts.html
@@ -0,0 +1,77 @@
+{% extends "base.html" %}
+{% load url from future %}
+{% load gravatar %}
+{% load hk_generic %}
+
+
+{% block title %}
+Messages by {{ fullname }}{% if mlist %} - {{ mlist.display_name|default:mlist.name|escapeemail }} {% endif %} - {{ app_name|title }}
+{% endblock %}
+
+{% block content %}
+
+<div class="row-fluid">
+
+<div id="months-list" class="span2"> </div>
+
+ <div id="thread-list" class="span8">
+
+ <div class="thread-list-header page-header">
+ {% if mlist %}
+ <h1>Messages by {{ fullname }}
+ <small>in {{ mlist.display_name|default:mlist.name|escapeemail }}</small>
+ </h1>
+ {% else %}
+ <h1>Messages by {{ fullname }}</h1>
+ {% endif %}
+ <ul class="thread-list-info">
+ {% if mlist.display_name %}
+ <li class="list-address">
+ {{ mlist.name|escapeemail }}
+ </li>
+ {% endif %}
+ <li class="discussion">
+ {{ messages.paginator.count }} messages
+ </li>
+ <li>
+ <a href="{% url 'public_user_profile' user_id=user_id %}">
+ Back to {{ fullname }}'s profile
+ </a>
+ </li>
+ </ul>
+
+ </div>
+
+ {% for message in messages %}
+ {% include "messages/summary_message.html" %}
+ {% empty %}
+ <p>Sorry no email could be found by this user.</p>
+ {% endfor %}
+
+ {% include "paginator.html" with pager=messages %}
+
+ </div>
+
+</div>
+
+{% endblock %}
+
+{% block additionaljs %}
+<script>
+$(document).ready(function() {
+ $('span.expander').expander({
+ slicePoint: 500,
+ userCollapseText : '\n[View Less]',
+ expandText : '\n[View More]',
+ beforeExpand: function() {
+ $(this).removeClass("collapsed");
+ $(this).addClass("expanded");
+ },
+ onCollapse: function() {
+ $(this).removeClass("expanded");
+ $(this).addClass("collapsed");
+ }
+ });
+});
+</script>
+{% endblock %}
diff --git a/hyperkitty/urls.py b/hyperkitty/urls.py
index e59c0ce..865d126 100644
--- a/hyperkitty/urls.py
+++ b/hyperkitty/urls.py
@@ -51,6 +51,7 @@ urlpatterns = patterns('hyperkitty.views',
# Users
url(r'^user/(?P<user_id>[^/]+)/$', 'accounts.public_profile', name='public_user_profile'),
+ url(r'^user/(?P<user_id>[^/]+)/posts$', 'accounts.posts', name='user_posts'),
# List archives and overview
url(r'^list/(?P<mlist_fqdn>[^/@]+@[^/@]+)/(?P<year>\d{4})/(?P<month>\d\d?)/(?P<day>\d\d?)/$',
diff --git a/hyperkitty/views/accounts.py b/hyperkitty/views/accounts.py
index 9a6b9ff..aa95ece 100644
--- a/hyperkitty/views/accounts.py
+++ b/hyperkitty/views/accounts.py
@@ -42,7 +42,8 @@ from hyperkitty.models import UserProfile, Rating, Favorite, LastView
from hyperkitty.views.forms import RegistrationForm, UserProfileForm
from hyperkitty.lib import get_store
from hyperkitty.lib.view_helpers import FLASH_MESSAGES, paginate
-from hyperkitty.lib.mailman import get_subscriptions
+from hyperkitty.lib.mailman import get_subscriptions, is_mlist_authorized
+from hyperkitty.lib.voting import set_message_votes
logger = logging.getLogger(__name__)
@@ -294,3 +295,55 @@ def public_profile(request, user_id):
"likestatus": likestatus,
}
return render(request, "user_public_profile.html", context)
+
+
+def posts(request, user_id):
+ store = get_store(request)
+ mlist_fqdn = request.GET.get("list")
+ sort_mode = request.GET.get('sort')
+ if mlist_fqdn is None:
+ mlist = None
+ return HttpResponse("Not implemented yet", status=500)
+ else:
+ mlist = store.get_list(mlist_fqdn)
+ if mlist is None:
+ raise Http404("No archived mailing-list by that name.")
+ if not is_mlist_authorized(request, mlist):
+ return render(request, "errors/private.html", {
+ "mlist": mlist,
+ }, status=403)
+
+ # Get the user's full name
+ try:
+ client = mailmanclient.Client('%s/3.0' %
+ settings.MAILMAN_REST_SERVER,
+ settings.MAILMAN_API_USER,
+ settings.MAILMAN_API_PASS)
+ mm_user = client.get_user(user_id)
+ except HTTPError:
+ raise Http404("No user with this ID: %s" % user_id)
+ except mailmanclient.MailmanConnectionError:
+ fullname = None
+ else:
+ fullname = mm_user.display_name
+ if not fullname:
+ fullname = store.get_sender_name(user_id)
+
+ # Get the messages and paginate them
+ messages = store.get_messages_by_user_id(user_id, mlist_fqdn)
+ try:
+ page_num = int(request.GET.get('page', "1"))
+ except ValueError:
+ page_num = 1
+ messages = paginate(messages, page_num)
+
+ for message in messages:
+ set_message_votes(message, request.user)
+
+ context = {
+ 'user_id': user_id,
+ 'mlist' : mlist,
+ 'messages': messages,
+ 'fullname': fullname,
+ }
+ return render(request, "user_posts.html", context)
diff --git a/hyperkitty/views/search.py b/hyperkitty/views/search.py
index 4966f03..300a047 100644
--- a/hyperkitty/views/search.py
+++ b/hyperkitty/views/search.py
@@ -134,6 +134,3 @@ def search(request, page=1):
'sort_mode': sort_mode,
}
return render(request, "search_results.html", context)
-
-
-