Skip to content

Commit

Permalink
Added Best Game Forever Feature (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecourtial authored Aug 5, 2021
1 parent bc361d3 commit 7ae820c
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ todo list, watch list, ranking...

## Changelog

### 3.3.0
* Added a new feature: "Best Game Forever". Different from the hall of fames. BGF games are still valuable today, while some entries in the HOF were valuable only at time.

### 3.2.0
* Added a blacktheme (the white one is no longer applied).
* Added a "Has the box" badge when we have the original box (not a re-edition).
Expand Down
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
configurationData = json.load(json_file)

# DB connection
db_factory = MySQLFactory.init(
MySQLFactory.init(
configurationData['db_host'],
configurationData['db_user'],
configurationData['db_password'],
Expand Down
2 changes: 1 addition & 1 deletion docker/python/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:latest
FROM python:3.7

# expose to nginx
EXPOSE 9000
Expand Down
3 changes: 2 additions & 1 deletion games_empty.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# Hôte: 0.0.0.0 (MySQL 5.7.29)
# Base de données: games
# Temps de génération: 2021-05-17 19:05:05 +0000
# Temps de génération: 2021-08-05 12:36:24 +0000
# ************************************************************


Expand Down Expand Up @@ -65,6 +65,7 @@ CREATE TABLE `games_meta` (
`comments` text,
`todo_with_help` tinyint(3) unsigned NOT NULL DEFAULT '0',
`has_box` tinyint(3) unsigned NOT NULL DEFAULT '0',
`bgf` tinyint(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`game_id`),
CONSTRAINT `games_meta_ibfk_1` FOREIGN KEY (`game_id`) REFERENCES `games` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
Expand Down
12 changes: 8 additions & 4 deletions src/repository/game_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class GameRepository(AbstractRepository):
'to_rewatch',
'to_buy',
'original',
'ongoing'
'ongoing',
'bgf'
]

random_cases = [
Expand Down Expand Up @@ -152,8 +153,9 @@ def insert(self, title, platform, form_content):
request += "many, top_game,"
request += "hall_of_fame, hall_of_fame_year,"
request += "hall_of_fame_position, played_it_often, ongoing, comments, todo_with_help"
request += ", has_box) "
request += "VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s, %s, %s, %s)"
request += ", has_box, bgf) "
request += "VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s, %s, %s, %s"
request += ", %s)"

self.write(request, meta)

Expand Down Expand Up @@ -186,7 +188,8 @@ def update(self, game_id, title, platform, form_content):
request += "ongoing=%s, "
request += "comments=%s, "
request += "todo_with_help=%s, "
request += "has_box=%s "
request += "has_box=%s, "
request += "bgf=%s "
request += "WHERE game_id = %s"

self.write(request, meta)
Expand Down Expand Up @@ -218,6 +221,7 @@ def get_meta_form_request(cls, game_id, form_content, operation):
form_content['comments'],
form_content['todo_with_help'],
form_content['has_box'],
form_content['bgf'],
)

if operation == 'INSERT':
Expand Down
Binary file added static/images/diamond.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions static/js/pages/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ define(
gameEntry += ' <img title="Dans le hall of fame" src="' + hallOfFameImageUrl + '"/>'
}


if (value.meta.bgf === 1) {
gameEntry += ' <img title="Membre des Best Games Forever" src="' + diamondImageUrl + '"/>'
}

if (value.meta.top_game === 1) {
gameEntry += ' <img title="Top jeu" src="' + topImageUrl + '"/>'
}
Expand Down
8 changes: 7 additions & 1 deletion static/js/pages/games.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ define(
'to_watch_serious': "A regarder sérieusement",
'to_rewatch': "A regarder à nouveau parfois",
'ongoing': "En cours",
'bgf': "Best Games Forever",
};

if (context in correspondence) {
Expand All @@ -79,7 +80,8 @@ define(
getSubtitle: function(context) {
var correspondence = {
"singleplayer_recurring": "Top jeux, jouables par intermittence (prendre des notes)",
'todo_solo_sometimes': "Top jeux, jouable de courts moments de temps en temps OU jeux d'aventures à faire d'une traite"
"todo_solo_sometimes": "Top jeux, jouable de courts moments de temps en temps OU jeux d'aventures à faire d'une traite",
"bgf": "Pépites qui malgré le temps restent des merveilles qui nous tiennent à coeur (différent du Hall Of Fames qui est dans le contexte de l'époque)"
};

if (context in correspondence) {
Expand All @@ -102,6 +104,10 @@ define(
gameEntry += ' <img title="Dans le hall of fame" src="' + hallOfFameImageUrl + '"/>'
}

if (value.meta.bgf === 1) {
gameEntry += ' <img title="Membre des Best Games Forever" src="' + diamondImageUrl + '"/>'
}

if (value.meta.top_game === 1) {
gameEntry += ' <img title="Top jeu" src="' + topImageUrl + '"/>'
}
Expand Down
7 changes: 7 additions & 0 deletions templates/general/game-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@
required
/>
</p>
<p>
<label for="bgf">Best Game Forever ?</label>
<select id="bgf" name="bgf">
<option value="0" {%- if game and game.get_meta()['bgf'] == 0 -%} selected {% endif %}>Non</option>
<option value="1" {%- if game and game.get_meta()['bgf'] == 1 -%} selected {% endif %}>Oui</option>
</select>
</p>
<p>
<label for="ongoing">En cours</label>
<select id="ongoing" name="ongoing">
Expand Down
1 change: 1 addition & 0 deletions templates/general/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<li><a id="random-multiplayer_random" href="" >Un multi au hasard</a></li>
</ul>
</li>
<li><a class="nav-li" id="special-list-bgf" href="">Best Games Forever</a></li>
<li><a class="nav-li" id="platforms" href="" >Par support</a></li>
<li class="dropdown">
<a class="nav-li" href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
Expand Down
1 change: 1 addition & 0 deletions templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ <h1 id="contentTitle">{{ content_title }}</h1>
var toBuyImageUrl = "{{ url_for('static', filename='images/to-buy.png') }}";
var withHelpImageUrl = "{{ url_for('static', filename='images/help.png') }}";
var hasBoxImageUrl = "{{ url_for('static', filename='images/box.png') }}";
var diamondImageUrl = "{{ url_for('static', filename='images/diamond.png') }}";

// API URLs
var hallOfFameUrl = "{{ url_for('get_home_content') }}";
Expand Down

0 comments on commit 7ae820c

Please sign in to comment.