Django 2.2 does not wrap single queries in transactions, for performance reasons. This caused some template tags that did database lookups to trigger exceptions. Fixed by moving the lookups (which would not normally change between apache reloads) out from the template tag code to module scope. Adding new groups of type ['ag','area','team','dir','program'] will now require a reload to show up in the group menu.

- Legacy-Id: 18086
This commit is contained in:
Henrik Levkowetz 2020-06-27 17:28:50 +00:00
parent 10b56c4e33
commit 47a2174e80
2 changed files with 9 additions and 3 deletions

View file

@ -5,9 +5,11 @@ from ietf.name.models import GroupTypeName
register = template.Library()
parents = GroupTypeName.objects.filter(slug__in=['ag','area','team','dir','program'])
@register.simple_tag
def active_groups_menu():
parents = GroupTypeName.objects.filter(slug__in=['ag','area','team','dir','program'])
global parents
for p in parents:
p.menu_url = '/%s/'%p.slug
return render_to_string('base/menu_active_groups.html', { 'parents': parents })

View file

@ -43,10 +43,14 @@ area_short_names = {
'rai':'RAI'
}
parents = Group.objects.filter(
models.Q(type="area") | models.Q(type="irtf", acronym="irtf"),
state="active"
).order_by('type_id', 'acronym')
@register.simple_tag
def wg_menu():
parents = Group.objects.filter(models.Q(type="area") | models.Q(type="irtf", acronym="irtf"),
state="active").order_by('type_id', 'acronym')
global parents
for p in parents:
p.short_name = area_short_names.get(p.acronym) or p.name