Provide a page that shows how current charter text renders through markdown. Related to #2695. Commit ready for merge.

- Legacy-Id: 19357
This commit is contained in:
Robert Sparks 2021-09-08 16:47:47 +00:00
parent b531a5c3cc
commit d7841409ca
4 changed files with 80 additions and 0 deletions

View file

@ -271,6 +271,13 @@ class GroupPagesTests(TestCase):
self.assertContains(r, milestone.desc)
self.assertContains(r, milestone.docs.all()[0].name)
def test_about_rendertest(self):
group = CharterFactory().group
url = urlreverse('ietf.group.views.group_about_rendertest', kwargs=dict(acronym=group.acronym))
r = self.client.get(url)
self.assertEqual(r.status_code,200)
def test_group_about(self):
interesting_users = [ 'plain','iana','iab-chair','irtf-chair', 'marschairman', 'teamchairman','ad', 'iab-member', 'secretary', ]

View file

@ -20,6 +20,7 @@ info_detail_urls = [
url(r'^documents/subscription/$', community_views.subscription),
url(r'^charter/$', views.group_about),
url(r'^about/$', views.group_about),
url(r'^about/rendertest/$', views.group_about_rendertest),
url(r'^about/status/$', views.group_about_status),
url(r'^about/status/edit/$', views.group_about_status_edit),
url(r'^about/status/meeting/(?P<num>\d+)/$', views.group_about_status_meeting),

View file

@ -39,6 +39,7 @@ import datetime
import itertools
import io
import json
import markdown
import math
import os
import re
@ -575,6 +576,17 @@ def all_status(request):
}
)
def group_about_rendertest(request, acronym, group_type=None):
group = get_group_or_404(acronym, group_type)
charter = None
if group.charter:
charter = get_charter_text(group)
try:
rendered = markdown.markdown(charter, extensions=['extra'])
except Exception as e:
rendered = f'Markdown rendering failed: {e}'
return render(request, 'group/group_about_rendertest.html', {'group':group, 'charter':charter, 'rendered':rendered})
def group_about_status(request, acronym, group_type=None):
group = get_group_or_404(acronym, group_type)
status_update = group.latest_event(type='status_update')

View file

@ -0,0 +1,60 @@
{% extends "group/group_base.html" %}
{# Copyright The IETF Trust 2021, All Rights Reserved #}
{% load origin %}
{% load ietf_filters %}
{% block morecss %}
.leftpanel { border-right: 1px solid #ccc;}
.header {text-align:center; background-color:#aaf; }
.buttonrow {text-align:center; border-bottom: 1px solid #000;}
{% endblock %}
{% block group_content %}
{% if charter %}
{% comment %}
<div class="row">
<div class="col-md-6 header leftpanel">Current about page rendering</div>
<div class="col-md-6 header">Markdown rendering</div>
</div>
<div class="row buttonrow">
<div class="col-md-6 leftpanel">&nbsp;</div>
<div class="col-md-6 "><input type="checkbox" name="widthconstraint"> Constrain width</input></div>
</div>
<div class="row">
<div class="col-md-6 leftpanel">{{charter|linebreaks}}</div>
<div class="col-md-6 rightcontent">{{rendered|sanitize|safe}}</div>
</div>
{% endcomment %}
<div class="row">
<div class="col-md-6 leftpanel">
<div class="header">Current about page rendering</div>
<div class="buttonrow">&nbsp;</div>
<div>{{charter|linebreaks}}</div>
</div>
<div class="col-md-6 rightpanel">
<div class="header">Markdown rendering</div>
<div class="buttonrow"><input type="checkbox" name="widthconstraint"> Constrain width</input></div>
<div class="rightcontent">{{rendered|sanitize|safe}}</div>
</div>
</div>
{% else %}
<div>Group has no charter document</div>
{% endif %}
{% endblock %}
{% block js %}
<script>
$(document).ready(function() {
$('input[name=widthconstraint]').change(function() {
if ($(this).is(':checked')) {
$('.rightcontent').css('max-width','700px')
} else {
$('.rightcontent').css('max-width','')
}
});
$('input[name=widthconstraint').prop('checked', true);
$('.rightcontent').css('max-width','700px')
});
</script>
{% endblock %}