Untrack this document button added to draft document view.

- Legacy-Id: 8130
This commit is contained in:
Shane Kerr 2014-07-19 19:44:30 +00:00
parent 51906f6f26
commit 4d71417817
5 changed files with 30 additions and 9 deletions

View file

@ -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'),

View file

@ -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())

View file

@ -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))

View file

@ -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>

View file

@ -36,7 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<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>
<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 %}
<td class="doc">