1
Fork 0

Store details in JSON

This commit is contained in:
Jake Howard 2016-03-15 21:55:36 +00:00
parent 5cf2443b28
commit 9dbd4da58f
3 changed files with 29 additions and 11 deletions

10
data/projects.json Normal file
View file

@ -0,0 +1,10 @@
{
"hipchat-emoticons-for-all": {
"title": "Hipchat Emoticons Plugin",
"image": "https://hipchat-magnolia-cdn.atlassian.com/assets/img/hipchat/hipchat_og_image.jpg"
},
"attack-on-blocks": {
"title": "Attack on Blocks Game",
"image": "https://image.freepik.com/free-vector/space-invaders-game_62147502273.jpg"
}
}

View file

@ -1,18 +1,20 @@
from collections import namedtuple
from project.common.views import CustomTemplate, MarkdownView from project.common.views import CustomTemplate, MarkdownView
from json import load
from django.conf import settings
import os.path
ProjectDetails = namedtuple('ProjectDetails', ['title', 'image']) PROJECT_DETAILS = load(open(os.path.join(settings.BASE_DIR, 'data/projects.json')))
PROJECT_DETAILS = {
'hipchat-emoticons-for-all': ProjectDetails('Hipchat Emoticons Plugin', 'https://hipchat-magnolia-cdn.atlassian.com/assets/img/hipchat/hipchat_og_image.jpg'),
'attack-on-blocks': ProjectDetails('Attack on Blocks Game', 'https://image.freepik.com/free-vector/space-invaders-game_62147502273.jpg')
}
class AllView(CustomTemplate): class AllView(CustomTemplate):
template_name = 'projects/all.html' template_name = 'projects/all.html'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['projects'] = PROJECT_DETAILS
return context
class ProjectView(MarkdownView): class ProjectView(MarkdownView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):

View file

@ -3,8 +3,14 @@
{% block pageTitle %}All Projects{% endblock %} {% block pageTitle %}All Projects{% endblock %}
{% block content %} {% block content %}
<div class="row">
<div class="container"> <div class="container all-projects">
<p>Stuff</p> {% for key, project in projects.items %}
<div class="">
<img src="{{ project.image }}">
<h5>{{ project.title }}
</div>
{% endfor %}
</div>
</div> </div>
{% endblock %} {% endblock %}