|
31 | 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
32 | 32 |
|
33 | 33 | from django import template |
34 | | -from django.core.cache import cache |
35 | 34 | from django.template.loader import render_to_string |
| 35 | +from django.db import models |
36 | 36 |
|
37 | 37 | from ietf.group.models import Group |
38 | 38 |
|
|
44 | 44 | } |
45 | 45 |
|
46 | 46 | @register.simple_tag |
47 | | -def wg_menu(flavor=""): |
48 | | - res = cache.get('wgmenu' + flavor) |
49 | | - if res: |
50 | | - return res |
| 47 | +def wg_menu(): |
| 48 | + parents = Group.objects.filter(models.Q(type="area") | models.Q(type="irtf", acronym="irtf"), |
| 49 | + state="active").order_by('type_id', 'acronym') |
51 | 50 |
|
52 | | - areas = Group.objects.filter(type="area", state="active").order_by('acronym') |
53 | | - wgs = Group.objects.filter(type="wg", state="active", parent__in=areas).order_by("acronym") |
54 | | - rgs = Group.objects.filter(type="rg", state="active").order_by("acronym") |
| 51 | + for p in parents: |
| 52 | + p.short_name = area_short_names.get(p.acronym) or p.name |
| 53 | + if p.short_name.endswith(" Area"): |
| 54 | + p.short_name = p.short_name[:-len(" Area")] |
55 | 55 |
|
56 | | - for a in areas: |
57 | | - a.short_area_name = area_short_names.get(a.acronym) or a.name |
58 | | - if a.short_area_name.endswith(" Area"): |
59 | | - a.short_area_name = a.short_area_name[:-len(" Area")] |
| 56 | + if p.type_id == "area": |
| 57 | + p.menu_url = "/wg/#" + p.acronym |
| 58 | + elif p.acronym == "irtf": |
| 59 | + p.menu_url = "/rg/" |
60 | 60 |
|
61 | | - a.active_groups = [g for g in wgs if g.parent_id == a.id] |
62 | | - |
63 | | - areas = [a for a in areas if a.active_groups] |
64 | | - |
65 | | - if flavor == "modal": |
66 | | - res = render_to_string('base/menu_wg_modal.html', {'areas':areas, 'rgs':rgs}) |
67 | | - else: |
68 | | - res = render_to_string('base/menu_wg.html', {'areas':areas, 'rgs':rgs}) |
69 | | - cache.set('wgmenu' + flavor, res, 30*60) |
70 | | - return res |
| 61 | + return render_to_string('base/menu_wg.html', { 'parents': parents }) |
0 commit comments