chore: merge main into feat/tzaware branch
This commit is contained in:
commit
cabb82efec
|
@ -10,12 +10,12 @@ import sys
|
|||
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils import timezone
|
||||
|
||||
import debug # pyflakes:ignore
|
||||
|
||||
from ietf.doc.models import NewRevisionDocEvent
|
||||
from ietf.doc.utils import bibxml_for_draft
|
||||
|
||||
DEFAULT_DAYS = 7
|
||||
|
||||
|
@ -77,21 +77,8 @@ class Command(BaseCommand):
|
|||
self.mutter('%s %s' % (e.time, e.doc.name))
|
||||
try:
|
||||
doc = e.doc
|
||||
if e.rev != doc.rev:
|
||||
for h in doc.history_set.order_by("-time"):
|
||||
if e.rev == h.rev:
|
||||
doc = h
|
||||
break
|
||||
doc.date = e.time.date()
|
||||
ref_text = '%s' % render_to_string('doc/bibxml.xml', {'name':doc.name, 'doc': doc, 'doc_bibtype':'I-D'})
|
||||
# if e.rev == e.doc.rev:
|
||||
# for name in (doc.name, doc.name[6:]):
|
||||
# ref_file_name = os.path.join(bibxmldir, 'reference.I-D.%s.xml' % (name, ))
|
||||
# self.write(ref_file_name, ref_text)
|
||||
# for name in (doc.name, doc.name[6:]):
|
||||
# ref_rev_file_name = os.path.join(bibxmldir, 'reference.I-D.%s-%s.xml' % (name, doc.rev))
|
||||
# self.write(ref_rev_file_name, ref_text)
|
||||
ref_rev_file_name = os.path.join(bibxmldir, 'reference.I-D.%s-%s.xml' % (doc.name, doc.rev))
|
||||
self.write(ref_rev_file_name, ref_text)
|
||||
bibxml = bibxml_for_draft(doc, e.rev)
|
||||
ref_rev_file_name = os.path.join(bibxmldir, 'reference.I-D.%s-%s.xml' % (doc.name, e.rev))
|
||||
self.write(ref_rev_file_name, bibxml)
|
||||
except Exception as ee:
|
||||
sys.stderr.write('\n%s-%s: %s\n' % (doc.name, doc.rev, ee))
|
||||
|
|
|
@ -17,6 +17,7 @@ from urllib.parse import quote
|
|||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.forms import ValidationError
|
||||
from django.http import Http404
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils import timezone
|
||||
from django.utils.html import escape
|
||||
|
@ -1331,3 +1332,33 @@ def fuzzy_find_documents(name, rev=None):
|
|||
|
||||
FoundDocuments = namedtuple('FoundDocuments', 'documents matched_name matched_rev')
|
||||
return FoundDocuments(docs, name, rev)
|
||||
|
||||
def bibxml_for_draft(doc, rev=None):
|
||||
|
||||
if rev is not None and rev != doc.rev:
|
||||
# find the entry in the history
|
||||
for h in doc.history_set.order_by("-time"):
|
||||
if rev == h.rev:
|
||||
doc = h
|
||||
break
|
||||
if rev and rev != doc.rev:
|
||||
raise Http404("Revision not found")
|
||||
|
||||
# Build the date we want to claim for the document in the bibxml
|
||||
# For documents that have relevent NewRevisionDocEvents, use the date of the event.
|
||||
# Very old documents don't have NewRevisionDocEvents - just use the document time.
|
||||
|
||||
latest_revision_event = doc.latest_event(NewRevisionDocEvent, type="new_revision")
|
||||
latest_revision_rev = latest_revision_event.rev if latest_revision_event else None
|
||||
best_events = NewRevisionDocEvent.objects.filter(doc__name=doc.name, rev=(rev or latest_revision_rev))
|
||||
if best_events.exists():
|
||||
# There was a period where it was possible to get more than one NewRevisionDocEvent for a revision.
|
||||
# A future data cleanup would allow this to be simplified
|
||||
best_event = best_events.order_by('time').first()
|
||||
log.assertion('doc.rev == best_event.rev')
|
||||
doc.date = best_event.time.date()
|
||||
else:
|
||||
doc.date = doc.time.date() # Even if this may be incoreect, what would be better?
|
||||
|
||||
return render_to_string('doc/bibxml.xml', {'name':doc.name, 'doc': doc, 'doc_bibtype':'I-D'})
|
||||
|
||||
|
|
|
@ -63,7 +63,8 @@ from ietf.doc.utils import (add_links_in_new_revision_events, augment_events_wit
|
|||
get_initial_notify, make_notify_changed_event, make_rev_history, default_consensus,
|
||||
add_events_message_info, get_unicode_document_content, build_doc_meta_block,
|
||||
augment_docs_and_user_with_user_info, irsg_needed_ballot_positions, add_action_holder_change_event,
|
||||
build_doc_supermeta_block, build_file_urls, update_documentauthors, fuzzy_find_documents)
|
||||
build_doc_supermeta_block, build_file_urls, update_documentauthors, fuzzy_find_documents,
|
||||
bibxml_for_draft)
|
||||
from ietf.doc.utils_bofreq import bofreq_editors, bofreq_responsible
|
||||
from ietf.group.models import Role, Group
|
||||
from ietf.group.utils import can_manage_all_groups_of_type, can_manage_materials, group_features_role_filter
|
||||
|
@ -1020,41 +1021,9 @@ def document_bibxml(request, name, rev=None):
|
|||
rev = None
|
||||
|
||||
doc = get_object_or_404(Document, name=name, type_id='draft')
|
||||
|
||||
latest_revision = doc.latest_event(NewRevisionDocEvent, type="new_revision")
|
||||
latest_rev = latest_revision.rev if latest_revision else None
|
||||
|
||||
if rev != None:
|
||||
# find the entry in the history
|
||||
for h in doc.history_set.order_by("-time"):
|
||||
if rev == h.rev:
|
||||
doc = h
|
||||
break
|
||||
if rev and rev != doc.rev:
|
||||
raise Http404("Revision not found")
|
||||
|
||||
### PATCH to deal with unexpected multiple NewRevisionDocEvent objects for the same revision on a document
|
||||
doc_event_qs = NewRevisionDocEvent.objects.filter(doc__name=doc.name, rev=(rev or latest_rev))
|
||||
if doc_event_qs.count():
|
||||
doc_event = doc_event_qs.order_by('time').last()
|
||||
doc.date = doc_event.time.date()
|
||||
else:
|
||||
doc.date = doc.time.date() # Even if this may be incoreect, what would be better?
|
||||
|
||||
# try:
|
||||
# doc_event = NewRevisionDocEvent.objects.get(doc__name=doc.name, rev=(rev or latest_rev))
|
||||
# doc.date = doc_event.time.date()
|
||||
# except DocEvent.DoesNotExist:
|
||||
# doc.date = doc.time.date() # Even if this may be incoreect, what would be better?
|
||||
return HttpResponse(bibxml_for_draft(doc, rev), content_type="application/xml; charset=utf-8")
|
||||
|
||||
return render(request, "doc/bibxml.xml",
|
||||
dict(
|
||||
name=name,
|
||||
doc=doc,
|
||||
doc_bibtype='I-D',
|
||||
),
|
||||
content_type="application/xml; charset=utf-8",
|
||||
)
|
||||
|
||||
|
||||
def document_writeup(request, name):
|
||||
|
|
|
@ -28,13 +28,15 @@ function add_inline_form(name) {
|
|||
// check to see if this is a stacked or tabular inline
|
||||
if (first.hasClass("tabular")) {
|
||||
var field_table = first.parent().find('table > tbody')
|
||||
var count = field_table.children().length
|
||||
var copy = $('tr:last', field_table).clone(true)
|
||||
const children = field_table.children('tr.dynamic-inline')
|
||||
var count = children.length
|
||||
const last = $(children[count-1])
|
||||
var copy = last.clone(true)
|
||||
copy.removeClass("row1 row2")
|
||||
copy.find("input[name$='address']").removeAttr("readonly")
|
||||
copy.addClass("row"+((count % 2) == 0 ? 1 : 2))
|
||||
field_table.append(copy)
|
||||
increment_form_ids($('tr:last', field_table), count, name)
|
||||
copy.find("input[name$='address']").attr("readonly", false)
|
||||
copy.addClass("row"+((count % 2) ? 2 : 1))
|
||||
copy.insertAfter(last)
|
||||
increment_form_ids($(copy), count, name)
|
||||
}
|
||||
else {
|
||||
var last = $(first).parent().children('.last-related')
|
||||
|
@ -54,13 +56,14 @@ function add_inline_form(name) {
|
|||
$(function() {
|
||||
var html_template = '<ul class="tools">'+
|
||||
'<li>'+
|
||||
'<a class="addlink" href="#" onclick="return add_inline_form(\'{{prefix}}\')">'+
|
||||
'<a id="addlink-{{prefix}}" class="addlink" href="#">'+
|
||||
'Add another</a>'+
|
||||
'</li>'+
|
||||
'</ul>'
|
||||
$('.inline-group').each(function(i) {
|
||||
//prefix is in the name of the input fields before the "-"
|
||||
var prefix = $("input[type='hidden'][name!='csrfmiddlewaretoken']", this).attr("name").split("-")[0]
|
||||
$(this).append(html_template.replace("{{prefix}}", prefix))
|
||||
var prefix = $("input[type='hidden'][name!='csrfmiddlewaretoken']", this).attr("name").split("-")[0];
|
||||
$(this).append(html_template.replace("{{prefix}}", prefix));
|
||||
$('#addlink-' + prefix).on('click', () => add_inline_form(prefix));
|
||||
})
|
||||
})
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
{% if form.non_field_errors %}
|
||||
<tr><td colspan="3">{{ form.non_field_errors }}</td></tr>
|
||||
{% endif %}
|
||||
<tr class="{% cycle 'row1' 'row2' %}">
|
||||
<tr class="dynamic-inline {% cycle 'row1' 'row2' %}">
|
||||
<td>
|
||||
{% for hidden in form.hidden_fields %}
|
||||
{{ hidden }}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<tbody>
|
||||
{% for form in email_formset.forms %}
|
||||
{% if form.non_field_errors %}{{ form.non_field_errors }}{% endif %}
|
||||
<tr class="{% cycle 'row1' 'row2' %}">
|
||||
<tr class="dynamic-inline {% cycle 'row1' 'row2' %}">
|
||||
<td>
|
||||
{# Include the hidden fields in the form #}
|
||||
{% for hidden in form.hidden_fields %}
|
||||
|
|
|
@ -20,7 +20,6 @@ from django.core.validators import validate_email
|
|||
from django.db import transaction
|
||||
from django.http import HttpRequest # pyflakes:ignore
|
||||
from django.utils.module_loading import import_string
|
||||
from django.template.loader import render_to_string
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
from django.utils import timezone
|
||||
|
||||
|
@ -30,9 +29,10 @@ from ietf.doc.models import ( Document, State, DocAlias, DocEvent, SubmissionDoc
|
|||
DocumentAuthor, AddedMessageEvent )
|
||||
from ietf.doc.models import NewRevisionDocEvent
|
||||
from ietf.doc.models import RelatedDocument, DocRelationshipName, DocExtResource
|
||||
from ietf.doc.utils import add_state_change_event, rebuild_reference_relations
|
||||
from ietf.doc.utils import ( set_replaces_for_document, prettify_std_name,
|
||||
update_doc_extresources, can_edit_docextresources, update_documentauthors, update_action_holders )
|
||||
from ietf.doc.utils import (add_state_change_event, rebuild_reference_relations,
|
||||
set_replaces_for_document, prettify_std_name, update_doc_extresources,
|
||||
can_edit_docextresources, update_documentauthors, update_action_holders,
|
||||
bibxml_for_draft )
|
||||
from ietf.doc.mails import send_review_possibly_replaces_request, send_external_resource_change_request
|
||||
from ietf.group.models import Group
|
||||
from ietf.ietfauth.utils import has_role
|
||||
|
@ -486,14 +486,7 @@ def post_submission(request, submission, approved_doc_desc, approved_subm_desc):
|
|||
create_submission_event(request, submission, approved_subm_desc)
|
||||
|
||||
# Create bibxml-ids entry
|
||||
ref_text = '%s' % render_to_string('doc/bibxml.xml', {'name':draft.name, 'doc': draft, 'doc_bibtype':'I-D'})
|
||||
# for name in (draft.name, draft.name[6:]):
|
||||
# ref_file_name = os.path.join(os.path.join(settings.BIBXML_BASE_PATH, 'bibxml-ids'), 'reference.I-D.%s.xml' % (name, ))
|
||||
# with io.open(ref_file_name, "w", encoding='utf-8') as f:
|
||||
# f.write(ref_text)
|
||||
# ref_rev_file_name = os.path.join(os.path.join(settings.BIBXML_BASE_PATH, 'bibxml-ids'), 'reference.I-D.%s-%s.xml' % (name, draft.rev ))
|
||||
# with io.open(ref_rev_file_name, "w", encoding='utf-8') as f:
|
||||
# f.write(ref_text)
|
||||
ref_text = bibxml_for_draft(draft, draft.rev)
|
||||
ref_rev_file_name = os.path.join(os.path.join(settings.BIBXML_BASE_PATH, 'bibxml-ids'), 'reference.I-D.%s-%s.xml' % (draft.name, draft.rev ))
|
||||
with io.open(ref_rev_file_name, "w", encoding='utf-8') as f:
|
||||
f.write(ref_text)
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<reference anchor="{{doc_bibtype}}.{{name|slice:"6:"}}">
|
||||
<front>
|
||||
<title>{{doc.title}}</title>{% if doc.submission %}{% for author in doc.submission.authors %}
|
||||
<author fullname="{{ author.name }}">
|
||||
{% if author.affiliation %}<organization>{{ author.affiliation }}</organization>
|
||||
{% endif %}</author>{% endfor %}{% else %}{% for author in doc.documentauthor_set.all %}
|
||||
<title>{{doc.title}}</title>{% for author in doc.documentauthor_set.all %}
|
||||
<author initials="{{ author.person.initials }}" surname="{{ author.person.last_name }}" fullname="{{ author.person.name }}">
|
||||
{% if author.affiliation %}<organization>{{ author.affiliation }}</organization>
|
||||
{% endif %}</author>{% endfor %}{% endif %}
|
||||
{% endif %}</author>{% endfor %}
|
||||
<date month="{{doc.date|date:"F"}}" day="{{doc.date.day}}" year="{{doc.date.year}}" />
|
||||
<abstract>
|
||||
<t>{{doc.abstract}}
|
||||
|
|
|
@ -39,12 +39,12 @@
|
|||
</td>
|
||||
<td>
|
||||
{% if recipient.template %}
|
||||
<code>{{ recipient.template|escape|linebreaksbr }}</code>
|
||||
<pre><code>{{ recipient.template|escape }}</code></pre>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if recipient.code %}
|
||||
<code>{{ recipient.code|escape|linebreaksbr }}</code>
|
||||
<pre><code>{{ recipient.code|escape }}</code></pre>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -55,4 +55,4 @@
|
|||
{% endblock %}
|
||||
{% block js %}
|
||||
<script src="{% static "ietf/js/list.js" %}"></script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
Loading…
Reference in a new issue