Skip to content

Commit 4d71417

Browse files
committed
Untrack this document button added to draft document view.
- Legacy-Id: 8130
1 parent 51906f6 commit 4d71417

5 files changed

Lines changed: 30 additions & 9 deletions

File tree

ietf/community/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
url(r'^group/(?P<acronym>[\w.@+-]+)/unsubscribe/$', 'unsubscribe_group_list', {'significant': False}, name='unsubscribe_group_list'),
2424
url(r'^group/(?P<acronym>[\w.@+-]+)/unsubscribe/significant/$', 'unsubscribe_group_list', {'significant': True}, name='unsubscribe_significant_group_list'),
2525

26-
url(r'^add_document/(?P<document_name>[^/]+)/$', 'add_document', name='community_add_document'),
26+
url(r'^add_track_document/(?P<document_name>[^/]+)/$', 'add_track_document', name='community_add_track_document'),
27+
url(r'^remove_track_document/(?P<document_name>[^/]+)/$', 'remove_track_document', name='community_remove_track_document'),
2728
url(r'^(?P<list_id>[\d]+)/remove_document/(?P<document_name>[^/]+)/$', 'remove_document', name='community_remove_document'),
2829
url(r'^(?P<list_id>[\d]+)/remove_rule/(?P<rule_id>[^/]+)/$', 'remove_rule', name='community_remove_rule'),
2930
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'),

ietf/community/views.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ def manage_group_list(request, acronym):
7575
return _manage_list(request, clist)
7676

7777

78-
def add_document(request, document_name):
78+
def add_track_document(request, document_name):
79+
"""supports the "Track this document" functionality
80+
81+
This is exposed in the document view and in document search results."""
7982
if not request.user.is_authenticated():
8083
path = urlquote(request.get_full_path())
8184
tup = settings.LOGIN_URL, REDIRECT_FIELD_NAME, path
@@ -85,6 +88,19 @@ def add_document(request, document_name):
8588
clist.update()
8689
return add_document_to_list(request, clist, doc)
8790

91+
def remove_track_document(request, document_name):
92+
"""supports the "Untrack this document" functionality
93+
94+
This is exposed in the document view and in document search results."""
95+
clist = CommunityList.objects.get_or_create(user=request.user)[0]
96+
if not clist.check_manager(request.user):
97+
path = urlquote(request.get_full_path())
98+
tup = settings.LOGIN_URL, REDIRECT_FIELD_NAME, path
99+
return HttpResponseRedirect('%s?%s=%s' % tup)
100+
doc = get_object_or_404(DocAlias, name=document_name).document
101+
clist.added_ids.remove(doc)
102+
clist.update()
103+
return HttpResponse(json.dumps({'success': True}), content_type='text/plain')
88104

89105
def remove_document(request, list_id, document_name):
90106
clist = get_object_or_404(CommunityList, pk=list_id)
@@ -97,7 +113,6 @@ def remove_document(request, list_id, document_name):
97113
clist.update()
98114
return HttpResponseRedirect(clist.get_manage_url())
99115

100-
101116
def add_document_to_list(request, clist, doc):
102117
if not clist.check_manager(request.user):
103118
path = urlquote(request.get_full_path())

ietf/doc/views_doc.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,13 @@ def document_main(request, name, rev=None):
326326
elif can_edit_stream_info and (not iesg_state or iesg_state.slug == 'watching'):
327327
actions.append(("Submit to IESG for Publication", urlreverse('doc_to_iesg', kwargs=dict(name=doc.name))))
328328

329-
show_add_to_list = False
329+
tracking_document = False
330330
if request.user.is_authenticated():
331331
try:
332332
clist = CommunityList.objects.get(user=request.user)
333333
clist.update()
334-
show_add_to_list = clist.get_documents().filter(name=doc.name).count() == 0
334+
if clist.get_documents().filter(name=doc.name).count() > 0:
335+
tracking_document = True
335336
except ObjectDoesNotExist:
336337
pass
337338

@@ -387,7 +388,7 @@ def document_main(request, name, rev=None):
387388
shepherd_writeup=shepherd_writeup,
388389
search_archive=search_archive,
389390
actions=actions,
390-
show_add_to_list=show_add_to_list,
391+
tracking_document=tracking_document,
391392
),
392393
context_instance=RequestContext(request))
393394

ietf/templates/doc/document_draft.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,12 @@
240240
{% if user|has_role:"Area Director" %}
241241
| <a href="https://www.iesg.org/bin/c5i?mid=6&rid=77&target={{ doc.name }}" rel="nofollow" target="_blank">Search Mailing Lists (ARO)</a>
242242
{% endif %}
243-
{% if show_add_to_list and user.is_authenticated %}
244-
| <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>
243+
{% if user.is_authenticated %}
244+
{% if tracking_document %}
245+
| <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>
246+
{% else %}
247+
| <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>
248+
{% endif %}
245249
{% endif %}
246250
</div>
247251

ietf/templates/doc/search/search_result_row.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<tr class="{{ forloop.counter|divisibleby:2|yesno:"oddrow,evenrow" }}">
3737
{% if show_add_to_list and user.is_authenticated %}
3838
<td class="addtolist">
39-
<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>
39+
<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>
4040
</td>
4141
{% endif %}
4242
<td class="doc">

0 commit comments

Comments
 (0)