Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
416 changes: 304 additions & 112 deletions ietf/community/tests.py

Large diffs are not rendered by default.

259 changes: 169 additions & 90 deletions ietf/community/views.py

Large diffs are not rendered by default.

43 changes: 41 additions & 2 deletions ietf/meeting/tests_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,58 @@
from django.http import HttpResponse, JsonResponse
from ietf.meeting.factories import MeetingFactory, RegistrationFactory, RegistrationTicketFactory
from ietf.meeting.models import Registration
from ietf.meeting.utils import (process_single_registration,
get_registration_data, sync_registration_data, fetch_attendance_from_meetings)
from ietf.meeting.utils import (
process_single_registration,
get_registration_data,
sync_registration_data,
fetch_attendance_from_meetings,
get_activity_stats
)
from ietf.nomcom.models import Volunteer
from ietf.nomcom.factories import NomComFactory, nomcom_kwargs_for_year
from ietf.person.factories import PersonFactory
from ietf.utils.test_utils import TestCase
from ietf.meeting.test_data import make_meeting_test_data
from ietf.doc.factories import NewRevisionDocEventFactory, DocEventFactory


class JsonResponseWithJson(JsonResponse):
def json(self):
return json.loads(self.content)


class ActivityStatsTests(TestCase):

def test_activity_stats(self):
utc = datetime.timezone.utc
make_meeting_test_data()
sdate = datetime.date(2016,4,3)
edate = datetime.date(2016,7,14)
MeetingFactory(type_id='ietf', date=sdate, number="96")
MeetingFactory(type_id='ietf', date=edate, number="97")

NewRevisionDocEventFactory(time=datetime.datetime(2016,4,5,12,0,0,0,tzinfo=utc))
NewRevisionDocEventFactory(time=datetime.datetime(2016,4,6,12,0,0,0,tzinfo=utc))
NewRevisionDocEventFactory(time=datetime.datetime(2016,4,7,12,0,0,0,tzinfo=utc))

NewRevisionDocEventFactory(time=datetime.datetime(2016,6,30,12,0,0,0,tzinfo=utc))
NewRevisionDocEventFactory(time=datetime.datetime(2016,6,30,13,0,0,0,tzinfo=utc))

DocEventFactory(doc__std_level_id="ps", doc__type_id="rfc", type="published_rfc", time=datetime.datetime(2016,4,5,12,0,0,0,tzinfo=utc))
DocEventFactory(doc__std_level_id="bcp", doc__type_id="rfc", type="published_rfc", time=datetime.datetime(2016,4,6,12,0,0,0,tzinfo=utc))
DocEventFactory(doc__std_level_id="inf", doc__type_id="rfc", type="published_rfc", time=datetime.datetime(2016,4,7,12,0,0,0,tzinfo=utc))
DocEventFactory(doc__std_level_id="exp", doc__type_id="rfc", type="published_rfc", time=datetime.datetime(2016,4,8,12,0,0,0,tzinfo=utc))

data = get_activity_stats(sdate, edate)
self.assertEqual(data['new_drafts_count'], len(data['new_docs']))
self.assertEqual(data['ffw_new_count'], 2)
self.assertEqual(data['ffw_new_percent'], '40%')
rfc_count = 0
for c in data['counts']:
rfc_count += data['counts'].get(c)
self.assertEqual(rfc_count, len(data['rfcs']))


class GetRegistrationsTests(TestCase):

@patch('ietf.meeting.utils.requests.get')
Expand Down
15 changes: 8 additions & 7 deletions ietf/meeting/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,13 +949,14 @@ def get_activity_stats(sdate, edate):
data['ffw_update_count'] = ffw_update_count
data['ffw_update_percent'] = ffw_update_percent

rfcs = events.filter(type='published_rfc')
data['rfcs'] = rfcs.select_related('doc').select_related('doc__group').select_related('doc__intended_std_level')

data['counts'] = {'std': rfcs.filter(doc__intended_std_level__in=('ps', 'ds', 'std')).count(),
'bcp': rfcs.filter(doc__intended_std_level='bcp').count(),
'exp': rfcs.filter(doc__intended_std_level='exp').count(),
'inf': rfcs.filter(doc__intended_std_level='inf').count()}
rfcs_events = DocEvent.objects.filter(doc__type='rfc', time__gte=sdatetime, time__lt=edatetime)
rfcs = rfcs_events.filter(type='published_rfc')
data['rfcs'] = rfcs.select_related('doc').select_related('doc__group').select_related('doc__std_level')

