2016-01-26 18:25:20 +00:00
|
|
|
from project.common.views import CustomTemplate, MarkdownView
|
2016-03-15 21:55:36 +00:00
|
|
|
from json import load
|
|
|
|
from django.conf import settings
|
|
|
|
import os.path
|
2016-01-26 18:25:20 +00:00
|
|
|
|
|
|
|
|
2016-03-15 21:55:36 +00:00
|
|
|
PROJECT_DETAILS = load(open(os.path.join(settings.BASE_DIR, 'data/projects.json')))
|
2016-02-28 22:26:40 +00:00
|
|
|
|
|
|
|
|
2016-01-26 18:25:20 +00:00
|
|
|
class AllView(CustomTemplate):
|
|
|
|
template_name = 'projects/all.html'
|
|
|
|
|
2016-03-15 21:55:36 +00:00
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context['projects'] = PROJECT_DETAILS
|
|
|
|
return context
|
|
|
|
|
2016-01-26 18:25:20 +00:00
|
|
|
|
|
|
|
class ProjectView(MarkdownView):
|
2016-02-28 22:26:40 +00:00
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
try:
|
|
|
|
details = PROJECT_DETAILS[kwargs['project']]
|
2016-03-20 17:16:45 +00:00
|
|
|
context['html_title'] = details['title']
|
|
|
|
context['page_title'] = details['title']
|
|
|
|
context['header_image'] = details['image']
|
2016-02-28 22:26:40 +00:00
|
|
|
except:
|
|
|
|
context['html_title'] = kwargs['project']
|
|
|
|
context['page_title'] = kwargs['project']
|
|
|
|
return context
|
|
|
|
|
2016-01-26 18:25:20 +00:00
|
|
|
def dispatch(self, request, *args, **kwargs):
|
|
|
|
self.markdown = 'projects/{0}.md'.format(kwargs['project'])
|
|
|
|
return super().dispatch(request, *args, **kwargs)
|