Skip to content

Commit 1e75ee3

Browse files
committed
Do not create CommunityLists when rendering the side bar, only render
the links - Legacy-Id: 10668
1 parent e807115 commit 1e75ee3

4 files changed

Lines changed: 37 additions & 19 deletions

File tree

ietf/community/models.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ def check_manager(self, user):
3939
return bool(Role.objects.filter(name__slug='chair', email__in=person.email_set.all(), group=self.group).count())
4040
return False
4141

42-
def short_name(self):
43-
if self.user:
44-
return 'mine'
45-
else:
46-
return '%s' % self.group.acronym
47-
4842
def long_name(self):
4943
if self.user:
5044
return 'Personal ID list of %s' % self.user.username
@@ -124,13 +118,11 @@ class Rule(models.Model):
124118
cached_ids = models.ManyToManyField(Document)
125119
rule_type = models.CharField(max_length=30, choices=TYPES_OF_RULES)
126120
value = models.CharField(max_length=255)
121+
last_updated = models.DateTimeField(auto_now=True)
127122

128123
class Meta:
129124
unique_together= ("community_list", "rule_type", "value")
130125

131-
last_updated = models.DateTimeField(
132-
auto_now=True)
133-
134126
def get_callable_rule(self):
135127
for i in RuleManager.__subclasses__():
136128
if i.codename == self.rule_type:

ietf/community/templatetags/community_tags.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
register = template.Library()
1010

1111
@register.assignment_tag
12-
def get_user_managed_lists(user):
12+
def community_lists_for_user(user):
1313
if not (user and hasattr(user, "is_authenticated") and user.is_authenticated()):
14-
return ''
15-
lists = {'personal': CommunityList.objects.get_or_create(user=user)[0]}
14+
return {}
15+
1616
try:
1717
person = user.person
1818
groups = []
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from django import template
2+
3+
from ietf.group.models import Group
4+
5+
register = template.Library()
6+
7+
@register.filter
8+
def managed_groups(user):
9+
if not (user and hasattr(user, "is_authenticated") and user.is_authenticated()):
10+
return []
11+
12+
groups = []
13+
groups.extend(Group.objects.filter(
14+
role__name__slug='ad',
15+
role__person__user=user,
16+
type__slug='area',
17+
state__slug='active').select_related("type"))
18+
19+
groups.extend(Group.objects.filter(
20+
role__name__slug='chair',
21+
role__person__user=user,
22+
type__slug__in=('rg', 'wg'),
23+
state__slug__in=('active', 'bof')).select_related("type"))
24+
25+
return groups
26+

ietf/templates/base/menu.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{# Copyright The IETF Trust 2015, All Rights Reserved #}{% load origin %}{% origin %}
2-
{% load ietf_filters community_tags wg_menu streams_menu active_groups_menu %}
2+
{% load ietf_filters managed_groups wg_menu streams_menu active_groups_menu %}
33

44
{% if flavor != "top" %}
55
{% include "base/menu_user.html" %}
@@ -51,14 +51,14 @@
5151
<li><a href="{% url "submit_approvals" %}">Approve a draft</a></li>
5252
{% endif %}
5353

54-
{% get_user_managed_lists user as community_lists %}
55-
{% if community_lists %}
56-
<li><a href="{{ community_lists.personal.get_manage_url }}">My tracked docs</a></li>
57-
{% for cl in community_lists.group %}
58-
<li><a href="{{ cl.get_manage_url }}">{{ cl.short_name }} {{cl.group.type.slug}} docs</a></li>
54+
{% if user and user.is_authenticated %}
55+
<li><a href="{% url "manage_personal_list" %}">My tracked docs</a></li>
56+
57+
{% for g in user|managed_groups %}
58+
<li><a href="{% url "manage_group_list" g.acronym %}">{{ g.acronym }} {{ g.type.slug }} docs</a></li>
5959
{% endfor %}
6060
{% else %}
61-
<li><a rel="nofollow" href="/accounts/login/?next={{request.get_full_path|urlencode}}">Sign in to track docs</a></li>
61+
<li><a rel="nofollow" href="/accounts/login/?next={{ request.get_full_path|urlencode }}">Sign in to track docs</a></li>
6262
{% endif %}
6363

6464
{% if user|has_role:"Area Director,Secretariat" %}

0 commit comments

Comments
 (0)