data['counts'] = {'std': rfcs.filter(doc__std_level__in=('ps', 'ds', 'std')).count(),
'bcp': rfcs.filter(doc__std_level='bcp').count(),
'exp': rfcs.filter(doc__std_level='exp').count(),
'inf': rfcs.filter(doc__std_level='inf').count()}

data['new_groups'] = Group.objects.filter(
type='wg',
Expand Down
1 change: 0 additions & 1 deletion ietf/templates/base/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<span class="fw-bolder">Groups</span>
</li>
{% endif %}
<li><a class="dropdown-item" href="{% url "ietf.group.views.group_about" acronym="iesg" %}">IESG</a></li>
{% if flavor == 'top' %}<li class="dropdown-header">By area/parent</li>{% endif %}
{% wg_menu flavor %}
<li class="dropend">
Expand Down
3 changes: 3 additions & 0 deletions ietf/templates/base/menu_wg.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
{% load origin %}
{% origin %}
{% for p in parents %}
{% if p.acronym == "iab" %}
<li><a class="dropdown-item" href="{% url "ietf.group.views.group_about" acronym="iesg" %}">IESG</a></li>
{% endif%}
<li class="dropend group-menu group-parent-{{ p.id }}">
<a class="dropdown-item dropdown-toggle {% if flavor != 'top' %}text-wrap{% endif %}"
href="{{ p.menu_url }}">
Expand Down
8 changes: 4 additions & 4 deletions ietf/templates/community/atom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<title type="text">{{ title }}</title>
<subtitle type="text">{{ subtitle }}</subtitle>
<id>{{ id }}</id>
<updated>{{ updated|date:"Y-m-d\TH:i:sO" }}</updated>
<updated>{{ updated.isoformat }}</updated>
<link rel="alternate" type="text/html" hreflang="en" href="https://{{ request.get_host }}/"/>
<link rel="self" type="application/atom+xml" href="https://{{ request.get_host }}{{ request.get_full_path }}"/>

Expand All @@ -17,11 +17,11 @@

<link href="{{ entry.doc.get_absolute_url }}"/>

<id>{{ entry.id }}</id>
<id>urn:datatracker-ietf-org:event:{{ entry.id }}</id>

<updated>{{ entry.time|date:"Y-m-d\TH:i:sO" }}</updated>
<updated>{{ entry.time.isoformat }}</updated>

<published>{{ entry.time|date:"Y-m-d\TH:i:sO" }}</published>
<published>{{ entry.time.isoformat }}</published>

<author>
<name>{{ entry.by }}</name>
Expand Down
4 changes: 2 additions & 2 deletions ietf/templates/meeting/activity_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ <h3 class="mt-3">{{ rfcs.count }} RFCs published this period</h3>
<th scope="col" data-sort="title">Title</th>
</tr>
</thead>
{% if rfcs %}
{% if rfcs|length > 0 %}
<tbody>
{% for rfc in rfcs %}
<tr>
<td class="text-nowrap">
<a href="{{ rfc.doc.get_absolute_url }}">{{ rfc.doc.name|prettystdname }}</a>
</td>
<td class="text-nowrap">{{ rfc.doc.intended_std_level.name }}</td>
<td class="text-nowrap">{{ rfc.doc.std_level.name }}</td>
<td>
<a href="{{ rfc.doc.group.about_url }}">{{ rfc.doc.group.acronym }}</a>
</td>
Expand Down
17 changes: 10 additions & 7 deletions ietf/utils/mime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import magic
import re


def get_mime_type(content):
# try to fixup encoding
if hasattr(magic, "open"):
Expand All @@ -13,15 +14,17 @@ def get_mime_type(content):
filetype = m.buffer(content)
else:
m = magic.Magic()
m.cookie = magic.magic_open(magic.MAGIC_NONE | magic.MAGIC_MIME | magic.MAGIC_MIME_ENCODING)
m.cookie = magic.magic_open(
magic.MAGIC_NONE | magic.MAGIC_MIME | magic.MAGIC_MIME_ENCODING
)
magic.magic_load(m.cookie, None)
filetype = m.from_buffer(content)
# Work around silliness in libmagic on OpenSUSE 15.1
filetype = filetype.replace('text/x-Algol68;', 'text/plain;')
if ';' in filetype and 'charset=' in filetype:
mimetype, charset = re.split('; *charset=', filetype)
filetype = filetype.replace("text/x-Algol68;", "text/plain;")
filetype = filetype.replace("application/vnd.hp-HPGL;", "text/plain;")
if ";" in filetype and "charset=" in filetype:
mimetype, charset = re.split("; *charset=", filetype)
else:
mimetype = re.split(';', filetype)[0]
charset = 'utf-8'
mimetype = re.split(";", filetype)[0]
charset = "utf-8"
return mimetype, charset

Loading