From 5867d701118479005911ba5f30bcfdd3b99cc12f Mon Sep 17 00:00:00 2001 From: Olivier DOSSMANN Date: Thu, 31 Aug 2017 15:20:08 +0200 Subject: [PATCH] Ajout d'une page d'accueil listant la collection --- .../locale/fr/LC_MESSAGES/django.po | 2 +- collection/collection/urls.py | 6 ++- .../conf/locale/fr/LC_MESSAGES/django.po | 44 +++++++++++++------ collection/core/templates/base.html | 11 +++++ collection/games/templates/games/index.html | 23 ++++++++++ collection/games/urls.py | 7 +++ collection/games/views.py | 22 +++++++++- 7 files changed, 96 insertions(+), 19 deletions(-) create mode 100644 collection/core/templates/base.html create mode 100644 collection/games/templates/games/index.html create mode 100644 collection/games/urls.py diff --git a/collection/collection/locale/fr/LC_MESSAGES/django.po b/collection/collection/locale/fr/LC_MESSAGES/django.po index a2974ff..ab1557d 100644 --- a/collection/collection/locale/fr/LC_MESSAGES/django.po +++ b/collection/collection/locale/fr/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-25 22:18+0000\n" +"POT-Creation-Date: 2017-08-31 13:13+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Olivier DOSSMANN \n" "Language-Team: \n" diff --git a/collection/collection/urls.py b/collection/collection/urls.py index 9522944..d011295 100644 --- a/collection/collection/urls.py +++ b/collection/collection/urls.py @@ -13,15 +13,17 @@ Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ -from django.conf.urls import url +from django.conf.urls import url, include from django.contrib import admin from collection import __version__ as app_version - +from games.views import GameList # Admin config admin.site.site_title = 'OpenBackloggery' admin.site.site_header = '%s %s' % (admin.site.site_title, app_version) urlpatterns = [ + url(r'^$', GameList.as_view(), name='homepage'), + url(r'^games/', include('games.urls', namespace='games'), name='games'), url(r'^admin/', admin.site.urls), ] diff --git a/collection/conf/locale/fr/LC_MESSAGES/django.po b/collection/conf/locale/fr/LC_MESSAGES/django.po index 6cc58a7..aaec4a2 100644 --- a/collection/conf/locale/fr/LC_MESSAGES/django.po +++ b/collection/conf/locale/fr/LC_MESSAGES/django.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-25 22:18+0000\n" -"PO-Revision-Date: 2017-08-26 00:21+0200\n" +"POT-Creation-Date: 2017-08-31 13:13+0000\n" +"PO-Revision-Date: 2017-08-31 15:15+0200\n" "Last-Translator: \n" "Language-Team: \n" "Language: fr\n" @@ -73,50 +73,66 @@ msgstr "Usé / Épuisé" msgid "Unfinished" msgstr "Inachevé" -#: games/models.py:48 +#: games/models.py:49 msgid "Progress note" msgstr "Note de progression" -#: games/models.py:49 +#: games/models.py:50 msgid "Short note displayed to your followers." msgstr "Courte note affichée à ceux qui vous suive" -#: games/models.py:54 +#: games/models.py:55 msgid "playing?" msgstr "en train d'y jouer ?" -#: games/models.py:55 +#: games/models.py:56 msgid "You're currently playing this game." msgstr "Vous jouez actuellement à ce jeu." -#: games/models.py:58 +#: games/models.py:59 msgid "unplayed?" msgstr "jamais joué ?" -#: games/models.py:59 +#: games/models.py:60 msgid "You never played this game." msgstr "Vous n'avez jamais joué à ce jeu." -#: games/models.py:62 +#: games/models.py:63 msgid "wish?" msgstr "envie de l'avoir ?" -#: games/models.py:63 +#: games/models.py:64 msgid "You're waiting X-mas father offers you this game." msgstr "Vous patientez que le père Noël vous offre ce jeu." -#: games/models.py:67 +#: games/models.py:68 msgid "game" msgstr "jeu" -#: games/models.py:68 +#: games/models.py:69 msgid "games" msgstr "jeux" -#: games/models.py:79 +#: games/models.py:80 msgid "Timeline" msgstr "Chronologie" -#: games/models.py:80 +#: games/models.py:81 msgid "Timelines" msgstr "Chronologies" + +#: games/templates/games/index.html:5 +msgid "Games" +msgstr "Jeux" + +#: games/templates/games/index.html:6 +msgid "Now playing" +msgstr "En train d'y jouer" + +#: games/templates/games/index.html:15 +msgid "No playing game found." +msgstr "Aucun jeu en cours." + +#: games/templates/games/index.html:17 +msgid "Complete list" +msgstr "Liste complète" diff --git a/collection/core/templates/base.html b/collection/core/templates/base.html new file mode 100644 index 0000000..c0081bd --- /dev/null +++ b/collection/core/templates/base.html @@ -0,0 +1,11 @@ + +{% load i18n %}{% get_current_language as LANGUAGE_CODE %} + + + OpenBackloggery + + +{% block content %} +{% endblock %} + + \ No newline at end of file diff --git a/collection/games/templates/games/index.html b/collection/games/templates/games/index.html new file mode 100644 index 0000000..d9e699b --- /dev/null +++ b/collection/games/templates/games/index.html @@ -0,0 +1,23 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block content %} +

{% trans "Games" %}

+

{% trans "Now playing" %}

+ {% if playing_games %} + + {% else %} +

{% trans "No playing game found." %}

+ {% endif %} +

{% trans "Complete list" %}

+ +{% endblock %} \ No newline at end of file diff --git a/collection/games/urls.py b/collection/games/urls.py new file mode 100644 index 0000000..a62f92f --- /dev/null +++ b/collection/games/urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import url +from . import views + + +urlpatterns = [ + url(r'$', views.GameList.as_view()), +] \ No newline at end of file diff --git a/collection/games/views.py b/collection/games/views.py index 91ea44a..a3ca2f9 100644 --- a/collection/games/views.py +++ b/collection/games/views.py @@ -1,3 +1,21 @@ -from django.shortcuts import render +from django.db.models import Q +from django.views.generic import ListView +from django.utils.translation import ugettext as _ -# Create your views here. +from .models import Game + + +class GameList(ListView): + model = Game + context_object_name = 'non_excluded_games' + template_name = 'games/index.html' + queryset = Game.objects.filter(~Q(status=Game.EXCLUDED)).order_by('name') + + def get_context_data(self, **kwargs): + """ + Add playing games list + """ + context = super(GameList, self).get_context_data(**kwargs) + context['playing_games'] = Game.objects.filter( + playing=True).order_by('name') + return context \ No newline at end of file