Commit 0790d933 authored by Leonidas Poulopoulos's avatar Leonidas Poulopoulos
Browse files

Added realm_data.xml, plus minor ui fixes

parent 68148409
......@@ -14,7 +14,12 @@ class UrlInline(generic.GenericTabularInline):
class InstitutionAdmin(admin.ModelAdmin):
inlines = [
NameInline,
NameInline,
]
class InstitutionDetailsAdmin(admin.ModelAdmin):
inlines = [
UrlInline,
]
class ServiceLocAdmin(admin.ModelAdmin):
......@@ -39,6 +44,6 @@ admin.site.register(MonProxybackClient)
admin.site.register(MonLocalEAPOLData)
admin.site.register(ServiceLoc, ServiceLocAdmin)
admin.site.register(Institution, InstitutionAdmin)
admin.site.register(InstitutionDetails)
admin.site.register(InstitutionDetails, InstitutionDetailsAdmin)
admin.site.register(Realm, RealmInLine)
admin.site.register(RealmData)
\ No newline at end of file
......@@ -330,7 +330,7 @@ class InstitutionDetails(models.Model):
return _('Institution: %(inst)s, Type: %(ertype)s') % {
# but name is many-to-many from institution
'inst': ', '.join([i.name for i in self.institution.org_name.all()]),
'ertype': self.ertype,
'ertype': self.institution.ertype,
}
......
......@@ -4,33 +4,38 @@ urlpatterns = patterns('edumanage.views',
url(r'^$', 'index', name="index"),
url(r'^geolocate/?$', 'geolocate', name="geolocate"),
url(r'^closest/?$', 'closest', name="closest"),
url(r'^general/institution.xml', "instxml", name="instxml"),
url(r'^general/realm.xml', "realmxml", name="realmxml"),
url(r'^general/realm_data.xml', "realmdataxml", name="realmdataxml"),
url(r'^manage/?$', 'manage', name="manage"),
url(r'^institutions/?$', 'institutions', name="institutions"),
url(r'^institution/edit/(?P<institution_pk>\d+)?$', 'add_institution_details', name="edit-institution"),
url(r'^services/(?P<service_pk>\d+)?$', 'services', name="services"),
url(r'^services/del/?$', 'del_service', name="del-service"),
url(r'^services/edit/(?P<service_pk>\d+)?$', 'add_services', name="edit-services"),
url(r'^services/points/?$', 'get_service_points', name="get-service-points"),
url(r'^services/allpoints/?$', 'get_all_services', name="get-all-services"),
url(r'^servers/(?P<server_pk>\d+)?$', 'servers', name="servers"),
url(r'^servers/del/?$', 'del_server', name="del-server"),
url(r'^servers/edit/(?P<server_pk>\d+)?$', 'add_server', name="edit-servers"),
url(r'^realms/?$', 'realms', name="realms"),
url(r'^realms/edit/(?P<realm_pk>\d+)?$', 'add_realm', name="edit-realms"),
url(r'^realms/del/?$', 'del_realm', name="del-realm"),
url(r'^contacts/?$', 'contacts', name="contacts"),
url(r'^contacts/edit/(?P<contact_pk>\d+)?$', 'add_contact', name="edit-contacts"),
url(r'^contacts/del/?$', 'del_contact', name="del-contact"),
url(r'^manage/institutions/?$', 'institutions', name="institutions"),
url(r'^manage/institution/edit/(?P<institution_pk>\d+)?$', 'add_institution_details', name="edit-institution"),
url(r'^manage/services/(?P<service_pk>\d+)?$', 'services', name="services"),
url(r'^manage/services/del/?$', 'del_service', name="del-service"),
url(r'^manage/services/edit/(?P<service_pk>\d+)?$', 'add_services', name="edit-services"),
url(r'^manage/services/points/?$', 'get_service_points', name="get-service-points"),
url(r'^manage/services/allpoints/?$', 'get_all_services', name="get-all-services"),
url(r'^manage/servers/(?P<server_pk>\d+)?$', 'servers', name="servers"),
url(r'^manage/servers/del/?$', 'del_server', name="del-server"),
url(r'^manage/servers/edit/(?P<server_pk>\d+)?$', 'add_server', name="edit-servers"),
url(r'^manage/realms/?$', 'realms', name="realms"),
url(r'^manage/realms/edit/(?P<realm_pk>\d+)?$', 'add_realm', name="edit-realms"),
url(r'^manage/realms/del/?$', 'del_realm', name="del-realm"),
url(r'^manage/contacts/?$', 'contacts', name="contacts"),
url(r'^manage/contacts/edit/(?P<contact_pk>\d+)?$', 'add_contact', name="edit-contacts"),
url(r'^manage/contacts/del/?$', 'del_contact', name="del-contact"),
url(r'^adduser/?$', 'adduser', name="adduser"),
url(r'^manage/adduser/?$', 'adduser', name="adduser"),
url(r'^general/institution.xml', "instxml", name="instxml"),
url(r'^general/realm.xml', "realmxml", name="realmxml"),
)
......
......@@ -20,6 +20,9 @@ from xml.etree import ElementTree as ET
from django.conf import settings
from django.contrib import messages
from django.db.models import Max
def index(request):
return render_to_response('front/index.html', context_instance=RequestContext(request))
......@@ -725,7 +728,7 @@ def instxml(request):
instCountry.text = ("%s" %inst.institution.realmid.country).upper()
instType = ET.SubElement(instElement, "type")
instType.text = "%s" %inst.ertype
instType.text = "%s" %inst.institution.ertype
for realm in institution.instrealm_set.all():
instRealm = ET.SubElement(instElement, "inst_realm")
......@@ -830,7 +833,7 @@ def realmxml(request):
realmElement = ET.SubElement(root, "realm")
realmCountry = ET.SubElement(realmElement, "country")
realmCountry.text = realm.country
realmCountry.text = realm.country.upper()
realmStype = ET.SubElement(realmElement, "stype")
realmStype.text = "%s" %realm.stype
......@@ -865,15 +868,66 @@ def realmxml(request):
realmUrl.attrib["lang"] = url.lang
realmUrl.text = url.url
instTs = ET.SubElement(realmElement, "ts")
instTs.text = "%s" %realm.ts.isoformat()
return render_to_response("general/realm.xml", {"xml":to_xml(root)},context_instance=RequestContext(request,), mimetype="application/xml")
def realmdataxml(request):
realm = Realm.objects.all()[0]
ET._namespace_map["http://www.w3.org/2001/XMLSchema-instance"] = 'xsi'
root = ET.Element("realm-data")
root = ET.Element("realm_data_root")
NS_XSI = "{http://www.w3.org/2001/XMLSchema-instance}"
root.set(NS_XSI + "noNamespaceSchemaLocation", "realm-data.xsd")
realmdataElement = ET.SubElement(root, "realm_data")
realmCountry = ET.SubElement(realmdataElement, "country")
realmCountry.text = realm.country.upper()
nIdpCountry = ET.SubElement(realmdataElement, "number_Idp")
nIdpCountry.text = "%s" %len(realm.institution_set.filter(ertype=1))
nSPCountry = ET.SubElement(realmdataElement, "number_SP")
nSPCountry.text = "%s" %len(realm.institution_set.filter(ertype=2))
nSPIdpCountry = ET.SubElement(realmdataElement, "number_SPIdP")
nSPIdpCountry.text = "%s" %len(realm.institution_set.filter(ertype=3))
ninstCountry = ET.SubElement(realmdataElement, "number_inst")
ninstCountry.text = "%s" %len(realm.institution_set.all())
nuserCountry = ET.SubElement(realmdataElement, "number_user")
insts = realm.institution_set.all()
users = 0
for inst in insts:
try:
users = users + inst.institutiondetails.number_user
except InstitutionDetails.DoesNotExist:
pass
nuserCountry.text = "%s" %users
nIdCountry = ET.SubElement(realmdataElement, "number_id")
insts = realm.institution_set.all()
ids = 0
for inst in insts:
try:
ids = ids + inst.institutiondetails.number_id
except InstitutionDetails.DoesNotExist:
pass
nIdCountry.text = "%s" %ids
# Get the latest ts from all tables...
datetimes = []
datetimes.append(InstitutionDetails.objects.aggregate(Max('ts'))['ts__max'])
datetimes.append(Realm.objects.aggregate(Max('ts'))['ts__max'])
datetimes.append(InstServer.objects.aggregate(Max('ts'))['ts__max'])
datetimes.append(ServiceLoc.objects.aggregate(Max('ts'))['ts__max'])
instTs = ET.SubElement(realmdataElement, "ts")
instTs.text = "%s" %max(datetimes).isoformat()
return render_to_response("general/realm_data.xml", {"xml":to_xml(root)},context_instance=RequestContext(request,), mimetype="application/xml")
def to_xml(ele, encoding="UTF-8"):
......
......@@ -123,7 +123,6 @@ function addButton(row){
<label class="control-label" for="id_urls">{% trans "Urls" %}</label>
{{urls_form.management_form}}
<div class="controls">
{% for err in urls_form.errors %}{% if err|length > 0 %}<span class="help-inline">{{err}}</span>{% endif %}{% endfor %}
{% if urls_form.non_form_errors %} <span class="help-inline"> {{ urls_form.non_form_errors|join:", "}}</span>{% endif %}
<table id="urlsform"><thead><tr><td>url</td><td>type</td><td>language</td></tr></thead><tbody>
{% for formset in urls_form.forms %}
......
{% autoescape off %}{{xml}}{% endautoescape %}
\ No newline at end of file
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