From b0978034b5d96aedf4e29eea2cc2ec125f5b8002 Mon Sep 17 00:00:00 2001 From: Olivier DOSSMANN Date: Sat, 16 Sep 2017 17:42:04 +0200 Subject: [PATCH] Renommage des consoles en plateformes --- CHANGELOG | 1 + README.md | 2 +- TODO | 1 - .../locale/fr/LC_MESSAGES/django.po | 12 +-- collection/collection/urls.py | 4 +- .../conf/locale/fr/LC_MESSAGES/django.po | 92 ++++++++++--------- collection/games/admin.py | 4 +- collection/games/fixtures/initial.yaml | 22 ++--- .../0008_rename_console_to_platform.py | 38 ++++++++ collection/games/models.py | 16 ++-- collection/games/serializers.py | 6 +- collection/games/tests/test_api.py | 36 ++++---- collection/games/tests/test_console.py | 20 ++-- collection/games/tests/test_game.py | 12 +-- collection/games/views.py | 18 ++-- 15 files changed, 164 insertions(+), 120 deletions(-) create mode 100644 collection/games/migrations/0008_rename_console_to_platform.py diff --git a/CHANGELOG b/CHANGELOG index 520fadd..d4df61e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ Current version (0.2) : + - Renommage des consoles en « plateformes » - Activation des requêtes CORS pour permettre à une autre application d'accéder à l'API - MàJ vers Django 1.11.5 - Activation d'une API (pour les consoles) accessible par l'administrateur (avec documentation) diff --git a/README.md b/README.md index 43c6fa8..9550b6b 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ docker run -it --rm -v /openbackloggery_db:/opt/apps/db openbackloggery:0.1 pyth docker run -it --rm -v /openbackloggery_db:/opt/apps/db openbackloggery:0.1 python3 manage.py loaddata initial ``` -*loaddata initial* permet de charger quelques données initiales comme une liste de consoles par exemple. +*loaddata initial* permet de charger quelques données initiales comme une liste de plateformes par exemple. Adaptez la ligne en remplaçant **admin** par le nom d'utilisateur que vous voulez et **admin@domaine.tld** par l'adresse courriel de votre choix (qu'elle existe ou non importe peu pour l'instant car elle n'est pas utilisée). diff --git a/TODO b/TODO index bbe497d..77fbf00 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,5 @@ # À faire - * Renommer "Console" en "Plateforme" * Ajouter des help_text à tous les champs + classes enfants. Les traduire. * étudier la possibilité à l'utilisateur, via des variables d'environnement, de configurer un email, une autre BDD, etc. diff --git a/collection/collection/locale/fr/LC_MESSAGES/django.po b/collection/collection/locale/fr/LC_MESSAGES/django.po index dcfaa58..2c687b8 100644 --- a/collection/collection/locale/fr/LC_MESSAGES/django.po +++ b/collection/collection/locale/fr/LC_MESSAGES/django.po @@ -3,24 +3,24 @@ # This file is distributed under the same license as the openbackloggery package. # Olivier DOSSMANN , 2017. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-31 14:49+0000\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"POT-Creation-Date: 2017-09-16 15:15+0000\n" +"PO-Revision-Date: 2017-09-16 17:16+0200\n" "Last-Translator: Olivier DOSSMANN \n" "Language-Team: \n" -"Language: \n" +"Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.0.3\n" -#: collection/components/i18n.py:8 +#: collection/collection/components/i18n.py:8 msgid "French" msgstr "Français" -#: collection/components/i18n.py:9 +#: collection/collection/components/i18n.py:9 msgid "English" msgstr "Anglais" diff --git a/collection/collection/urls.py b/collection/collection/urls.py index ed2ba35..eac724b 100644 --- a/collection/collection/urls.py +++ b/collection/collection/urls.py @@ -16,7 +16,7 @@ Including another URLconf from django.conf.urls import url, include from django.contrib import admin from collection import __version__ as app_version -from games.views import GameList, ConsoleViewSet +from games.views import GameList, PlatformViewSet from rest_framework import routers from rest_framework.documentation import include_docs_urls @@ -26,7 +26,7 @@ admin.site.site_header = '%s %s' % (admin.site.site_title, app_version) # Django Rest Framework router router = routers.DefaultRouter() -router.register(r'consoles', ConsoleViewSet) +router.register(r'platforms', PlatformViewSet) urlpatterns = [ url(r'^$', GameList.as_view(), name='homepage'), diff --git a/collection/conf/locale/fr/LC_MESSAGES/django.po b/collection/conf/locale/fr/LC_MESSAGES/django.po index e051876..7e78e02 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-09-04 21:24+0000\n" -"PO-Revision-Date: 2017-09-04 23:27+0200\n" +"POT-Creation-Date: 2017-09-16 15:15+0000\n" +"PO-Revision-Date: 2017-09-16 17:17+0200\n" "Last-Translator: \n" "Language-Team: \n" "Language: fr\n" @@ -17,138 +17,144 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 2.0.3\n" -#: core/models.py:7 core/models.py:28 +#: collection/core/models.py:7 collection/core/models.py:28 msgid "name" msgstr "nom" -#: core/models.py:24 +#: collection/core/models.py:24 msgid "New" msgstr "Nouveau" -#: core/models.py:48 core/models.py:80 +#: collection/core/models.py:48 collection/core/models.py:80 msgid "status" msgstr "état" -#: core/models.py:65 +#: collection/core/models.py:65 msgid "date" msgstr "date" -#: games/admin.py:11 +#: collection/games/admin.py:11 msgid "state" msgstr "état" -#: games/admin.py:39 +#: collection/games/admin.py:39 msgid "Game Information" msgstr "Information du jeu" -#: games/admin.py:42 +#: collection/games/admin.py:42 msgid "Progress" msgstr "Progression" -#: games/models.py:15 games/models.py:29 -msgid "console" -msgstr "console" +#: collection/games/models.py:15 collection/games/models.py:29 +msgid "platform" +msgstr "plateforme" -#: games/models.py:16 -msgid "consoles" -msgstr "consoles" +#: collection/games/models.py:16 +msgid "platforms" +msgstr "plateformes" -#: games/models.py:20 -msgid "Most used console name." -msgstr "Nom de console le plus utilisé." +#: collection/games/models.py:20 +msgid "Most used platform name." +msgstr "Nom de plateforme le plus utilisé." -#: games/models.py:40 +#: collection/games/models.py:40 msgid "Beaten" msgstr "Terminé (quête principale)" -#: games/models.py:41 +#: collection/games/models.py:41 msgid "Completed" msgstr "Terminé complètement" -#: games/models.py:42 +#: collection/games/models.py:42 msgid "Excluded" msgstr "Exclu" -#: games/models.py:43 +#: collection/games/models.py:43 msgid "Mastered" msgstr "Usé / Épuisé" -#: games/models.py:44 +#: collection/games/models.py:44 msgid "Unfinished" msgstr "Inachevé" -#: games/models.py:53 +#: collection/games/models.py:53 msgid "Progress note" msgstr "Note de progression" -#: games/models.py:54 +#: collection/games/models.py:54 msgid "Short note displayed to your followers." -msgstr "Courte note affichée à ceux qui vous suive" +msgstr "Courte note affichée à ceux qui vous suive." -#: games/models.py:59 +#: collection/games/models.py:59 msgid "playing?" msgstr "en train d'y jouer ?" -#: games/models.py:60 +#: collection/games/models.py:60 msgid "You're currently playing this game." msgstr "Vous jouez actuellement à ce jeu." -#: games/models.py:63 +#: collection/games/models.py:63 msgid "unplayed?" msgstr "jamais joué ?" -#: games/models.py:64 +#: collection/games/models.py:64 msgid "You never played this game." msgstr "Vous n'avez jamais joué à ce jeu." -#: games/models.py:67 +#: collection/games/models.py:67 msgid "wish?" msgstr "envie de l'avoir ?" -#: games/models.py:68 +#: collection/games/models.py:68 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:72 +#: collection/games/models.py:72 msgid "game" msgstr "jeu" -#: games/models.py:73 +#: collection/games/models.py:73 msgid "games" msgstr "jeux" -#: games/models.py:84 +#: collection/games/models.py:84 msgid "Timeline" msgstr "Chronologie" -#: games/models.py:85 +#: collection/games/models.py:85 msgid "Timelines" msgstr "Chronologies" -#: games/templates/games/index.html:5 +#: collection/games/templates/games/index.html:5 msgid "Games" msgstr "Jeux" -#: games/templates/games/index.html:6 +#: collection/games/templates/games/index.html:6 msgid "Now playing" msgstr "En train d'y jouer" -#: games/templates/games/index.html:15 +#: collection/games/templates/games/index.html:15 msgid "No playing game found." msgstr "Aucun jeu en cours." -#: games/templates/games/index.html:17 +#: collection/games/templates/games/index.html:17 msgid "Complete list" msgstr "Liste complète" -#: games/templates/games/index.html:25 +#: collection/games/templates/games/index.html:25 msgid "No game found." msgstr "Aucun jeu." -#: games/templates/games/index.html:27 +#: collection/games/templates/games/index.html:27 msgid "Memory Card" msgstr "Carte mémoire" -#: games/templates/games/index.html:43 +#: collection/games/templates/games/index.html:43 msgid "Empty memory." msgstr "Mémoire vide." + +#~ msgid "console" +#~ msgstr "console" + +#~ msgid "consoles" +#~ msgstr "consoles" diff --git a/collection/games/admin.py b/collection/games/admin.py index e13bdab..8412e80 100644 --- a/collection/games/admin.py +++ b/collection/games/admin.py @@ -1,7 +1,7 @@ from django.contrib import admin from django.utils.translation import ugettext as _ from games.forms import GameForm -from games.models import Console, Game, Timeline +from games.models import Game, Platform, Timeline class StatusFilter(admin.SimpleListFilter): @@ -56,6 +56,6 @@ class TimelineAdmin(admin.ModelAdmin): 'date', 'status', 'item') -admin.site.register(Console) +admin.site.register(Platform) admin.site.register(Game, GameAdmin) admin.site.register(Timeline, TimelineAdmin) diff --git a/collection/games/fixtures/initial.yaml b/collection/games/fixtures/initial.yaml index f9419d6..96966bc 100644 --- a/collection/games/fixtures/initial.yaml +++ b/collection/games/fixtures/initial.yaml @@ -1,44 +1,44 @@ -- model: games.console +- model: games.platform pk: 1 fields: name: Steam -- model: games.console +- model: games.platform pk: 2 fields: name: Game Boy -- model: games.console +- model: games.platform pk: 3 fields: name: Nintendo 3DS -- model: games.console +- model: games.platform pk: 4 fields: name: Nintendo Switch -- model: games.console +- model: games.platform pk: 5 fields: name: PC -- model: games.console +- model: games.platform pk: 6 fields: name: Genesis / Mega Drive -- model: games.console +- model: games.platform pk: 7 fields: name: Nintendo Entertainment System -- model: games.console +- model: games.platform pk: 8 fields: name: PlayStation -- model: games.console +- model: games.platform pk: 9 fields: name: PlayStation 3 -- model: games.console +- model: games.platform pk: 10 fields: name: PlayStation 4 -- model: games.console +- model: games.platform pk: 11 fields: name: Wii diff --git a/collection/games/migrations/0008_rename_console_to_platform.py b/collection/games/migrations/0008_rename_console_to_platform.py new file mode 100644 index 0000000..2bf4d76 --- /dev/null +++ b/collection/games/migrations/0008_rename_console_to_platform.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.5 on 2017-09-16 15:05 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('games', '0007_help_text_on_console_name'), + ] + + operations = [ + migrations.RenameModel( + old_name='Console', + new_name='Platform', + ), + migrations.AlterField( + model_name='game', + name='collection', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='games', to='games.Platform', verbose_name='platform'), + ), + migrations.AlterModelOptions( + name='Platform', + options={ + 'verbose_name': 'platform', + 'verbose_name_plural': 'platforms', + 'ordering': ('name',), + }, + ), + migrations.AlterField( + model_name='platform', + name='name', + field=models.CharField(help_text='Most used platform name.', max_length=255, verbose_name='nom'), + ), + ] diff --git a/collection/games/models.py b/collection/games/models.py index 739c5ab..8633e25 100644 --- a/collection/games/models.py +++ b/collection/games/models.py @@ -3,30 +3,30 @@ from django.db import models from django.utils.translation import ugettext as _ -class Console(Collection): +class Platform(Collection): """ - All console, system or box that can be used to play video games. + All platform, system or box that can be used to play video games. """ def __str__(self): return '%s' % self.name class Meta: ordering = ('name',) - verbose_name = _('console') - verbose_name_plural = _('consoles') + verbose_name = _('platform') + verbose_name_plural = _('platforms') # Redefine help_text (for documentation, API, etc.) -Console._meta.get_field('name').help_text = _('Most used console name.') +Platform._meta.get_field('name').help_text = _('Most used platform name.') class Game(Item): """ - A video game you will use on a specific Console. + A video game you will use on a specific Platform. """ # class config - TARGET_MODEL = 'games.Console' - TARGET_VERBOSE_NAME = _('console') + TARGET_MODEL = 'games.Platform' + TARGET_VERBOSE_NAME = _('platform') RELATED_TARGET_NAME = 'games' # Status choices diff --git a/collection/games/serializers.py b/collection/games/serializers.py index 6cc4b7c..771918f 100644 --- a/collection/games/serializers.py +++ b/collection/games/serializers.py @@ -1,8 +1,8 @@ -from games.models import Console +from games.models import Platform from rest_framework import serializers -class ConsoleSerializer(serializers.ModelSerializer): +class PlatformSerializer(serializers.ModelSerializer): class Meta: - model = Console + model = Platform fields = ('name',) diff --git a/collection/games/tests/test_api.py b/collection/games/tests/test_api.py index bf9f531..34f8506 100644 --- a/collection/games/tests/test_api.py +++ b/collection/games/tests/test_api.py @@ -1,12 +1,12 @@ from django.contrib.auth.models import User from django.urls import reverse -from games.models import Console +from games.models import Platform from rest_framework import status from rest_framework.test import APITestCase, force_authenticate import json -class ConsoleTest(APITestCase): +class PlatformTest(APITestCase): @classmethod def setUpTestData(cls): @@ -15,31 +15,31 @@ class ConsoleTest(APITestCase): 'admin@localhost', 'admin') - def test_create_console(self): + def test_create_platform(self): """ - Check we can create a console object. + Check we can create a platform object. """ - url = reverse('console-list') + url = reverse('platform-list') data = {'name': 'GP2X'} self.client.force_authenticate(user=self.superuser) response = self.client.post(url, data, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) - self.assertEqual(Console.objects.count(), 1) - self.assertEqual(Console.objects.get().name, 'GP2X') + self.assertEqual(Platform.objects.count(), 1) + self.assertEqual(Platform.objects.get().name, 'GP2X') - def test_sorted_console(self): + def test_sorted_platform(self): """ - Check that console list is sorted. + Check that platform list is sorted. """ - Console.objects.create(name='GP2X') - Console.objects.create(name='3DS') - Console.objects.create(name='Game Boy') - Console.objects.create(name='Amiga') - url = reverse('console-list') + Platform.objects.create(name='GP2X') + Platform.objects.create(name='3DS') + Platform.objects.create(name='Game Boy') + Platform.objects.create(name='Amiga') + url = reverse('platform-list') self.client.force_authenticate(user=self.superuser) response = self.client.get(url, format='json') - sorted_consoles = list( - Console.objects.all().order_by('name').values_list( + sorted_platforms = list( + Platform.objects.all().order_by('name').values_list( 'name', flat=True)) - consoles = [x.get('name') for x in json.loads(response.content)] - self.assertEqual(consoles, sorted_consoles) + platforms = [x.get('name') for x in json.loads(response.content)] + self.assertEqual(platforms, sorted_platformss) diff --git a/collection/games/tests/test_console.py b/collection/games/tests/test_console.py index f43c8df..50390c5 100644 --- a/collection/games/tests/test_console.py +++ b/collection/games/tests/test_console.py @@ -1,20 +1,20 @@ from django.test import TestCase -from games.models import Console +from games.models import Platform -class ConsoleTest(TestCase): +class PlatformTest(TestCase): """ - Console Model + Platform Model """ def setUp(self): - Console.objects.create(name='GP2X') - Console.objects.create(name='3DS') + Platform.objects.create(name='GP2X') + Platform.objects.create(name='3DS') - def test_console_are_sorted_by_name(self): - consoles = list(Console.objects.all().values_list('name', flat=True)) - sorted_consoles = list( - Console.objects.all().order_by('name').values_list( + def test_platform_are_sorted_by_name(self): + platforms = list(Platform.objects.all().values_list('name', flat=True)) + sorted_platforms = list( + Platform.objects.all().order_by('name').values_list( 'name', flat=True)) - self.assertEqual(consoles, sorted_consoles) + self.assertEqual(platforms, sorted_platforms) diff --git a/collection/games/tests/test_game.py b/collection/games/tests/test_game.py index b966fae..dfb5d53 100644 --- a/collection/games/tests/test_game.py +++ b/collection/games/tests/test_game.py @@ -1,5 +1,5 @@ from django.test import TestCase -from games.models import Console, Game +from games.models import Game, Platform class GameTest(TestCase): @@ -8,20 +8,20 @@ class GameTest(TestCase): """ def setUp(self): - self.console = Console.objects.create(name='BestConsole4Ever') + self.platform = Platform.objects.create(name='BestPlatform4Ever') Game.objects.create( name='Deponia', playing=True, - collection=self.console, + collection=self.platform, status=Game.EXCLUDED) Game.objects.create( - name='Aladdin', playing=True, collection=self.console) + name='Aladdin', playing=True, collection=self.platform) Game.objects.create( - name='Persona 5', playing=True, collection=self.console) + name='Persona 5', playing=True, collection=self.platform) Game.objects.create( name='The Witcher III', playing=False, - collection=self.console, + collection=self.platform, wish=True) self.index_url = '/games/' diff --git a/collection/games/views.py b/collection/games/views.py index 5eea4e4..a61f347 100644 --- a/collection/games/views.py +++ b/collection/games/views.py @@ -1,25 +1,25 @@ from django.db.models import Q from django.views.generic import ListView from rest_framework import viewsets -from .serializers import ConsoleSerializer +from .serializers import PlatformSerializer -from .models import Console, Game, Timeline +from .models import Game, Platform, Timeline -class ConsoleViewSet(viewsets.ModelViewSet): +class PlatformViewSet(viewsets.ModelViewSet): """ - API endpoints that allows consoles to be edited or viewed. + API endpoints that allows platforms to be edited or viewed. retrieve: - Return the given console + Return the given platform list: - Return a list of all existing consoles ordered by name. + Return a list of all existing platforms ordered by name. create: - Create a new console instance. + Create a new platform instance. """ - queryset = Console.objects.all().order_by('name') - serializer_class = ConsoleSerializer + queryset = Platform.objects.all().order_by('name') + serializer_class = PlatformSerializer class GameList(ListView):