mirror of
https://github.com/peeringdb/peeringdb.git
synced 2024-05-11 05:55:09 +00:00
* use new peeringdb client (1.0.0) for pdb_load_data sync (#599) * drop django-mobi for lack of py3/dj2 support (#492) remove django-forms-bootstrap for lack of py3/dj2 support (#492) * black formatted * django2.2 and py3 upgrade (#492) * drop ixlans (#21) ui and api changes * drop local_asn (#168) * org search (#193) * phone number validation (#50) * implement help text tooltips (#228) * Mark own ASN as transit-free (#394) * py3 fix for `pdb_migrate_ixlans` command when writing migration report * pdb_migrate_ixlans: properly handle py3 Runtime error if ixlan dict changes during iteration * set rest DEFAULT_SCHEMA_CLASS to coreapi to fix swagger apidocs fix migration 0027 missing from facsimile manifest * fix swagger doc strings * fix tests that were broken from api doc fixes * fix UniqueFieldValidator for netixlan ipaddress validation that broke during django/drf upgrade * fix org merge tool layout issues * travis config * update pipfile and lock * black formatting * update travis dist * beta mode banner (#411) * add beta banner template (#411) * automatically scheduled sync may not always be on, add a flag that lets us reflect that state in the beta banner message clean up beta banner implementation (#411) * add tests for beta banner (#411)
82 lines
2.4 KiB
Python
82 lines
2.4 KiB
Python
from django.core.management.base import BaseCommand
|
|
import json
|
|
import peeringdb_server.models as pdbm
|
|
from django.contrib.contenttypes.models import ContentType
|
|
from reversion.models import Version
|
|
|
|
MODELS = [
|
|
pdbm.Organization,
|
|
pdbm.Network,
|
|
pdbm.InternetExchange,
|
|
pdbm.InternetExchangeFacility,
|
|
pdbm.Facility,
|
|
pdbm.NetworkContact,
|
|
pdbm.NetworkFacility,
|
|
pdbm.IXLan,
|
|
pdbm.IXLanPrefix,
|
|
pdbm.NetworkIXLan,
|
|
]
|
|
|
|
|
|
class Command(BaseCommand):
|
|
args = "<reftag> <id, id, ...>"
|
|
help = "Inspect an object's reversion history"
|
|
|
|
def log(self, id, msg):
|
|
print("%s: %s" % (id, msg))
|
|
|
|
def print_line(self):
|
|
print("".join(["-" for i in range(0, 80)]))
|
|
|
|
def add_arguments(self, parser):
|
|
parser.add_argument("reftag", nargs="?", type=str)
|
|
parser.add_argument("id", nargs="+", type=int)
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
versions = Version.objects.all()
|
|
ref_tag = options.get("reftag")
|
|
|
|
ids = [int(i) for i in options.get("id")]
|
|
|
|
print((ref_tag, ids))
|
|
|
|
model = None
|
|
for m in MODELS:
|
|
if m.handleref.tag == ref_tag:
|
|
model = m
|
|
break
|
|
|
|
if not model:
|
|
print("Unknown ref tag: %s" % ref_tag)
|
|
return
|
|
|
|
content_type = ContentType.objects.get_for_model(model)
|
|
for id in ids:
|
|
versions = Version.objects.filter(
|
|
content_type=content_type, object_id=id
|
|
).order_by("revision_id")
|
|
print("%s - %d:" % (ref_tag, id))
|
|
self.print_line()
|
|
prev = {}
|
|
n = 0
|
|
for version in versions:
|
|
data = json.loads(version.serialized_data)[0].get("fields")
|
|
n += 1
|
|
print(
|
|
"VERSION: %d (%d) - %s - User: %s"
|
|
% (n, version.id, data.get("updated"), version.revision.user,)
|
|
)
|
|
if not prev:
|
|
for k, v in list(data.items()):
|
|
print("%s: '%s'" % (k, v))
|
|
self.print_line()
|
|
prev = data
|
|
continue
|
|
for k, v in list(data.items()):
|
|
if prev.get(k) != v:
|
|
print("%s: '%s' => '%s'" % (k, prev.get(k), v))
|
|
|
|
prev = data
|
|
self.print_line()
|