Merged in personal/shane/v5.6.2-dev0@8144 from shane@time-travellers.org:
Added untrack to document and search pages. Fixes #1381. - Legacy-Id: 8145
This commit is contained in:
commit
f50fa3a412
|
@ -23,7 +23,8 @@ urlpatterns = patterns('ietf.community.views',
|
|||
url(r'^group/(?P<acronym>[\w.@+-]+)/unsubscribe/$', 'unsubscribe_group_list', {'significant': False}, name='unsubscribe_group_list'),
|
||||
url(r'^group/(?P<acronym>[\w.@+-]+)/unsubscribe/significant/$', 'unsubscribe_group_list', {'significant': True}, name='unsubscribe_significant_group_list'),
|
||||
|
||||
url(r'^add_document/(?P<document_name>[^/]+)/$', 'add_document', name='community_add_document'),
|
||||
url(r'^add_track_document/(?P<document_name>[^/]+)/$', 'add_track_document', name='community_add_track_document'),
|
||||
url(r'^remove_track_document/(?P<document_name>[^/]+)/$', 'remove_track_document', name='community_remove_track_document'),
|
||||
url(r'^(?P<list_id>[\d]+)/remove_document/(?P<document_name>[^/]+)/$', 'remove_document', name='community_remove_document'),
|
||||
url(r'^(?P<list_id>[\d]+)/remove_rule/(?P<rule_id>[^/]+)/$', 'remove_rule', name='community_remove_rule'),
|
||||
url(r'^(?P<list_id>[\d]+)/subscribe/confirm/(?P<email>[\w.@+-]+)/(?P<date>[\d]+)/(?P<confirm_hash>[a-f0-9]+)/$', 'confirm_subscription', name='confirm_subscription'),
|
||||
|
|
|
@ -75,7 +75,10 @@ def manage_group_list(request, acronym):
|
|||
return _manage_list(request, clist)
|
||||
|
||||
|
||||
def add_document(request, document_name):
|
||||
def add_track_document(request, document_name):
|
||||
"""supports the "Track this document" functionality
|
||||
|
||||
This is exposed in the document view and in document search results."""
|
||||
if not request.user.is_authenticated():
|
||||
path = urlquote(request.get_full_path())
|
||||
tup = settings.LOGIN_URL, REDIRECT_FIELD_NAME, path
|
||||
|
@ -85,6 +88,19 @@ def add_document(request, document_name):
|
|||
clist.update()
|
||||
return add_document_to_list(request, clist, doc)
|
||||
|
||||
def remove_track_document(request, document_name):
|
||||
"""supports the "Untrack this document" functionality
|
||||
|
||||
This is exposed in the document view and in document search results."""
|
||||
clist = CommunityList.objects.get_or_create(user=request.user)[0]
|
||||
if not clist.check_manager(request.user):
|
||||
path = urlquote(request.get_full_path())
|
||||
tup = settings.LOGIN_URL, REDIRECT_FIELD_NAME, path
|
||||
return HttpResponseRedirect('%s?%s=%s' % tup)
|
||||
doc = get_object_or_404(DocAlias, name=document_name).document
|
||||
clist.added_ids.remove(doc)
|
||||
clist.update()
|
||||
return HttpResponse(json.dumps({'success': True}), content_type='text/plain')
|
||||
|
||||
def remove_document(request, list_id, document_name):
|
||||
clist = get_object_or_404(CommunityList, pk=list_id)
|
||||
|
@ -97,7 +113,6 @@ def remove_document(request, list_id, document_name):
|
|||
clist.update()
|
||||
return HttpResponseRedirect(clist.get_manage_url())
|
||||
|
||||
|
||||
def add_document_to_list(request, clist, doc):
|
||||
if not clist.check_manager(request.user):
|
||||
path = urlquote(request.get_full_path())
|
||||
|
|
|
@ -326,12 +326,13 @@ def document_main(request, name, rev=None):
|
|||
elif can_edit_stream_info and (not iesg_state or iesg_state.slug == 'watching'):
|
||||
actions.append(("Submit to IESG for Publication", urlreverse('doc_to_iesg', kwargs=dict(name=doc.name))))
|
||||
|
||||
show_add_to_list = False
|
||||
tracking_document = False
|
||||
if request.user.is_authenticated():
|
||||
try:
|
||||
clist = CommunityList.objects.get(user=request.user)
|
||||
clist.update()
|
||||
show_add_to_list = clist.get_documents().filter(name=doc.name).count() == 0
|
||||
if clist.get_documents().filter(name=doc.name).count() > 0:
|
||||
tracking_document = True
|
||||
except ObjectDoesNotExist:
|
||||
pass
|
||||
|
||||
|
@ -387,7 +388,7 @@ def document_main(request, name, rev=None):
|
|||
shepherd_writeup=shepherd_writeup,
|
||||
search_archive=search_archive,
|
||||
actions=actions,
|
||||
show_add_to_list=show_add_to_list,
|
||||
tracking_document=tracking_document,
|
||||
),
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
import datetime
|
||||
|
||||
from django import forms
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.shortcuts import render_to_response
|
||||
from django.db.models import Q
|
||||
from django.template import RequestContext
|
||||
|
@ -40,6 +41,7 @@ from django.http import Http404, HttpResponseBadRequest
|
|||
|
||||
import debug # pyflakes:ignore
|
||||
|
||||
from ietf.community.models import CommunityList
|
||||
from ietf.doc.models import ( Document, DocAlias, State, RelatedDocument, DocEvent,
|
||||
LastCallDocEvent, TelechatDocEvent, IESG_SUBSTATE_TAGS )
|
||||
from ietf.doc.expire import expirable_draft
|
||||
|
@ -399,8 +401,28 @@ def search(request):
|
|||
results = []
|
||||
meta = { 'by': None, 'advanced': False, 'searching': False }
|
||||
|
||||
# Determine whether each document is being tracked or not, and remember
|
||||
# that so we can display the proper track/untrack option.
|
||||
# We use a slightly cumbersome pair of dictionaries:
|
||||
# - have_doc_status is set if we know anything about the document at all
|
||||
# - doc_is_tracked is set if we are tracking the document
|
||||
# If have_doc_status is False, then we use an empty cell, otherwise
|
||||
# we either use the track or untrack option in the cell, as appropriate.
|
||||
have_doc_status = { }
|
||||
doc_is_tracked = { }
|
||||
if request.user.is_authenticated():
|
||||
try:
|
||||
clist = CommunityList.objects.get(user=request.user)
|
||||
clist.update()
|
||||
except ObjectDoesNotExist:
|
||||
pass
|
||||
for doc in results:
|
||||
if clist.get_documents().filter(name=doc.name).count() > 0:
|
||||
doc_is_tracked[doc.name] = True
|
||||
have_doc_status[doc.name] = True
|
||||
|
||||
return render_to_response('doc/search/search.html',
|
||||
{'form':form, 'docs':results, 'meta':meta, 'show_add_to_list': True },
|
||||
{'form':form, 'docs':results, 'have_doc_status':have_doc_status, 'doc_is_tracked':doc_is_tracked, 'meta':meta, },
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
def frontpage(request):
|
||||
|
|
|
@ -240,8 +240,12 @@
|
|||
{% if user|has_role:"Area Director" %}
|
||||
| <a href="https://www.iesg.org/bin/c5i?mid=6&rid=77&target={{ doc.name }}" rel="nofollow" target="_blank">Search Mailing Lists (ARO)</a>
|
||||
{% endif %}
|
||||
{% if show_add_to_list and user.is_authenticated %}
|
||||
| <span class="search-results"><span class="addtolist"><a href="{% url "community_add_document" doc.name %}" title="Add to your personal ID list"><img src="/images/add_to_list.png" alt="Add to your personal ID list"/>Track this document</a></span></span>
|
||||
{% if user.is_authenticated %}
|
||||
{% if tracking_document %}
|
||||
| <span class="search-results"><span class="removefromlist"><a href="{% url "community_remove_track_document" doc.name %}" title="Remove from your personal ID list"><img src="/images/remove_from_list.png" alt="Remove from your personal ID list"/>Untrack this document</a></span></span>
|
||||
{% else %}
|
||||
| <span class="search-results"><span class="addtolist"><a href="{% url "community_add_track_document" doc.name %}" title="Add to your personal ID list"><img src="/images/add_to_list.png" alt="Add to your personal ID list"/>Track this document</a></span></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -34,10 +34,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
{% load ietf_filters %}
|
||||
<tr class="{{ forloop.counter|divisibleby:2|yesno:"oddrow,evenrow" }}">
|
||||
{% if show_add_to_list and user.is_authenticated %}
|
||||
<td class="addtolist">
|
||||
<a href="{% url "community_add_document" doc.name %}" title="Add to your personal ID list"><img src="/images/add_to_list.png" alt="Add to your personal ID list" /></a>
|
||||
{% if user.is_authenticated %}
|
||||
{% if not doc.name in have_doc_status %}
|
||||
<td></td>
|
||||
{% elif doc.name in doc_is_tracked %}
|
||||
<td class="removefromlist">
|
||||
<a href="{% url "community_remove_track_document" doc.name %}" title="Remove from your personal ID list"><img src="/images/remove_from_list.png" alt="Remove from your personal ID list" /></a>
|
||||
</td>
|
||||
{% else %}
|
||||
<td class="addtolist">
|
||||
<a href="{% url "community_add_track_document" doc.name %}" title="Add to your personal ID list"><img src="/images/add_to_list.png" alt="Add to your personal ID list" /></a>
|
||||
</td>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<td class="doc">
|
||||
<a href="{{ doc.get_absolute_url }}">{% if doc.get_state_slug == "rfc" %}RFC {{ doc.rfc_number }}{% else %}{{ doc.name }}-{{ doc.rev }}{% endif %}</a>
|
||||
|
|
BIN
static/images/remove_from_list.png
Normal file
BIN
static/images/remove_from_list.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 287 B |
|
@ -80,6 +80,22 @@ $(function () {
|
|||
});
|
||||
});
|
||||
|
||||
$('.search-results .removefromlist a').click(function(e) {
|
||||
e.preventDefault();
|
||||
var trigger = $(this);
|
||||
$.ajax({
|
||||
url: trigger.attr('href'),
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
success: function(response){
|
||||
if (response.success) {
|
||||
trigger.replaceWith('removed');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("a.ballot-icon").click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
|
|
Loading…
Reference in a new issue