Merged in code from Pasi@1360, then changed the app name from docs to idrfc, and changed the app URL.
- Legacy-Id: 1383
This commit is contained in:
parent
6cffbcd189
commit
cf053c61b9
1
ietf/idrfc/__init__.py
Normal file
1
ietf/idrfc/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
#
|
88
ietf/idrfc/mirror_draft_versions.py
Normal file
88
ietf/idrfc/mirror_draft_versions.py
Normal file
|
@ -0,0 +1,88 @@
|
|||
# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# * Neither the name of the Nokia Corporation and/or its
|
||||
# subsidiary(-ies) nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from ietf import settings
|
||||
from django.core import management
|
||||
management.setup_environ(settings)
|
||||
from django import db
|
||||
|
||||
import re
|
||||
import urllib2
|
||||
from datetime import datetime
|
||||
import socket
|
||||
import sys
|
||||
|
||||
URL = "http://merlot.tools.ietf.org/~pasi/draft_versions.txt"
|
||||
TABLE = "draft_versions_mirror"
|
||||
|
||||
log_data = ""
|
||||
def log(line):
|
||||
global log_data
|
||||
if len(sys.argv) > 1:
|
||||
print line
|
||||
else:
|
||||
log_data += line + "\n"
|
||||
|
||||
try:
|
||||
log("output from mirror_draft_versions.py:\n")
|
||||
log("time: "+str(datetime.now()))
|
||||
log("host: "+socket.gethostname())
|
||||
log("url: "+URL)
|
||||
|
||||
log("downloading...")
|
||||
response = urllib2.urlopen(URL)
|
||||
#log("got \n"+str(response.info()))
|
||||
log("parsing...")
|
||||
data = []
|
||||
for line in response.readlines():
|
||||
rec = line[:-1].split("\t")
|
||||
data.append(rec)
|
||||
|
||||
log("got " + str(len(data)) + " entries")
|
||||
if len(data) < 10000:
|
||||
raise Exception('not enough data')
|
||||
|
||||
log("connecting to database...")
|
||||
cursor = db.connection.cursor()
|
||||
log("removing old data...")
|
||||
cursor.execute("DELETE FROM "+TABLE)
|
||||
log("inserting new data...")
|
||||
cursor.executemany("INSERT INTO "+TABLE+" (filename, revision, revision_date) VALUES (%s, %s, %s)", data)
|
||||
cursor.close()
|
||||
db.connection._commit()
|
||||
db.connection.close()
|
||||
|
||||
log("all done!")
|
||||
log_data = ""
|
||||
finally:
|
||||
if len(log_data) > 0:
|
||||
print log_data
|
195
ietf/idrfc/mirror_rfc_editor_queue.py
Normal file
195
ietf/idrfc/mirror_rfc_editor_queue.py
Normal file
|
@ -0,0 +1,195 @@
|
|||
# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# * Neither the name of the Nokia Corporation and/or its
|
||||
# subsidiary(-ies) nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from ietf import settings
|
||||
from django.core import management
|
||||
management.setup_environ(settings)
|
||||
from django import db
|
||||
|
||||
from xml.dom import pulldom, Node
|
||||
import re
|
||||
import urllib2
|
||||
from datetime import datetime
|
||||
import socket
|
||||
import sys
|
||||
|
||||
QUEUE_URL = "http://www.rfc-editor.org/queue2.xml"
|
||||
TABLE = "rfc_editor_queue_mirror"
|
||||
REF_TABLE = "rfc_editor_queue_mirror_refs"
|
||||
|
||||
log_data = ""
|
||||
def log(line):
|
||||
global log_data
|
||||
if len(sys.argv) > 1:
|
||||
print line
|
||||
else:
|
||||
log_data += line + "\n"
|
||||
|
||||
def parse(response):
|
||||
def getChildText(parentNode, tagName):
|
||||
for node in parentNode.childNodes:
|
||||
if node.nodeType == Node.ELEMENT_NODE and node.localName == tagName:
|
||||
return node.firstChild.data
|
||||
return None
|
||||
|
||||
events = pulldom.parse(response)
|
||||
drafts = []
|
||||
refs = []
|
||||
for (event, node) in events:
|
||||
if event == pulldom.START_ELEMENT and node.tagName == "entry":
|
||||
events.expandNode(node)
|
||||
node.normalize()
|
||||
draft_name = getChildText(node, "draft")
|
||||
if re.search("-\d\d\.txt$", draft_name):
|
||||
draft_name = draft_name[0:-7]
|
||||
date_received = getChildText(node, "date-received")
|
||||
|
||||
states = []
|
||||
for child in node.childNodes:
|
||||
if child.nodeType == Node.ELEMENT_NODE and child.localName == "state":
|
||||
states.append(child.firstChild.data)
|
||||
if len(states) == 0:
|
||||
state = "?"
|
||||
else:
|
||||
state = " ".join(states)
|
||||
|
||||
drafts.append([draft_name, date_received, state, stream])
|
||||
|
||||
for child in node.childNodes:
|
||||
if child.nodeType == Node.ELEMENT_NODE and child.localName == "normRef":
|
||||
ref_name = getChildText(child, "ref-name")
|
||||
ref_state = getChildText(child, "ref-state")
|
||||
in_queue = ref_state.startswith("IN-QUEUE")
|
||||
refs.append([draft_name, ref_name, in_queue, True])
|
||||
|
||||
elif event == pulldom.START_ELEMENT and node.tagName == "section":
|
||||
name = node.getAttribute('name')
|
||||
if name.startswith("IETF"):
|
||||
stream = 1
|
||||
elif name.startswith("IAB"):
|
||||
stream = 2
|
||||
elif name.startswith("IRTF"):
|
||||
stream = 3
|
||||
elif name.startswith("INDEPENDENT"):
|
||||
stream = 4
|
||||
else:
|
||||
stream = 0
|
||||
log("WARNING: unrecognized section "+name)
|
||||
return (drafts, refs)
|
||||
|
||||
# Find set of all normative references (whether direct or via some
|
||||
# other normative reference)
|
||||
def find_indirect_refs(drafts, refs):
|
||||
result = []
|
||||
draft_names = set()
|
||||
for draft in drafts:
|
||||
draft_names.add(draft[0])
|
||||
|
||||
def recurse(draft_name, ref_set, level):
|
||||
for (source, destination, in_queue, direct) in refs:
|
||||
if source == draft_name:
|
||||
if destination not in ref_set:
|
||||
ref_set.add(destination)
|
||||
recurse(destination, ref_set, level+1)
|
||||
if level == 0:
|
||||
for ref in ref_set:
|
||||
if draft_name != ref:
|
||||
result.append([draft_name, ref, ref in draft_names, False])
|
||||
|
||||
for draft_name in draft_names:
|
||||
recurse(draft_name, set([draft_name]), 0)
|
||||
return result
|
||||
|
||||
# Convert filenames to id_document_tags
|
||||
def find_document_ids(cursor, drafts, refs):
|
||||
draft_ids = {}
|
||||
drafts2 = []
|
||||
for draft in drafts:
|
||||
cursor.execute("SELECT id_document_tag FROM internet_drafts WHERE filename=%s", [draft[0]])
|
||||
row = cursor.fetchone()
|
||||
if not row:
|
||||
log("WARNING: cannot find id for "+draft[0])
|
||||
else:
|
||||
draft_ids[draft[0]] = row[0]
|
||||
drafts2.append([row[0]]+draft[1:])
|
||||
refs2 = []
|
||||
for ref in refs:
|
||||
if ref[0] in draft_ids:
|
||||
refs2.append([draft_ids[ref[0]]]+ref[1:])
|
||||
return (drafts2, refs2)
|
||||
|
||||
try:
|
||||
log("output from mirror_rfc_editor_queue.py:\n")
|
||||
log("time: "+str(datetime.now()))
|
||||
log("host: "+socket.gethostname())
|
||||
log("url: "+QUEUE_URL)
|
||||
|
||||
log("downloading...")
|
||||
response = urllib2.urlopen(QUEUE_URL)
|
||||
log("parsing...")
|
||||
(drafts, refs) = parse(response)
|
||||
log("got "+ str(len(drafts)) + " drafts and "+str(len(refs))+" direct refs")
|
||||
|
||||
indirect_refs = find_indirect_refs(drafts, refs)
|
||||
log("found " + str(len(indirect_refs)) + " indirect refs")
|
||||
refs.extend(indirect_refs)
|
||||
del(indirect_refs)
|
||||
|
||||
if len(drafts) < 10 or len(refs) < 10:
|
||||
raise Exception('not enough data')
|
||||
|
||||
# convert filenames to id_document_tags
|
||||
log("connecting to database...")
|
||||
cursor = db.connection.cursor()
|
||||
log("finding id_document_tags...")
|
||||
(drafts, refs) = find_document_ids(cursor, drafts, refs)
|
||||
|
||||
if len(drafts) < 10 or len(refs) < 10:
|
||||
raise Exception('not enough data')
|
||||
|
||||
log("removing old data...")
|
||||
cursor.execute("DELETE FROM "+TABLE)
|
||||
cursor.execute("DELETE FROM "+REF_TABLE)
|
||||
log("inserting new data...")
|
||||
cursor.executemany("INSERT INTO "+TABLE+" (id_document_tag, date_received, state, stream) VALUES (%s, %s, %s, %s)", drafts)
|
||||
cursor.execute("DELETE FROM "+REF_TABLE)
|
||||
cursor.executemany("INSERT INTO "+REF_TABLE+" (source, destination, in_queue, direct) VALUES (%s, %s, %s, %s)", refs)
|
||||
cursor.close()
|
||||
db.connection._commit()
|
||||
db.connection.close()
|
||||
|
||||
log("all done!")
|
||||
if log_data.find("WARNING") < 0:
|
||||
log_data = ""
|
||||
finally:
|
||||
if len(log_data) > 0:
|
||||
print log_data
|
160
ietf/idrfc/mirror_rfc_index.py
Normal file
160
ietf/idrfc/mirror_rfc_index.py
Normal file
|
@ -0,0 +1,160 @@
|
|||
# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# * Neither the name of the Nokia Corporation and/or its
|
||||
# subsidiary(-ies) nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from ietf import settings
|
||||
from django.core import management
|
||||
management.setup_environ(settings)
|
||||
from django import db
|
||||
|
||||
from xml.dom import pulldom, Node
|
||||
import re
|
||||
import urllib2
|
||||
from datetime import datetime
|
||||
import socket
|
||||
import sys
|
||||
|
||||
INDEX_URL = "http://www.rfc-editor.org/rfc/rfc-index.xml"
|
||||
TABLE = "rfc_index_mirror"
|
||||
|
||||
log_data = ""
|
||||
def log(line):
|
||||
global log_data
|
||||
if len(sys.argv) > 1:
|
||||
print line
|
||||
else:
|
||||
log_data += line + "\n"
|
||||
|
||||
def parse(response):
|
||||
def getChildText(parentNode, tagName):
|
||||
for node in parentNode.childNodes:
|
||||
if node.nodeType == Node.ELEMENT_NODE and node.localName == tagName:
|
||||
return node.firstChild.data
|
||||
return None
|
||||
|
||||
def getDocList(parentNode, tagName):
|
||||
l = []
|
||||
for u in parentNode.getElementsByTagName(tagName):
|
||||
for d in u.getElementsByTagName("doc-id"):
|
||||
l.append(d.firstChild.data)
|
||||
if len(l) == 0:
|
||||
return None
|
||||
else:
|
||||
return ",".join(l)
|
||||
|
||||
also_list = {}
|
||||
data = []
|
||||
events = pulldom.parse(response)
|
||||
for (event, node) in events:
|
||||
if event == pulldom.START_ELEMENT and node.tagName in ["bcp-entry", "fyi-entry", "std-entry"]:
|
||||
events.expandNode(node)
|
||||
node.normalize()
|
||||
bcpid = getChildText(node, "doc-id")
|
||||
doclist = getDocList(node, "is-also")
|
||||
if doclist:
|
||||
for docid in doclist.split(","):
|
||||
if docid in also_list:
|
||||
also_list[docid].append(bcpid)
|
||||
else:
|
||||
also_list[docid] = [bcpid]
|
||||
|
||||
elif event == pulldom.START_ELEMENT and node.tagName == "rfc-entry":
|
||||
events.expandNode(node)
|
||||
node.normalize()
|
||||
rfc_number = int(getChildText(node, "doc-id")[3:])
|
||||
title = getChildText(node, "title")
|
||||
|
||||
l = []
|
||||
for author in node.getElementsByTagName("author"):
|
||||
l.append(getChildText(author, "name"))
|
||||
authors = "; ".join(l)
|
||||
|
||||
d = node.getElementsByTagName("date")[0]
|
||||
year = int(getChildText(d, "year"))
|
||||
month = getChildText(d, "month")
|
||||
month = ["January","February","March","April","May","June","July","August","September","October","November","December"].index(month)+1
|
||||
rfc_published_date = ("%d-%02d-01" % (year, month))
|
||||
|
||||
current_status = getChildText(node, "current-status").title()
|
||||
|
||||
updates = getDocList(node, "updates")
|
||||
updated_by = getDocList(node, "updated-by")
|
||||
obsoletes = getDocList(node, "obsoletes")
|
||||
obsoleted_by = getDocList(node, "obsoleted-by")
|
||||
|
||||
draft = getChildText(node, "draft")
|
||||
if draft and re.search("-\d\d$", draft):
|
||||
draft = draft[0:-3]
|
||||
|
||||
if len(node.getElementsByTagName("errata-url")) > 0:
|
||||
has_errata = 1
|
||||
else:
|
||||
has_errata = 0
|
||||
|
||||
data.append([rfc_number,title,authors,rfc_published_date,current_status,updates,updated_by,obsoletes,obsoleted_by,None,draft,has_errata])
|
||||
|
||||
for d in data:
|
||||
k = "RFC%04d" % d[0]
|
||||
if k in also_list:
|
||||
d[9] = ",".join(also_list[k])
|
||||
return data
|
||||
|
||||
try:
|
||||
log("output from mirror_rfc_index.py:\n")
|
||||
log("time: "+str(datetime.now()))
|
||||
log("host: "+socket.gethostname())
|
||||
log("url: "+INDEX_URL)
|
||||
|
||||
log("downloading...")
|
||||
response = urllib2.urlopen(INDEX_URL)
|
||||
log("parsing...")
|
||||
data = parse(response)
|
||||
|
||||
log("got " + str(len(data)) + " entries")
|
||||
if len(data) < 5000:
|
||||
raise Exception('not enough data')
|
||||
|
||||
log("connecting to database...")
|
||||
cursor = db.connection.cursor()
|
||||
log("removing old data...")
|
||||
cursor.execute("DELETE FROM "+TABLE)
|
||||
log("inserting new data...")
|
||||
cursor.executemany("INSERT INTO "+TABLE+" (rfc_number, title, authors, rfc_published_date, current_status,updates,updated_by,obsoletes,obsoleted_by,also,draft,has_errata) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", data)
|
||||
cursor.close()
|
||||
db.connection._commit()
|
||||
db.connection.close()
|
||||
|
||||
log("all done!")
|
||||
log_data = ""
|
||||
|
||||
finally:
|
||||
if len(log_data) > 0:
|
||||
print log_data
|
103
ietf/idrfc/models.py
Normal file
103
ietf/idrfc/models.py
Normal file
|
@ -0,0 +1,103 @@
|
|||
# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# * Neither the name of the Nokia Corporation and/or its
|
||||
# subsidiary(-ies) nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from django.db import models
|
||||
from ietf.idtracker.models import InternetDraft
|
||||
|
||||
class RfcEditorQueue(models.Model):
|
||||
STREAM_CHOICES = (
|
||||
(0, 'Unknown'),
|
||||
(1, 'IETF'),
|
||||
(2, 'IAB'),
|
||||
(3, 'IRTF'),
|
||||
(4, 'Independent')
|
||||
)
|
||||
draft = models.OneToOneField(InternetDraft, db_column="id_document_tag", related_name="rfc_editor_queue_state")
|
||||
#draft = models.CharField(maxlength=200,primary_key=True)
|
||||
date_received = models.DateField()
|
||||
state = models.CharField(maxlength=200, blank=True, null=True)
|
||||
# currently, queue2.xml does not have this information, so
|
||||
# this field will be NULL (but we could get it from other sources)
|
||||
state_date = models.DateField(blank=True,null=True)
|
||||
stream = models.IntegerField(choices=STREAM_CHOICES)
|
||||
def __str__(self):
|
||||
return "RfcEditorQueue"+str([self.draft, self.date_received, self.state, self.state_date, self.stream])
|
||||
class Meta:
|
||||
db_table = "rfc_editor_queue_mirror"
|
||||
class Admin:
|
||||
pass
|
||||
|
||||
class RfcEditorQueueRef(models.Model):
|
||||
source = models.ForeignKey(InternetDraft, db_column="source", related_name="rfc_editor_queue_refs")
|
||||
destination = models.CharField(maxlength=200)
|
||||
in_queue = models.BooleanField()
|
||||
direct = models.BooleanField()
|
||||
class Meta:
|
||||
db_table = "rfc_editor_queue_mirror_refs"
|
||||
class Admin:
|
||||
pass
|
||||
|
||||
class RfcIndex(models.Model):
|
||||
rfc_number = models.IntegerField(primary_key=True)
|
||||
title = models.CharField(maxlength=250)
|
||||
authors = models.CharField(maxlength=250)
|
||||
rfc_published_date = models.DateField()
|
||||
current_status = models.CharField(maxlength=50,null=True)
|
||||
updates = models.CharField(maxlength=200,blank=True,null=True)
|
||||
updated_by = models.CharField(maxlength=200,blank=True,null=True)
|
||||
obsoletes = models.CharField(maxlength=200,blank=True,null=True)
|
||||
obsoleted_by = models.CharField(maxlength=200,blank=True,null=True)
|
||||
also = models.CharField(maxlength=50,blank=True,null=True)
|
||||
draft = models.CharField(maxlength=200,null=True)
|
||||
has_errata = models.BooleanField()
|
||||
def __str__(self):
|
||||
return "RfcIndex"+str(self.rfc_number)
|
||||
class Meta:
|
||||
db_table = "rfc_index_mirror"
|
||||
class Admin:
|
||||
pass
|
||||
|
||||
class DraftVersions(models.Model):
|
||||
# Django does not support multi-column primary keys, so
|
||||
# we can't use filename+revision. But the key for this table
|
||||
# does not really matter, so we'll have an 'id' field
|
||||
id = models.AutoField(primary_key=True)
|
||||
filename = models.CharField(maxlength=200, db_index=True)
|
||||
revision = models.CharField(maxlength=2)
|
||||
revision_date = models.DateField()
|
||||
def __str__(self):
|
||||
return "DraftVersions"+filename+revision+str(revision_date)
|
||||
class Meta:
|
||||
db_table = "draft_versions_mirror"
|
||||
class Admin:
|
||||
pass
|
||||
|
38
ietf/idrfc/urls.py
Normal file
38
ietf/idrfc/urls.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# * Neither the name of the Nokia Corporation and/or its
|
||||
# subsidiary(-ies) nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from django.conf.urls.defaults import patterns
|
||||
from ietf.idrfc import views
|
||||
|
||||
urlpatterns = patterns('',
|
||||
(r'^test.html$', views.test)
|
||||
)
|
40
ietf/idrfc/views.py
Normal file
40
ietf/idrfc/views.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# * Neither the name of the Nokia Corporation and/or its
|
||||
# subsidiary(-ies) nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from django.shortcuts import render_to_response
|
||||
from ietf.idrfc.models import RfcIndex, RfcEditorQueue, DraftVersions
|
||||
|
||||
def test(request):
|
||||
q = RfcEditorQueue.objects.order_by('-date_received')[:20]
|
||||
v = DraftVersions.objects.order_by('-revision_date')[:20]
|
||||
r = RfcIndex.objects.order_by('-rfc_number')[:20]
|
||||
return render_to_response('idrfc/test.html', {'queue':q, 'versions':v, 'rfcs':r})
|
|
@ -135,6 +135,7 @@ INSTALLED_APPS = (
|
|||
'ietf.my',
|
||||
'ietf.proceedings',
|
||||
'ietf.redirects',
|
||||
'ietf.idrfc',
|
||||
# not yet merged from the Vancouver branch
|
||||
# 'ietf.wgcharter',
|
||||
)
|
||||
|
@ -161,6 +162,10 @@ TEST_REFERENCE_URL_PREFIX = os.environ.get("IETFDB_REF_PREFIX","") or 'https://d
|
|||
|
||||
IPR_DOCUMENT_PATH = '/a/www/ietf-ftp/ietf/IPR'
|
||||
|
||||
# Override this in settings_local.py if needed
|
||||
INTERNET_DRAFT_PATH = '/a/www/ietf-ftp/internet-drafts/'
|
||||
RFC_PATH = '/a/www/ietf-ftp/rfc/'
|
||||
|
||||
IPR_EMAIL_TO = ['ietf-ipr@ietf.org', ]
|
||||
|
||||
# The number of days for which a password-request URL is valid
|
||||
|
|
69
ietf/templates/idrfc/test.html
Normal file
69
ietf/templates/idrfc/test.html
Normal file
|
@ -0,0 +1,69 @@
|
|||
{% comment %}
|
||||
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of the Nokia Corporation and/or its
|
||||
subsidiary(-ies) nor the names of its contributors may be used
|
||||
to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
{% endcomment %}
|
||||
<html>
|
||||
<head>
|
||||
<title>Test page</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>RFC Editor Queue</h1>
|
||||
<table border="1">
|
||||
{% for q in queue %}
|
||||
<tr><td>{{q.draft}}</td><td>{{q.date_received}}</td><td>{{q.state}}</td>
|
||||
<td>
|
||||
{% for ref in q.draft.rfc_editor_queue_refs.get_query_set %}
|
||||
{{ ref.destination }}
|
||||
{% endfor %}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<h1>Draft Versions</h1>
|
||||
<table border="1">
|
||||
{% for v in versions %}
|
||||
<tr><td>{{v.filename}}</td><td>{{v.revision}}</td><td>{{v.revision_date}}</td></tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<h1>RFC Index</h1>
|
||||
<table border="1">
|
||||
{% for r in rfcs %}
|
||||
<tr><td>{{r.rfc_number}}</td><td>{{r.title|escape}}</td><td>{{r.draft}}</td></tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -53,6 +53,7 @@ urlpatterns = patterns('',
|
|||
(r'^ipr/', include('ietf.ipr.urls')),
|
||||
(r'^meeting/', include('ietf.meeting.urls')),
|
||||
(r'^accounts/', include('ietf.ietfauth.urls')),
|
||||
(r'^doc/', include('ietf.idrfc.urls')),
|
||||
|
||||
(r'^$', 'ietf.redirects.views.redirect'),
|
||||
|
||||
|
|
Loading…
Reference in a new issue