Drop naming community URL patterns, just reverse them directly from

the view
 - Legacy-Id: 11175
This commit is contained in:
Ole Laursen 2016-05-06 18:10:37 +00:00
parent 9faae5e915
commit b6d4c5ffe8
11 changed files with 40 additions and 37 deletions

View file

@ -24,8 +24,9 @@ class CommunityList(models.Model):
return self.long_name()
def get_absolute_url(self):
import ietf.community.views
if self.user:
return urlreverse("community_personal_view_list", kwargs={ 'username': self.user.username })
return urlreverse(ietf.community.views.view_list, kwargs={ 'username': self.user.username })
elif self.group:
return urlreverse("group_docs", kwargs={ 'acronym': self.group.acronym })
return ""

View file

@ -8,6 +8,7 @@ from django.contrib.auth.models import User
from ietf.community.models import CommunityList, SearchRule, EmailSubscription
from ietf.community.utils import docs_matching_community_list_rule, community_list_rules_matching_doc
from ietf.community.utils import reset_name_contains_index_for_rule
import ietf.community.views
from ietf.group.utils import setup_default_community_list_for_group
from ietf.doc.models import State
from ietf.doc.utils import add_state_change_event
@ -63,7 +64,7 @@ class CommunityListTests(TestCase):
def test_view_list(self):
draft = make_test_data()
url = urlreverse("community_personal_view_list", kwargs={ "username": "plain" })
url = urlreverse(ietf.community.views.view_list, kwargs={ "username": "plain" })
# without list
r = self.client.get(url)
@ -85,7 +86,7 @@ class CommunityListTests(TestCase):
def test_manage_personal_list(self):
draft = make_test_data()
url = urlreverse("community_personal_manage_list", kwargs={ "username": "plain" })
url = urlreverse(ietf.community.views.manage_list, kwargs={ "username": "plain" })
login_testing_unauthorized(self, "plain", url)
r = self.client.get(url)
@ -149,7 +150,7 @@ class CommunityListTests(TestCase):
def test_manage_group_list(self):
draft = make_test_data()
url = urlreverse("community_group_manage_list", kwargs={ "acronym": draft.group.acronym })
url = urlreverse(ietf.community.views.manage_list, kwargs={ "acronym": draft.group.acronym })
setup_default_community_list_for_group(draft.group)
login_testing_unauthorized(self, "marschairman", url)
@ -160,7 +161,7 @@ class CommunityListTests(TestCase):
def test_track_untrack_document(self):
draft = make_test_data()
url = urlreverse("community_personal_track_document", kwargs={ "username": "plain", "name": draft.name })
url = urlreverse(ietf.community.views.track_document, kwargs={ "username": "plain", "name": draft.name })
login_testing_unauthorized(self, "plain", url)
# track
@ -173,7 +174,7 @@ class CommunityListTests(TestCase):
self.assertEqual(list(clist.added_docs.all()), [draft])
# untrack
url = urlreverse("community_personal_untrack_document", kwargs={ "username": "plain", "name": draft.name })
url = urlreverse(ietf.community.views.untrack_document, kwargs={ "username": "plain", "name": draft.name })
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
@ -185,7 +186,7 @@ class CommunityListTests(TestCase):
def test_track_untrack_document_through_ajax(self):
draft = make_test_data()
url = urlreverse("community_personal_track_document", kwargs={ "username": "plain", "name": draft.name })
url = urlreverse(ietf.community.views.track_document, kwargs={ "username": "plain", "name": draft.name })
login_testing_unauthorized(self, "plain", url)
# track
@ -196,7 +197,7 @@ class CommunityListTests(TestCase):
self.assertEqual(list(clist.added_docs.all()), [draft])
# untrack
url = urlreverse("community_personal_untrack_document", kwargs={ "username": "plain", "name": draft.name })
url = urlreverse(ietf.community.views.untrack_document, kwargs={ "username": "plain", "name": draft.name })
r = self.client.post(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEqual(r.status_code, 200)
self.assertEqual(json.loads(r.content)["success"], True)
@ -206,7 +207,7 @@ class CommunityListTests(TestCase):
def test_csv(self):
draft = make_test_data()
url = urlreverse("community_personal_csv", kwargs={ "username": "plain" })
url = urlreverse(ietf.community.views.export_to_csv, kwargs={ "username": "plain" })
# without list
r = self.client.get(url)
@ -229,7 +230,7 @@ class CommunityListTests(TestCase):
def test_csv_for_group(self):
draft = make_test_data()
url = urlreverse("community_group_csv", kwargs={ "acronym": draft.group.acronym })
url = urlreverse(ietf.community.views.export_to_csv, kwargs={ "acronym": draft.group.acronym })
setup_default_community_list_for_group(draft.group)
@ -240,7 +241,7 @@ class CommunityListTests(TestCase):
def test_feed(self):
draft = make_test_data()
url = urlreverse("community_personal_feed", kwargs={ "username": "plain" })
url = urlreverse(ietf.community.views.feed, kwargs={ "username": "plain" })
# without list
r = self.client.get(url)
@ -267,7 +268,7 @@ class CommunityListTests(TestCase):
def test_feed_for_group(self):
draft = make_test_data()
url = urlreverse("community_group_feed", kwargs={ "acronym": draft.group.acronym })
url = urlreverse(ietf.community.views.feed, kwargs={ "acronym": draft.group.acronym })
setup_default_community_list_for_group(draft.group)
@ -278,7 +279,7 @@ class CommunityListTests(TestCase):
def test_subscription(self):
draft = make_test_data()
url = urlreverse("community_personal_subscription", kwargs={ "username": "plain" })
url = urlreverse(ietf.community.views.subscription, kwargs={ "username": "plain" })
login_testing_unauthorized(self, "plain", url)
@ -315,7 +316,7 @@ class CommunityListTests(TestCase):
def test_subscription_for_group(self):
draft = make_test_data()
url = urlreverse("community_group_subscription", kwargs={ "acronym": draft.group.acronym })
url = urlreverse(ietf.community.views.subscription, kwargs={ "acronym": draft.group.acronym })
setup_default_community_list_for_group(draft.group)

View file

@ -2,12 +2,12 @@ from django.conf.urls import patterns, url
urlpatterns = patterns('',
url(r'^personal/(?P<username>[^/]+)/$', 'ietf.community.views.view_list', name='community_personal_view_list'),
url(r'^personal/(?P<username>[^/]+)/manage/$', 'ietf.community.views.manage_list', name='community_personal_manage_list'),
url(r'^personal/(?P<username>[^/]+)/trackdocument/(?P<name>[^/]+)/$', 'ietf.community.views.track_document', name='community_personal_track_document'),
url(r'^personal/(?P<username>[^/]+)/untrackdocument/(?P<name>[^/]+)/$', 'ietf.community.views.untrack_document', name='community_personal_untrack_document'),
url(r'^personal/(?P<username>[^/]+)/csv/$', 'ietf.community.views.export_to_csv', name='community_personal_csv'),
url(r'^personal/(?P<username>[^/]+)/feed/$', 'ietf.community.views.feed', name='community_personal_feed'),
url(r'^personal/(?P<username>[^/]+)/subscription/$', 'ietf.community.views.subscription', name='community_personal_subscription'),
url(r'^personal/(?P<username>[^/]+)/$', 'ietf.community.views.view_list'),
url(r'^personal/(?P<username>[^/]+)/manage/$', 'ietf.community.views.manage_list'),
url(r'^personal/(?P<username>[^/]+)/trackdocument/(?P<name>[^/]+)/$', 'ietf.community.views.track_document'),
url(r'^personal/(?P<username>[^/]+)/untrackdocument/(?P<name>[^/]+)/$', 'ietf.community.views.untrack_document'),
url(r'^personal/(?P<username>[^/]+)/csv/$', 'ietf.community.views.export_to_csv'),
url(r'^personal/(?P<username>[^/]+)/feed/$', 'ietf.community.views.feed'),
url(r'^personal/(?P<username>[^/]+)/subscription/$', 'ietf.community.views.subscription'),
)

View file

@ -378,7 +378,8 @@ def construct_group_menu_context(request, group, selected, group_type, others):
if group.features.has_documents:
clist = CommunityList.objects.filter(group=group).first()
if clist and can_manage_community_list(request.user, clist):
actions.append((u'Manage document list', urlreverse('community_group_manage_list', kwargs=kwargs)))
import ietf.community.views
actions.append((u'Manage document list', urlreverse(ietf.community.views.manage_list, kwargs=kwargs)))
if group.features.has_materials and can_manage_materials(request.user, group):
actions.append((u"Upload material", urlreverse("ietf.doc.views_material.choose_material_type", kwargs=kwargs)))

View file

@ -5,10 +5,10 @@ urlpatterns = patterns('',
(r'^$', 'ietf.group.info.group_home', None, "group_home"),
(r'^documents/txt/$', 'ietf.group.info.group_documents_txt'),
(r'^documents/$', 'ietf.group.info.group_documents', None, "group_docs"),
(r'^documents/manage/$', 'ietf.community.views.manage_list', None, "community_group_manage_list"),
(r'^documents/csv/$', 'ietf.community.views.export_to_csv', None, 'community_group_csv'),
(r'^documents/feed/$', 'ietf.community.views.feed', None, 'community_group_feed'),
(r'^documents/subscription/$', 'ietf.community.views.subscription', None, 'community_group_subscription'),
(r'^documents/manage/$', 'ietf.community.views.manage_list'),
(r'^documents/csv/$', 'ietf.community.views.export_to_csv'),
(r'^documents/feed/$', 'ietf.community.views.feed'),
(r'^documents/subscription/$', 'ietf.community.views.subscription'),
(r'^charter/$', 'ietf.group.info.group_about', None, 'group_charter'),
(r'^about/$', 'ietf.group.info.group_about', None, 'group_about'),
(r'^about/status/$', 'ietf.group.info.group_about_status'),

View file

@ -52,7 +52,7 @@
{% endif %}
{% if user and user.is_authenticated %}
<li><a href="{% url "community_personal_view_list" user.username %}">My tracked docs</a></li>
<li><a href="{% url "ietf.community.views.view_list" user.username %}">My tracked docs</a></li>
{% for g in user|managed_groups %}
<li><a href="{% url "group_docs" g.acronym %}">{{ g.acronym }} {{ g.type.slug }} docs</a></li>

View file

@ -2,13 +2,13 @@
<li>
<label id="list-feeds">Atom feed:</label>
<div class="btn-group" role="group" aria-labelledby="list-feeds">
<a class="btn btn-default" title="Feed of all changes" href="{% if clist.group %}{% url "community_group_feed" clist.group.acronym %}{% else %}{% url "community_personal_feed" clist.user.username %}{% endif %}">All changes</a>
<a class="btn btn-default" title="Feed of only significant state changes" href="{% if clist.group %}{% url "community_group_feed" clist.group.acronym %}{% else %}{% url "community_personal_feed" clist.user.username %}{% endif %}?significant=1">Significant</a>
<a class="btn btn-default" title="Feed of all changes" href="{% if clist.group %}{% url "ietf.community.views.feed" acronym=clist.group.acronym %}{% else %}{% url "ietf.community.views.feed" username=clist.user.username %}{% endif %}">All changes</a>
<a class="btn btn-default" title="Feed of only significant state changes" href="{% if clist.group %}{% url "ietf.community.views.feed" acronym=clist.group.acronym %}{% else %}{% url "ietf.community.views.feed" username=clist.user.username %}{% endif %}?significant=1">Significant</a>
</div>
</li>
{% if clist.pk != None %}
<li><a class="btn btn-default" href="{% if clist.group %}{% url "community_group_subscription" clist.group.acronym %}{% else %}{% url "community_personal_subscription" clist.user.username %}{% endif %}">
<li><a class="btn btn-default" href="{% if clist.group %}{% url "ietf.community.views.subscription" acronym=clist.group.acronym %}{% else %}{% url "ietf.community.views.subscription" username=clist.user.username %}{% endif %}">
<i class="glyphicon glyphicon-envelope"></i>
{% if subscribed %}
Change subscription
@ -18,5 +18,5 @@
</a></li>
{% endif %}
<li><a class="btn btn-default" href="{% if clist.group %}{% url "community_group_csv" clist.group.acronym %}{% else %}{% url "community_personal_csv" clist.user.username %}{% endif %}"><i class="glyphicon glyphicon-list"></i> Export as CSV</a></li>
<li><a class="btn btn-default" href="{% if clist.group %}{% url "ietf.community.views.export_to_csv" acronym=clist.group.acronym %}{% else %}{% url "ietf.community.views.export_to_csv" username=clist.user.username %}{% endif %}"><i class="glyphicon glyphicon-list"></i> Export as CSV</a></li>
</ul>

View file

@ -50,7 +50,7 @@
<td>{{ doc.display_name }}</td>
<td>{{ doc.get_state }}</td>
<td><a href="{{ doc.get_absolute_url }}">{{ doc.title }}</a></td>
<td><a class="btn btn-danger btn-xs" href="{% if cl.user %}{% url "community_personal_untrack_document" doc.pk %}{% else %}{% url "community_group_untrack_document" %}{% endif %}">Remove</a></td>
<td><a class="btn btn-danger btn-xs" href="{% if cl.user %}{% url "ietf.community.views.untrack_document" username=cl.user.username name=doc.pk %}{% else %}{% url "community_group_untrack_document" acronym=cl.group.acronym name=doc.pk %}{% endif %}">Remove</a></td>
</tr>
{% endfor %}
</tbody>

View file

@ -12,7 +12,7 @@
{% bootstrap_messages %}
{% if can_manage_list %}
<a class="btn btn-primary" href="{% url "community_personal_manage_list" clist.user.username %}">
<a class="btn btn-primary" href="{% url "ietf.community.views.manage_list" username=clist.user.username %}">
<i class="glyphicon glyphicon-cog"></i>
Manage list
</a>

View file

@ -501,8 +501,8 @@
</ul>
</div>
{% if user.is_authenticated %}
<a class="btn btn-default btn-xs track-untrack-doc {% if not doc.tracked_in_personal_community_list %}hide{% endif %}" href="{% url "community_personal_untrack_document" user.username doc.name %}" title="Remove from your personal ID list"><span class="fa fa-bookmark"></span> Untrack</a>
<a class="btn btn-default btn-xs track-untrack-doc {% if doc.tracked_in_personal_community_list %}hide{% endif %}" href="{% url "community_personal_track_document" user.username doc.name %}" title="Add to your personal ID list"><span class="fa fa-bookmark-o"></span> Track</a>
<a class="btn btn-default btn-xs track-untrack-doc {% if not doc.tracked_in_personal_community_list %}hide{% endif %}" href="{% url "ietf.community.views.untrack_document" username=user.username name=doc.name %}" title="Remove from your personal ID list"><span class="fa fa-bookmark"></span> Untrack</a>
<a class="btn btn-default btn-xs track-untrack-doc {% if doc.tracked_in_personal_community_list %}hide{% endif %}" href="{% url "ietf.community.views.track_document" username=user.username name=doc.name %}" title="Add to your personal ID list"><span class="fa fa-bookmark-o"></span> Track</a>
{% endif %}
{% if can_edit and iesg_state %}

View file

@ -13,10 +13,10 @@
<td>
{% if user.is_authenticated %}
<a href="{% url "community_personal_untrack_document" request.user.username doc.name %}" class="track-untrack-doc {% if not doc.tracked_in_personal_community_list %}hide{% endif %}" title="Remove from your personal ID list">
<a href="{% url "ietf.community.views.untrack_document" username=request.user.username name=doc.name %}" class="track-untrack-doc {% if not doc.tracked_in_personal_community_list %}hide{% endif %}" title="Remove from your personal ID list">
<span class="fa fa-bookmark"></span>
</a>
<a href="{% url "community_personal_track_document" request.user.username doc.name %}" class="track-untrack-doc {% if doc.tracked_in_personal_community_list %}hide{% endif %}" title="Add to your personal ID list">
<a href="{% url "ietf.community.views.track_document" username=request.user.username name=doc.name %}" class="track-untrack-doc {% if doc.tracked_in_personal_community_list %}hide{% endif %}" title="Add to your personal ID list">
<span class="fa fa-bookmark-o"></span>
</a>
{% endif %}