First draft of new liaison statement model, import SDOs as groups,
start on liaison statement importing - Legacy-Id: 3309
This commit is contained in:
parent
99886e9a38
commit
c7d58d6079
ietf
redesign
|
@ -88,7 +88,7 @@ class ScheduledAnnouncement(models.Model):
|
|||
db_table = 'scheduled_announcements'
|
||||
|
||||
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES or hasattr(settings, "IMPORTING_ANNOUNCEMENTS"):
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES or hasattr(settings, "IMPORTING_FROM_OLD_SCHEMA"):
|
||||
import datetime
|
||||
|
||||
from person.models import Email, Person
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#coding: utf-8
|
||||
from django import template
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from django.contrib.admin.util import unquote
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
@ -18,7 +19,8 @@ from ietf.ietfauth.models import LegacyWgPassword, LegacyLiaisonUser
|
|||
|
||||
class FromBodiesAdmin(admin.ModelAdmin):
|
||||
list_display = ['body_name', 'contact_link', 'other_sdo']
|
||||
admin.site.register(FromBodies, FromBodiesAdmin)
|
||||
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
admin.site.register(FromBodies, FromBodiesAdmin)
|
||||
|
||||
|
||||
class LiaisonDetailAdmin(admin.ModelAdmin):
|
||||
|
|
|
@ -305,3 +305,41 @@ class Uploads(models.Model):
|
|||
# removed edit_inline
|
||||
# removed num_in_admin
|
||||
# removed raw_id_admin
|
||||
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES or hasattr(settings, "IMPORTING_FROM_OLD_SCHEMA"):
|
||||
from redesign.name.models import LiaisonStatementPurposeName
|
||||
from redesign.person.models import Person
|
||||
from redesign.group.models import Group
|
||||
|
||||
class LiaisonStatement(models.Model):
|
||||
title = models.CharField(blank=True, max_length=255)
|
||||
purpose = models.ForeignKey(LiaisonStatementPurposeName)
|
||||
body = models.TextField(blank=True)
|
||||
deadline = models.DateField(null=True, blank=True)
|
||||
|
||||
related_to = models.ForeignKey('LiaisonDetail', blank=True, null=True)
|
||||
|
||||
from_body = models.ForeignKey(Group, related_name="liaisonstatement_from_set", null=True, blank=True, help_text="From body, if it exists")
|
||||
from_name = models.CharField(max_length=255, help_text="Name of the sender body")
|
||||
to_body = models.ForeignKey(Group, related_name="liaisonstatement_to_set", null=True, blank=True, help_text="to body, if it exists")
|
||||
to_name = models.CharField(max_length=255, help_text="Name of the recipient body")
|
||||
to_contact = models.CharField(blank=True, max_length=255)
|
||||
|
||||
reply_to = models.CharField(blank=True, max_length=255)
|
||||
|
||||
response_contact = models.CharField(blank=True, max_length=255)
|
||||
technical_contact = models.CharField(blank=True, max_length=255)
|
||||
cc = models.TextField(blank=True)
|
||||
|
||||
submitted = models.DateTimeField(null=True, blank=True)
|
||||
submitted_by = models.ForeignKey(Person)
|
||||
modified = models.DateTimeField(null=True, blank=True)
|
||||
approved = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
action_taken = models.BooleanField(default=False)
|
||||
|
||||
#submitter_name = models.CharField(blank=True, null=True, max_length=255)
|
||||
#submitter_email = models.CharField(blank=True, null=True, max_length=255)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.title or "<no title>"
|
||||
|
|
|
@ -7,9 +7,9 @@ from redesign.person.models import Email, Person
|
|||
import datetime
|
||||
|
||||
class GroupInfo(models.Model):
|
||||
time = models.DateTimeField(default=datetime.datetime.now) # should probably have auto_now=True
|
||||
time = models.DateTimeField(default=datetime.datetime.now)
|
||||
name = models.CharField(max_length=80)
|
||||
acronym = models.CharField(max_length=16, db_index=True)
|
||||
acronym = models.CharField(max_length=16, blank=True, db_index=True)
|
||||
state = models.ForeignKey(GroupStateName, null=True)
|
||||
type = models.ForeignKey(GroupTypeName, null=True)
|
||||
parent = models.ForeignKey('Group', blank=True, null=True)
|
||||
|
|
|
@ -7,7 +7,7 @@ sys.path = [ basedir ] + sys.path
|
|||
|
||||
from ietf import settings
|
||||
settings.USE_DB_REDESIGN_PROXY_CLASSES = False
|
||||
settings.IMPORTING_ANNOUNCEMENTS = True
|
||||
settings.IMPORTING_FROM_OLD_SCHEMA = True
|
||||
|
||||
from django.core import management
|
||||
management.setup_environ(settings)
|
||||
|
|
|
@ -17,8 +17,9 @@ from redesign.name.models import *
|
|||
from redesign.name.utils import name
|
||||
from redesign.importing.utils import old_person_to_person
|
||||
from ietf.idtracker.models import AreaGroup, IETFWG, Area, AreaGroup, Acronym, AreaWGURL, IRTF, ChairsHistory, Role, AreaDirector
|
||||
from ietf.liaisons.models import SDOs
|
||||
|
||||
# imports IETFWG, Area, AreaGroup, Acronym, IRTF, AreaWGURL
|
||||
# imports IETFWG, Area, AreaGroup, Acronym, IRTF, AreaWGURL, SDOs
|
||||
|
||||
# also creates nomcom groups
|
||||
|
||||
|
@ -41,13 +42,22 @@ type_names = dict(
|
|||
rg=name(GroupTypeName, slug="rg", name="RG"),
|
||||
team=name(GroupTypeName, slug="team", name="Team"),
|
||||
individ=name(GroupTypeName, slug="individ", name="Individual"),
|
||||
sdo=name(GroupTypeName, slug="sdo", name="Standards Organization"),
|
||||
)
|
||||
|
||||
# make sure we got the IETF as high-level parent
|
||||
ietf_group, _ = Group.objects.get_or_create(acronym="ietf")
|
||||
ietf_group.name = "IETF"
|
||||
ietf_group.state = state_names["active"]
|
||||
ietf_group.type = type_names["ietf"]
|
||||
ietf_group.save()
|
||||
|
||||
# make sure we got the IESG so we can use it as parent for areas
|
||||
iesg_group, _ = Group.objects.get_or_create(acronym="iesg")
|
||||
iesg_group.name = "IESG"
|
||||
iesg_group.state = state_names["active"]
|
||||
iesg_group.type = type_names["ietf"]
|
||||
iesg_group.parent = ietf_group
|
||||
iesg_group.save()
|
||||
|
||||
# make sure we got the IRTF as parent for RGs
|
||||
|
@ -275,3 +285,12 @@ for o in IETFWG.objects.all().order_by("pk"):
|
|||
# dormant_date is empty on all so don't bother with that
|
||||
|
||||
# FIXME: missing fields from old: meeting_scheduled, email_keyword, meeting_scheduled_old
|
||||
|
||||
# SDOs
|
||||
for o in SDOs.objects.all().order_by("pk"):
|
||||
# we import SDOs as groups, this makes it easy to take advantage
|
||||
# of the rest of the role/person models for authentication and
|
||||
# authorization
|
||||
print "importing SDOs", o.pk, o.sdo_name
|
||||
Group.objects.get_or_create(name=o.sdo_name, type=type_names["sdo"])
|
||||
|
||||
|
|
124
redesign/importing/import-liaison.py
Normal file
124
redesign/importing/import-liaison.py
Normal file
|
@ -0,0 +1,124 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import sys, os, re, datetime, pytz
|
||||
|
||||
basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
|
||||
sys.path = [ basedir ] + sys.path
|
||||
|
||||
from ietf import settings
|
||||
settings.USE_DB_REDESIGN_PROXY_CLASSES = False
|
||||
settings.IMPORTING_FROM_OLD_SCHEMA = True
|
||||
|
||||
from django.core import management
|
||||
management.setup_environ(settings)
|
||||
|
||||
from django.template.defaultfilters import slugify
|
||||
|
||||
from ietf.idtracker.models import AreaDirector, IETFWG, Acronym, IRTF
|
||||
from ietf.liaisons.models import *
|
||||
from redesign.person.models import *
|
||||
from redesign.importing.utils import get_or_create_email, old_person_to_person
|
||||
from redesign.name.models import *
|
||||
from redesign.name.utils import name
|
||||
|
||||
|
||||
# imports LiaisonDetail, OutgoingLiaisonApproval, Uploads
|
||||
|
||||
# todo: LiaisonStatementManager, LiaisonManagers, SDOAuthorizedIndividual
|
||||
|
||||
# assumptions:
|
||||
# - persons have been imported
|
||||
# - groups have been imported
|
||||
|
||||
purpose_mapping = {
|
||||
1: name(LiaisonStatementPurposeName, "action", "For action"),
|
||||
2: name(LiaisonStatementPurposeName, "comment", "For comment"),
|
||||
3: name(LiaisonStatementPurposeName, "info", "For information"),
|
||||
4: name(LiaisonStatementPurposeName, "response", "In response"),
|
||||
5: name(LiaisonStatementPurposeName, "other", "Other"),
|
||||
}
|
||||
|
||||
purpose_mapping[None] = purpose_mapping[3] # map unknown to "For information"
|
||||
|
||||
system_person = Person.objects.get(name="(System)")
|
||||
obviously_bogus_date = datetime.date(1970, 1, 1)
|
||||
|
||||
bodies = {
|
||||
'IESG': Group.objects.get(acronym="iesg"),
|
||||
'IETF': Group.objects.get(acronym="ietf"),
|
||||
'IAB/ISOC': Group.objects.get(acronym="iab"),
|
||||
'IAB/IESG': Group.objects.get(acronym="iab"),
|
||||
'IAB': Group.objects.get(acronym="iab"),
|
||||
'IETF Transport Directorate': Group.objects.get(acronym="tsvdir"),
|
||||
'Sigtran': Group.objects.get(acronym="sigtran", type="wg"),
|
||||
'IETF RAI WG': Group.objects.get(acronym="rai", type="area"),
|
||||
'IETF Mobile IP WG': Group.objects.get(acronym="mobileip", type="wg"),
|
||||
}
|
||||
|
||||
def get_from_body(name):
|
||||
# the from body name is a nice case study in how inconsistencies
|
||||
# build up over time
|
||||
b = bodies.get(name)
|
||||
t = name.split()
|
||||
if not b and name.startswith("IETF"):
|
||||
if len(t) < 3 or t[2].lower() == "wg":
|
||||
b = lookup_group(acronym=t[1].lower(), type="wg")
|
||||
elif t[2].lower() in ("area", "ad"):
|
||||
print "inside AREA"
|
||||
b = lookup_group(acronym=t[1].lower(), type="area")
|
||||
if not b:
|
||||
b = lookup_group(name=u"%s %s" % (t[1], t[2]), type="area")
|
||||
|
||||
if not b and name.endswith(" WG"):
|
||||
b = lookup_group(acronym=t[-2].lower(), type="wg")
|
||||
|
||||
if not b:
|
||||
b = lookup_group(name=name, type="sdo")
|
||||
|
||||
return b
|
||||
|
||||
for o in LiaisonDetail.objects.all().order_by("pk"):#[:10]:
|
||||
print "importing LiaisonDetail", o.pk
|
||||
|
||||
try:
|
||||
l = LiaisonStatement.objects.get(pk=o.pk)
|
||||
except LiaisonStatement.DoesNotExist:
|
||||
l = LiaisonStatement(pk=o.pk)
|
||||
|
||||
l.title = (o.title or "").strip()
|
||||
l.purpose = purpose_mapping[o.purpose_id]
|
||||
if o.purpose_text and not o.purpose and "action" in o.purpose_text.lower():
|
||||
o.purpose = purpose_mapping[1]
|
||||
l.body = (o.body or "").strip()
|
||||
l.deadline = o.deadline_date
|
||||
|
||||
l.related_to_id = o.related_to_id # should not dangle as we process ids in turn
|
||||
|
||||
def lookup_group(**kwargs):
|
||||
try:
|
||||
return Group.objects.get(**kwargs)
|
||||
except Group.DoesNotExist:
|
||||
return None
|
||||
|
||||
l.from_name = o.from_body()
|
||||
l.from_body = get_from_body(l.from_name) # try to establish link
|
||||
continue
|
||||
|
||||
l.to_body = o.to_raw_body
|
||||
l.to_name = o.to_raw_body
|
||||
l.to_contact = (o.to_poc or "").strip()
|
||||
|
||||
l.reply_to = (o.replyto or "").strip()
|
||||
|
||||
l.response_contact = (o.response_contact or "").strip()
|
||||
l.technical_contact = (o.technical_contact or "").strip()
|
||||
l.cc = (o.cc1 or "").strip()
|
||||
|
||||
l.submitted = o.submitted_date
|
||||
l.submitted_by = old_person_to_person(o.person)
|
||||
l.modified = o.last_modified_date
|
||||
l.approved = o.approval and o.approval.approved and (o.approval.approval_date or l.modified or datetime.datetime.now())
|
||||
|
||||
l.action_taken = o.action_taken
|
||||
|
||||
#l.save()
|
|
@ -70,6 +70,8 @@ class TimeSlotTypeName(NameModel):
|
|||
"""Session, Break, Registration"""
|
||||
class ConstraintName(NameModel):
|
||||
"""Conflict"""
|
||||
class LiaisonStatementPurposeName(NameModel):
|
||||
"""For action, For comment, For information, In response, Other"""
|
||||
|
||||
|
||||
def get_next_iesg_states(iesg_state):
|
||||
|
|
Loading…
Reference in a new issue