Repository: OpenEnergyPlatform/oeplatform

Issue:
Logos in base/static/logos should be more organized
Currently, all logos (partner+project logos) are stored together in the `static/logos` directory. Introduce two sub-dirs. called `partern` and `project` .


Discussion:

Resolving patch:
diff --git a/base/urls.py b/base/urls.py
--- a/base/urls.py
+++ b/base/urls.py
@@ -5,7 +5,8 @@
 urlpatterns = [
     url(r"^robots.txt$", views.robot),
     url(r"^$", views.Welcome.as_view(), name="index"),
-    url(r"^about/$", views.redir, {"target": "about"}, name="index"),
+    url(r"^about/$", views.AboutPage.as_view(), name="index"),
+    url(r"^about/project-detail/(?P<project_id>[\w\-]+)/$", views.AboutProjectDetail.as_view(), name="project_detail"),
     url(r"^faq/$", views.redir, {"target": "faq"}, name="index"),
     url(r"^discussion/$", views.redir, {"target": "discussion"}, name="index"),
     url(r"^contact/$", views.ContactView.as_view(), name="index"),
diff --git a/base/views.py b/base/views.py
--- a/base/views.py
+++ b/base/views.py
@@ -1,5 +1,8 @@
+import json
 import os
 import re
+import pathlib
+from django.apps import apps
 
 import markdown2
 from django.core.mail import send_mail
@@ -107,3 +110,55 @@ def handler404(request, exception):
     response = render(request, "base/404.html", {})
     response.status_code = 404
     return response
+
+
+def get_json_content(path, json_id=None):
+    """ Parse all jsons from given path and return as 
+        list or return a single parsed json by id ->  
+        The json must have a field called id. 
+
+    Args:
+        path (string): path to directory like 'static/project_pages_content/'
+        json_id (string, optional): ID value that must match the value of json[id]. Defaults to None.
+
+    Returns:
+        list[object]: List of all deserialized json files in path 
+        or
+        object: single json python object
+    """
+    
+    if path is not None:
+        all_jsons=[]
+        for _json in os.listdir(path=path):
+            with open(os.path.join(path, _json), "r", encoding='utf-8') as json_content:
+                content = json.load(json_content)
+                all_jsons.append(content)
+
+        if json_id is None:
+            return all_jsons
+        else:
+            content_by_id = [i for i in all_jsons if json_id == i["id"] and "template" != i["id"]]
+            return content_by_id[0]
+    # TODO: catch the exception if path is none 
+    else:
+        return {"error": "Path cant be None. Please provide the path to '/static/project_detail_pages_content/' . You can create a new Project by adding an JSON file like the '/static/project_detail_pages_content/PROJECT_TEMPLATE.json'."}
+
+class AboutPage(View):
+# docstring
+    projects_content_static = "project_detail_pages_content"
+    projects_content_path = os.path.join(sec.STATIC_ROOT, projects_content_static)
+
+    def get(self, request, projects_content_path=projects_content_path):
+        projects = get_json_content(path=projects_content_path)
+
+        return render(request, "base/about.html", {"projects": projects})
+
+class AboutProjectDetail(AboutPage):
+# docstring
+
+    def get(self, request, project_id):
+        project = get_json_content(path=self.projects_content_path, json_id=project_id)
+
+        return render(request, "base/project-detail.html", {"project": project})
+    
+          
\ No newline at end of file


Test patch: