<%! from django.core.urlresolvers import reverse %>

<%
def url_for_thread(discussion_id, thread_id):
  return reverse('django_comment_client.forum.views.single_thread', args=[course.id, discussion_id, thread_id])
%>

<% 
def url_for_comment(discussion_id, thread_id, comment_id):
  return url_for_thread(discussion_id, thread_id) + "#" + comment_id
%>

<%
def url_for_discussion(discussion_id):
  return reverse('django_comment_client.forum.views.forum_form_discussion', args=[course.id, discussion_id])
%>

<% 
def discussion_title(discussion_id):
  return get_discussion_title(discussion_id=discussion_id)
%>


<div class="notifications">
  % for notification in notifications:
    ${render_notification(notification)}
  % endfor
</div>

<%def name="render_notification(notification)">
  <div class="notification">
    <% info = notification['info'] %>
    % if notification['notification_type'] == 'post_reply':
      User No.${notification['actor_id']} posted a
      <a href="${url_for_comment(info['commentable_id'], info['thread_id'], info['comment_id'])}">comment</a>
      to the thread
      <a href="${url_for_thread(info['commentable_id'], info['thread_id'])}">${info['thread_title']}</a>
      in discussion
      <a href="${url_for_discussion(info['commentable_id'])}">${discussion_title(info['commentable_id'])}</a>
    % elif notification['notification_type'] == 'post_topic':
      User No.${notification['actor_id']} posted a new thread
      <a href="${url_for_thread(info['commentable_id'], info['thread_id'])}">${info['thread_title']}</a>
      in discussion
      <a href="${url_for_discussion(info['commentable_id'])}">${discussion_title(info['commentable_id'])}</a>
    % endif
  </div>

</%def>
