Commit 795fd1c2 authored by Zenon Mousmoulas's avatar Zenon Mousmoulas
Browse files

Let parse_instituion_xml management command take INST_XML_FILE as an argument,

rather from settings.

Simplify some things in that script, while we're at it.
parent 21d598cd
......@@ -207,7 +207,6 @@ AUTH_PROFILE_MODULE = 'accounts.UserProfile'
LOGIN_URL = '/manage/login/'
KML_FILE = os.path.join(PROJECT_DIR, 'all.kml')
INST_XML_FILE = os.path.join(PROJECT_DIR, 'institution.xml')
EDUROAM_KML_URL = 'http://monitor.eduroam.org/kml/all.kml'
......
# -*- coding: utf-8 -*- vim:encoding=utf-8:
# vim: tabstop=4:shiftwidth=4:softtabstop=4:expandtab
from django.core.management.base import BaseCommand
from django.core.management.base import BaseCommand, CommandError
from edumanage.models import *
from xml.etree import ElementTree
from django.conf import settings
import sys
class Command(BaseCommand):
args = ''
help = '''
Parses the institution XML file and creates institution,
institution realm, contact and service point entries
Parses an institution XML file and creates institution,
institution realm, contact and service location entries
'''
help = 'Imports djnro models from a specified institution.xml'
args = '<file>'
label = 'file name to be imported'
def handle(self, *args, **options):
file = settings.INST_XML_FILE
self.parse_and_create(file)
'''
Handle command
'''
def parse_and_create(self, file):
doc = ElementTree.parse(file)
if args is None or len(args) != 1:
raise CommandError('You must supply a file name')
self.parse_and_create(args[0])
def parse_and_create(self, instxmlfile):
doc = ElementTree.parse(instxmlfile)
realmid = Realm.objects.get(pk=1)
root = doc.getroot()
institutions = []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment