diff --git a/hknweb/static/img/sponsors/Amazon.png b/hknweb/static/img/sponsors/Amazon.png
new file mode 100644
index 00000000..ee7d4eaf
Binary files /dev/null and b/hknweb/static/img/sponsors/Amazon.png differ
diff --git a/hknweb/static/img/indrel_sponsors_citadel_logo.png b/hknweb/static/img/sponsors/Citadel.png
similarity index 100%
rename from hknweb/static/img/indrel_sponsors_citadel_logo.png
rename to hknweb/static/img/sponsors/Citadel.png
diff --git a/hknweb/static/img/sponsors/Microsoft.png b/hknweb/static/img/sponsors/Microsoft.png
new file mode 100644
index 00000000..32ed4d2b
Binary files /dev/null and b/hknweb/static/img/sponsors/Microsoft.png differ
diff --git a/hknweb/static/img/sponsors/metadata b/hknweb/static/img/sponsors/metadata
new file mode 100644
index 00000000..a037be0f
--- /dev/null
+++ b/hknweb/static/img/sponsors/metadata
@@ -0,0 +1,3 @@
+Citadel https://citadel.com Citadel.png
+Google https://google.com Google.png
+Amazon https://amazon.com Amazon.png
diff --git a/hknweb/static/img/sponsors/metadata2 b/hknweb/static/img/sponsors/metadata2
new file mode 100644
index 00000000..427a0601
--- /dev/null
+++ b/hknweb/static/img/sponsors/metadata2
@@ -0,0 +1,2 @@
+Citadel https://citadel.com Citadel.png
+Google https://google.com Google.png
diff --git a/hknweb/templates/indrel.html b/hknweb/templates/indrel.html
index 1ce392db..a934d2dd 100644
--- a/hknweb/templates/indrel.html
+++ b/hknweb/templates/indrel.html
@@ -144,12 +144,14 @@
Sounds good, who should I contact?
diff --git a/hknweb/templates/indrel_admin.html b/hknweb/templates/indrel_admin.html
new file mode 100644
index 00000000..ccacb082
--- /dev/null
+++ b/hknweb/templates/indrel_admin.html
@@ -0,0 +1,101 @@
+{% extends "base.html" %}
+{% load static %}
+
+{% block title %}Industrial Relations Admin Page{% endblock %}
+
+{% block heading %}
+Industrial Relations Admin Page
+{% endblock %}
+
+{% block content %}
+
+{% include 'components/tabs.html' %}
+
+
+
+
+
+
+
+Current sponsors:
+
+
+
+{% endblock %}
diff --git a/hknweb/urls.py b/hknweb/urls.py
index 0e068d64..dacd2da7 100644
--- a/hknweb/urls.py
+++ b/hknweb/urls.py
@@ -5,7 +5,7 @@
from django.urls import include, path
from hknweb.utils import method_login_and_permission
-from hknweb.views import indrel, landing, outreach, people, users
+from hknweb.views import indrel, landing, outreach, people, users, indrel_admin
__all__ = ["urlpatterns", "safe_urlpatterns"]
@@ -29,6 +29,7 @@
path("", landing.home, name="home"),
path("about/people/", people.people, name="people"),
path("indrel", indrel.indrel, name="indrel"),
+ path("indrel_admin/", indrel_admin.indrel_admin, name = 'indrel_admin'),
path("outreach", outreach.outreach, name="outreach"),
]
diff --git a/hknweb/views/indrel.py b/hknweb/views/indrel.py
index a427a983..03d975ed 100644
--- a/hknweb/views/indrel.py
+++ b/hknweb/views/indrel.py
@@ -1,8 +1,29 @@
from django.shortcuts import render
from hknweb.utils import allow_public_access
-
+import os
@allow_public_access
def indrel(request):
- return render(request, "indrel.html")
+ # company_names = ['Google', 'Microsoft', 'Berkeley', 'Amazon']
+ # company_urls = ['https://google.com', 'https://microsoft.com', 'https://berkeley.edu', 'https://amazon.com']
+ # company_files = ['', '', '', '']
+
+ data_path = "/hknweb/static/img/sponsors/"
+ metadata_file = data_path + "metadata"
+
+ image_filepath = "/img/sponsors/"
+
+ current_companies = []
+ with open(os.getcwd() + metadata_file, "r") as f:
+ for index, line in enumerate(f.readlines()):
+ current_name, current_url, current_filename = line.split()
+ current_companies.append((index, current_name, current_url, image_filepath + current_filename))
+
+
+ a = 0
+ context = {
+ "company_data": current_companies
+ }
+
+ return render(request, "indrel.html", context)
diff --git a/hknweb/views/indrel_admin.py b/hknweb/views/indrel_admin.py
new file mode 100644
index 00000000..5f7d0397
--- /dev/null
+++ b/hknweb/views/indrel_admin.py
@@ -0,0 +1,70 @@
+from django.shortcuts import render
+
+from hknweb.utils import allow_public_access
+import os
+
+@allow_public_access
+def indrel_admin(request):
+ post_data = {}
+ data_path = "/hknweb/static/img/sponsors/"
+ metadata_file = data_path
+ if request.method == 'POST':
+ print(request.POST)
+ for key in request.POST.keys():
+ post_data[key] = request.POST.get(key, "")
+ metadata_file += "metadata"
+ write_metadata(post_data, os.getcwd() + metadata_file, data_path, request)
+
+
+
+
+ metadata_file = data_path + "metadata"
+
+
+
+ current_companies = []
+
+ print(os.getcwd())
+
+ with open(os.getcwd() + metadata_file, "r") as f:
+ for index, line in enumerate(f.readlines()):
+ current_name, current_url, current_filename = line.split()
+ current_companies.append((index, current_name, current_url, current_filename))
+
+
+
+
+ context = {
+ "company_data": current_companies
+ }
+
+
+ return render(request, "indrel_admin.html", context)
+
+
+
+def write_metadata(data, filepath, file_save_path, request):
+ count = 0
+ for key in data:
+ if key.startswith("name"):
+ count += 1
+ with open(filepath, 'w') as f:
+ for i in range(count):
+ name = data[f"name_{i}"]
+ url = data[f"url_{i}"]
+ if name == "" or url == "":
+ continue
+ uploaded_image = request.FILES.get(f"file_{i}", None)
+ filename = name + ".png"
+ if uploaded_image:
+ with open(os.getcwd() + file_save_path + filename, 'wb') as destination:
+ for chunk in uploaded_image.chunks():
+ destination.write(chunk)
+
+
+
+ f.write(name + " " + url + " " + filename + "\n")
+
+ return "Successfully wrote to metadata file!"
+
+