Kevin Veroneau avatar Kevin Veroneau committed 75f5299 Draft

Added ability to view a game.

Comments (0)

Files changed (4)

         (40, 'Beta'),
         (200, 'Final'),
     )
-    game_file = models.FileField(upload_to='games')
+    game_file = models.FileField(upload_to='games', blank=True, null=True)
+    #game_url = models.URLField(blank=True, null=True)
     title = models.CharField(max_length=128)
     version = models.PositiveIntegerField()
     classification = models.PositiveSmallIntegerField(choices=GAME_WORKFLOW, help_text='What classification does this release fall under?')
         if self.author == '':
             self.author = self.owner.username
         return super(Game, self).save(**kwargs)
+    def first_screenshot(self):
+        return self.screenshots.all()[0].image.url

gamedb/templates/gamedb/game_detail.html

+{% extends "base.html" %}
+
+{% block content %}
+<div class="row-fluid">
+  <div class="span5">
+    <center>
+      <h3>{{game.title}}</h3>
+      <img src="{{game.first_screenshot}}"/>
+    </center>
+    <div class="alert alert-info">Description</div>
+    {{game.description}}
+    <div class="alert alert-info">Storyline</div>
+    {{game.storyline}}
+    <div class="alert alert-info">Credits</div>
+    <table class="table">
+      <tbody>
+        <tr><th>Scenario:</th><td>{% for author in game.scenario.all %}<a href="#">{{author}}</a>{% endfor %}</td></tr>
+        <tr><th>Graphics:</th><td>{% for author in game.graphics.all %}<a href="#">{{author}}</a>{% endfor %}</td></tr>
+        <tr><th>Music:</th><td>{% for author in game.music.all %}<a href="#">{{author}}</a>{% endfor %}</td></tr>
+        <tr><th>Sound FX:</th><td>{% for author in game.sfx.all %}<a href="#">{{author}}</a>{% endfor %}</td></tr>
+      </tbody>
+    </table>
+    <div class="alert alert-info">More Screenshots</div>
+    <ul class="thumbnails">
+    {% for screenshot in game.screenshots.all %}
+      <li class="span4"> 
+        <img class="pull-left" src="{{screenshot.image.url}}"/>
+        <h3>{{screenshot.title}}</h3>
+      </li>
+    {% endfor %}
+    </ul>
+  </div>
+  <div class="span3">
+    <div class="alert alert-info">Game Title</div>
+    {{game.title}}
+    <div class="alert alert-info">Game Type</div>
+    {{game.get_game_type_display}}
+    <div class="alert alert-info">Game Genre</div>
+    {{game.get_genre_display}}
+    <div class="alert alert-info">Game Style</div>
+    {{game.get_style_display}}
+    <div class="alert alert-info">Engine Version used</div>
+    {{game.engine}}
+    <div class="alert alert-info">Download this game</div>
+      {% for download in game.downloads.all %}
+        <a href="#">{{download}}</a><br/>
+        <i>Downloaded {{download.download_count}} times.</i>
+      {% endfor %}
+    <div class="alert alert-info">Player comments</div>
+    <a href="#">View Comments</a>
+    <div class="alert alert-info">Date Added</div>
+    {{game.date_added|date:'l F jS, Y'}}
+    <div class="alert alert-info">Date Updated</div>
+    {{game.updated_on|date:'l F jS, Y'}}
+    </div>
+</div>
+{% endblock %}
 from django.conf.urls import patterns, url
 from django.views.generic.base import TemplateView
+from gamedb.views import ViewGame
 
 urlpatterns = patterns('',
-    url(r'^$', TemplateView.as_view(template_name='base.html')),
+    url(r'^$', ViewGame.as_view()),
 )
-# Create your views here.
+from django.views.generic.detail import DetailView
+from gamedb.models import Game
+
+class ViewGame(DetailView):
+    model = Game
+    def get_object(self, queryset=None):
+        return Game.objects.get(pk=1)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.