chore: remove unused mgmt commands
This commit is contained in:
parent
edd72826e6
commit
18941434c3
ietf
|
@ -1,64 +0,0 @@
|
|||
# Copyright The IETF Trust 2019-2020, All Rights Reserved
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
import os
|
||||
|
||||
from collections import Counter
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from ietf.doc.models import DocEvent
|
||||
from ietf.meeting.models import Meeting, SessionPresentation
|
||||
from ietf.person.models import Person
|
||||
|
||||
from ietf.meeting.utils import is_powerpoint, post_process
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = ('Fix uploaded_filename and generate pdf from pptx')
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--dry-run', action='store_true', dest='dry-run', default=False, help='Report on changes that would be made without making them')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
ietf105 = Meeting.objects.get(number=105)
|
||||
slides_path = os.path.join(ietf105.get_materials_path(),'slides')
|
||||
system_person = Person.objects.get(name="(System)")
|
||||
counts = Counter()
|
||||
|
||||
for sp in SessionPresentation.objects.filter(session__meeting__number=105,document__type='slides'): #.filter(document__name='slides-105-manet-dlep-multicast-support-discussion'):
|
||||
slides = sp.document
|
||||
if not os.path.exists(os.path.join(slides_path,slides.uploaded_filename)):
|
||||
name, ext = os.path.splitext(slides.uploaded_filename)
|
||||
target_filename = '%s-%s%s' % (name[:name.rfind('-ss')], slides.rev,ext)
|
||||
if os.path.exists(os.path.join(slides_path,target_filename)):
|
||||
slides.uploaded_filename = target_filename
|
||||
if not options['dry-run']:
|
||||
e = DocEvent.objects.create(doc=slides, rev=slides.rev, by=system_person, type='changed_document', desc='Corrected uploaded_filename')
|
||||
slides.save_with_history([e])
|
||||
counts['uploaded_filename repair succeeded'] += 1
|
||||
|
||||
else:
|
||||
self.stderr.write("Unable to repair %s" % slides)
|
||||
counts['uploaded_filename repair failed'] += 1
|
||||
continue
|
||||
else:
|
||||
counts['uploaded_filename already ok'] += 1
|
||||
|
||||
if is_powerpoint(slides):
|
||||
base, _ = os.path.splitext(slides.uploaded_filename)
|
||||
if os.path.exists(os.path.join(slides_path,base+'.pdf')):
|
||||
self.stderr.write("PDF already exists for %s " % slides)
|
||||
counts['PDF already exists for a repaired file'] += 1
|
||||
else:
|
||||
if not options['dry-run']:
|
||||
post_process(slides)
|
||||
counts['PDF conversions'] += 1
|
||||
|
||||
if options['dry-run']:
|
||||
self.stdout.write("This is a dry-run. Nothing has actually changed. In a normal run, the output would say the following:")
|
||||
|
||||
for label,count in counts.iteritems():
|
||||
self.stdout.write("%s : %d" % (label,count) )
|
||||
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
# Copyright The IETF Trust 2022, All Rights Reserved
|
||||
|
||||
import debug # pyflakes: ignore
|
||||
|
||||
from tqdm import tqdm
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from ietf.meeting.models import Session
|
||||
from ietf.meeting.utils import sort_sessions
|
||||
from ietf.person.models import Person, Email
|
||||
|
||||
import json
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
help = 'Populates the meeting Attended table based on bluesheets and registration information'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('filename', nargs='+', type=str)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
|
||||
issues = []
|
||||
session_cache = dict()
|
||||
skipped = 0
|
||||
for filename in options['filename']:
|
||||
records = json.loads(open(filename,'r').read())
|
||||
for record in tqdm(records):
|
||||
user = record['sub']
|
||||
session_acronym = record['group']
|
||||
meeting_number = record['meeting']
|
||||
email = record['email']
|
||||
# In the expected dumps from MeetEcho, if there was only one session for group foo, it would just be named 'foo'.
|
||||
# If there were _three_, we would see 'foo' for the first, 'foo_2' for the second, and 'foo_3' for the third.
|
||||
# order below is the index into what is returned from sort_sessions -- 0 is the first session for a group at that meeting.
|
||||
# There is brutal fixup below for older meetings where we had special arrangements where meetecho reported the non-existent
|
||||
# group of 'plenary', mapping it into the appropriate 'ietf' group session.
|
||||
# A bug in the export scripts at MeetEcho trimmed the '-t' from 'model-t'.
|
||||
order = 0
|
||||
if session_acronym in ['anrw_test', 'demoanrw', 'hostspeaker']:
|
||||
skipped = skipped + 1
|
||||
continue
|
||||
if session_acronym=='model':
|
||||
session_acronym='model-t'
|
||||
if '_' in session_acronym:
|
||||
session_acronym, order = session_acronym.split('_')
|
||||
order = int(order)-1
|
||||
if session_acronym == 'plenary':
|
||||
session_acronym = 'ietf'
|
||||
if meeting_number == '111':
|
||||
order = 4
|
||||
elif meeting_number == '110':
|
||||
order = 3
|
||||
elif meeting_number == '109':
|
||||
order = 6
|
||||
elif meeting_number == '108':
|
||||
order = 13
|
||||
if session_acronym == 'ietf':
|
||||
if meeting_number == '112':
|
||||
order = 2
|
||||
elif meeting_number == '113':
|
||||
order = 2
|
||||
if not (meeting_number, session_acronym) in session_cache:
|
||||
session_cache[(meeting_number, session_acronym)] = sort_sessions([s for s in Session.objects.filter(meeting__number=meeting_number,group__acronym=session_acronym) if s.official_timeslotassignment()])
|
||||
sessions = session_cache[(meeting_number, session_acronym)]
|
||||
try:
|
||||
session = sessions[order]
|
||||
except IndexError:
|
||||
issues.append(('session not found',record))
|
||||
continue
|
||||
person = None
|
||||
email = Email.objects.filter(address=email).first()
|
||||
if email:
|
||||
person = email.person
|
||||
else:
|
||||
person = Person.objects.filter(user__pk=user).first()
|
||||
if not person:
|
||||
issues.append(('person not found',record))
|
||||
continue
|
||||
obj, created = session.attended_set.get_or_create(person=person)
|
||||
for issue in issues:
|
||||
print(issue)
|
||||
print(f'{len(issues)} issues encountered')
|
||||
print(f'{skipped} records intentionally skipped')
|
Loading…
Reference in a new issue