Rudimentary stab at an email-expansion tag for docs
- Legacy-Id: 10056
This commit is contained in:
parent
275023f231
commit
9abd670587
|
@ -55,6 +55,7 @@ urlpatterns = patterns('',
|
|||
url(r'^(?P<name>[A-Za-z0-9._+-]+)/(?:(?P<rev>[0-9-]+)/)?$', views_doc.document_main, name="doc_view"),
|
||||
url(r'^(?P<name>[A-Za-z0-9._+-]+)/history/$', views_doc.document_history, name="doc_history"),
|
||||
url(r'^(?P<name>[A-Za-z0-9._+-]+)/writeup/$', views_doc.document_writeup, name="doc_writeup"),
|
||||
url(r'^(?P<name>[A-Za-z0-9._+-]+)/email/$', views_doc.document_email, name="doc_email"),
|
||||
url(r'^(?P<name>[A-Za-z0-9._+-]+)/shepherdwriteup/$', views_doc.document_shepherd_writeup, name="doc_shepherd_writeup"),
|
||||
url(r'^(?P<name>[A-Za-z0-9._+-]+)/references/$', views_doc.document_references, name="doc_references"),
|
||||
url(r'^(?P<name>[A-Za-z0-9._+-]+)/referencedby/$', views_doc.document_referenced_by, name="doc_referenced_by"),
|
||||
|
|
|
@ -59,6 +59,7 @@ from ietf.person.models import Email
|
|||
from ietf.utils.history import find_history_active_at
|
||||
from ietf.doc.forms import TelechatForm, NotifyForm
|
||||
from ietf.doc.mails import email_ad
|
||||
from ietf.mailtoken.utils import gather_relevant_expansions
|
||||
|
||||
def render_document_top(request, doc, tab, name):
|
||||
tabs = []
|
||||
|
@ -73,6 +74,7 @@ def render_document_top(request, doc, tab, name):
|
|||
if doc.type_id == "draft" or (doc.type_id == "charter" and doc.group.type_id == "wg"):
|
||||
tabs.append(("IESG Writeups", "writeup", urlreverse("doc_writeup", kwargs=dict(name=name)), True))
|
||||
|
||||
tabs.append(("Email expansions","email",urlreverse("doc_email", kwargs=dict(name=name)), True))
|
||||
tabs.append(("History", "history", urlreverse("doc_history", kwargs=dict(name=name)), True))
|
||||
|
||||
if name.startswith("rfc"):
|
||||
|
@ -572,6 +574,18 @@ def document_main(request, name, rev=None):
|
|||
|
||||
|
||||
|
||||
def document_email(request,name):
|
||||
doc = get_object_or_404(Document, docalias__name=name)
|
||||
top = render_document_top(request, doc, "email", name)
|
||||
|
||||
expansions = gather_relevant_expansions(doc=doc)
|
||||
|
||||
return render(request, "doc/document_email.html",
|
||||
dict(doc=doc,
|
||||
top=top,
|
||||
expansions=expansions,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def document_history(request, name):
|
||||
|
|
|
@ -103,7 +103,7 @@ def make_recipients(apps):
|
|||
|
||||
rc(slug='group_mail_list',
|
||||
desc="The group's mailing list",
|
||||
template='<{{ group.list_email }}>')
|
||||
template='{% if group.list_email %}<{{ group.list_email }}>{% endif %}')
|
||||
|
||||
rc(slug='group_steering_group',
|
||||
desc="The group's steering group (IESG or IRSG)",
|
||||
|
@ -111,7 +111,7 @@ def make_recipients(apps):
|
|||
|
||||
rc(slug='group_chairs',
|
||||
desc="The group's chairs",
|
||||
template="<{{group.acronym}}-chairs@ietf.org>")
|
||||
template="{% if group and group.acronym %}<{{group.acronym}}-chairs@ietf.org>{% endif %}")
|
||||
|
||||
rc(slug='group_responsible_directors',
|
||||
desc="The group's responsible AD(s) or IRTF chair",
|
||||
|
@ -429,7 +429,8 @@ def make_mailtokens(apps):
|
|||
|
||||
mt_factory(slug='doc_stream_changed',
|
||||
desc="Recipients for notification when a document's stream changes",
|
||||
to_slugs=['stream_managers',
|
||||
to_slugs=['doc_authors',
|
||||
'stream_managers',
|
||||
'doc_notify',
|
||||
])
|
||||
|
||||
|
|
|
@ -28,6 +28,50 @@ def gather_address_lists(slug, **kwargs):
|
|||
|
||||
return AddrLists(to=list(to),cc=list(cc))
|
||||
|
||||
def gather_relevant_expansions(**kwargs):
|
||||
relevant = set()
|
||||
|
||||
if 'doc' in kwargs:
|
||||
|
||||
doc = kwargs['doc']
|
||||
|
||||
relevant.update(MailToken.objects.filter(slug__startswith='doc_').values_list('slug',flat=True))
|
||||
|
||||
if doc.stream_id == 'ietf':
|
||||
relevant.update(['ballot_approved_ietf_stream'])
|
||||
else:
|
||||
relevant.update(['pubreq_rfced'])
|
||||
|
||||
if doc.type_id in ['draft','statchg']:
|
||||
relevant.update(MailToken.objects.filter(slug__startswith='last_call_').values_list('slug',flat=True))
|
||||
if doc.type_id == 'draft':
|
||||
relevant.update(['ipr_posted_on_doc',])
|
||||
if doc.type_id == 'conflrev':
|
||||
relevant.update(['conflrev_requested','ballot_approved_conflrev'])
|
||||
if doc.type_id == 'charter':
|
||||
relevant.update(['charter_external_review','ballot_approved_charter'])
|
||||
|
||||
rule_list = []
|
||||
for mailtoken in MailToken.objects.filter(slug__in=relevant):
|
||||
addrs = gather_address_lists(mailtoken.slug,**kwargs)
|
||||
rule_list.append((mailtoken.slug,mailtoken.desc,addrs.to,addrs.cc))
|
||||
return sorted(rule_list)
|
||||
|
||||
#def gather_relevant_expansions_recipient(**kwargs):
|
||||
# relevant_tokens = []
|
||||
#
|
||||
# if 'doc' in kwargs:
|
||||
# relevant_tokens.extend(Recipient.objects.filter(slug__startswith='doc').values_list('slug',flat=True))
|
||||
#
|
||||
# rule_dict = {}
|
||||
#
|
||||
# for recipient in Recipient.objects.filter(slug__in=relevant_tokens):
|
||||
# #for recipient in Recipient.objects.all():
|
||||
# addrs = recipient.gather(**kwargs)
|
||||
# if addrs:
|
||||
# rule_dict[recipient.slug] = recipient.gather(**kwargs)
|
||||
# return sorted(rule_dict.iteritems())
|
||||
|
||||
def get_base_ipr_request_address():
|
||||
return Recipient.objects.get(slug='ipr_requests').gather()[0]
|
||||
|
||||
|
|
|
@ -4473,7 +4473,7 @@
|
|||
},
|
||||
{
|
||||
"fields": {
|
||||
"template": "<{{group.acronym}}-chairs@ietf.org>",
|
||||
"template": "{% if group and group.acronym %}<{{group.acronym}}-chairs@ietf.org>{% endif %}",
|
||||
"desc": "The group's chairs"
|
||||
},
|
||||
"model": "mailtoken.recipient",
|
||||
|
@ -4489,7 +4489,7 @@
|
|||
},
|
||||
{
|
||||
"fields": {
|
||||
"template": "<{{ group.list_email }}>",
|
||||
"template": "{% if group.list_email %}<{{ group.list_email }}>{% endif %}",
|
||||
"desc": "The group's mailing list"
|
||||
},
|
||||
"model": "mailtoken.recipient",
|
||||
|
@ -5081,6 +5081,7 @@
|
|||
"fields": {
|
||||
"cc": [],
|
||||
"to": [
|
||||
"doc_authors",
|
||||
"doc_notify",
|
||||
"stream_managers"
|
||||
],
|
||||
|
|
57
ietf/templates/doc/document_email.html
Normal file
57
ietf/templates/doc/document_email.html
Normal file
|
@ -0,0 +1,57 @@
|
|||
{% extends "base.html" %}
|
||||
{# Copyright The IETF Trust 2015, All Rights Reserved #}
|
||||
{% load origin %}
|
||||
{% load ietf_filters %}
|
||||
{% load future %}
|
||||
|
||||
{% block title %}Email expansions for {{ doc.name }}-{{ doc.rev }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% origin %}
|
||||
{{ top|safe }}
|
||||
|
||||
<h2>Recipient Expansions</h2>
|
||||
|
||||
<table class="table table-condensed table-striped ietf">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>MailToken</th>
|
||||
<th>To</th>
|
||||
<th>Cc</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for token,desc,to,cc in expansions %}
|
||||
<tr>
|
||||
<td><a href="{% url 'ietf.mailtoken.views.show_tokens' token %}"
|
||||
title="{{desc}}">{{token}}</a></td>
|
||||
<td> {{to|join:', '}}</td>
|
||||
<td> {{cc|join:', '}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% comment %}
|
||||
<table class="table table-condensed table-striped ietf">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Rev.</th>
|
||||
<th>By</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% for e in events %}
|
||||
<tr class="anchor-target" id="history-{{ e.pk }}">
|
||||
<td class="text-nowrap">{{ e.time|date:"Y-m-d" }}</td>
|
||||
<td class="text-center">{{ e.rev }}</td>
|
||||
<td>{{ e.by|escape }}</td>
|
||||
<td>{{ e.desc|format_history_text|safe }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endcomment %}
|
||||
{% endblock content %}
|
|
@ -23,8 +23,11 @@
|
|||
<tr>
|
||||
<td><span title="{{recipient.desc}}">{{recipient.slug}}</span></td>
|
||||
<td>
|
||||
{% for mailtoken in recipient.mailtoken_set.all %}
|
||||
<a href="{% url 'ietf.mailtoken.views.show_tokens' mailtoken.slug %}" title="{{mailtoken.desc}}">{{mailtoken.slug}}{% if not forloop.last %}, {%endif%}
|
||||
{% for mailtoken in recipient.used_in_to.all %}
|
||||
<a href="{% url 'ietf.mailtoken.views.show_tokens' mailtoken.slug %}" title="{{mailtoken.desc}}">{{mailtoken.slug}}</a>{% if not forloop.last %}, {%endif%}
|
||||
{% endfor %}{% if recipient.used_in_to.exists and recipient.used_in_cc.exists %},{% endif %}
|
||||
{% for mailtoken in recipient.used_in_cc.all %}
|
||||
<a href="{% url 'ietf.mailtoken.views.show_tokens' mailtoken.slug %}" title="{{mailtoken.desc}}">{{mailtoken.slug}}</a>{% if not forloop.last %}, {%endif%}
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td>{{recipient.template}}</td>
|
||||
|
|
Loading…
Reference in a new issue