Skip to content

Commit

Permalink
Merge pull request opensciencegrid#2019 from matyasselmeci/pr/orgspage
Browse files Browse the repository at this point in the history
Organizations page (SOFTWARE-4776)
  • Loading branch information
matyasselmeci authored Aug 27, 2021
2 parents b89db24 + b8196be commit 76354b2
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
25 changes: 25 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,31 @@ def nsfscience_csv():
return response


@app.route('/organizations')
def organizations():
project_institution = global_data.get_mappings().project_institution
if not project_institution:
return Response("Error getting Project/Institution mappings", status=503)

organizations = set()
for project in global_data.get_projects()["Projects"]["Project"]:
if "Organization" in project:
organizations.add(project["Organization"])

# Invert the Project/Institution mapping. Note that "institution" == "organization"
# and "project" is actually the prefix for the project in our standard naming
# convention.
prefix_by_org = {pi[1]: pi[0] for pi in project_institution.items()}

org_table = []
for org in sorted(organizations):
prefix = prefix_by_org.get(org, "")
org_table.append((org, prefix))

return _fix_unicode(render_template('organizations.html.j2', org_table=org_table))



@app.route('/contacts')
def contacts():
try:
Expand Down
1 change: 1 addition & 0 deletions src/templates/homepage.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ OSG Topology Interface
<li><a href="generate_resource_group_downtime">Generate a downtime entry for a resource group</a></li>
<li><a href="contacts">List of OSG contacts</a></li>
<li><a href="map/iframe">Map of OSG sites</a></li>
<li><a href="organizations">List of organizations with projects</a></li>
</ul>
<hr>
<h2>XML and other machine-readable data</h2>
Expand Down
20 changes: 20 additions & 0 deletions src/templates/organizations.html.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% set want_js = false %}
{% extends "base.html.j2" %}
{% block title -%}
Organizations
{%- endblock %}
{% block content %}
<div class="container">
This page lists organizations that are currently used in OSG projects registered in Topology.
If there is a standard project name prefix used for project belonging to that organization,
that prefix is also shown.
<table class="table table-sm table-striped">
<thead class="thead-dark">
<tr><th scope="col">Organization</th><th scope="col">Project Prefix</th></tr>
</thead>
{%- for orgname, prefix in org_table %}
<tr><td>{{ orgname }}</td><td>{{ prefix }}</td></tr>
{% endfor -%}{# org_table #}
</table>
</div>
{% endblock %}
19 changes: 17 additions & 2 deletions src/webapp/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@


class Mappings:
def __init__(self, nsfscience: Dict):
def __init__(self, nsfscience: Dict, project_institution: Dict):
self.nsfscience = nsfscience
self.project_institution = project_institution


def get_nsfscience(indir: str, strict: bool) -> Dict:
Expand All @@ -34,6 +35,20 @@ def get_nsfscience(indir: str, strict: bool) -> Dict:
return nsfscience


def get_project_institution(indir: str, strict: bool) -> Dict:
project_institution = {}
try:
project_institution = load_yaml_file(os.path.join(indir, "project_institution.yaml"))
except yaml.YAMLError:
if strict:
raise
else:
# load_yaml_file() already logs the specific error
log.error("skipping (non-strict mode)")
return project_institution


def get_mappings(indir="../mappings", strict=False):
mappings = Mappings(nsfscience=get_nsfscience(indir, strict))
mappings = Mappings(nsfscience=get_nsfscience(indir, strict),
project_institution=get_project_institution(indir, strict))
return mappings

0 comments on commit 76354b2

Please sign in to comment.