-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring for better clarity, and removable of obsolete code.
- Loading branch information
Showing
4 changed files
with
29 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .main import index | ||
from .main import game | ||
from .main import index_online_shops | ||
from .main import online_shop | ||
from .viewAGame import game | ||
from .indexOnlineShop import index_online_shops | ||
from .indexOnlineShop import online_shop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django.shortcuts import render | ||
from django.shortcuts import get_object_or_404 | ||
|
||
from ..models import Online_Shop | ||
|
||
# TODO: pushed in a different file | ||
def index_online_shops(request): | ||
latest_shops = Online_Shop.objects.order_by("-date_creation")[:5] | ||
context = {"latest_shops": latest_shops} | ||
return render(request, "thefiltershop/index_online_shops.html", context) | ||
|
||
def online_shop(request, shop_id): | ||
a_game = get_object_or_404(Online_Shop, pk=shop_id) | ||
return render(request, "thefiltershop/online_shop.html", {"a_shop": a_game}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
from django.shortcuts import render | ||
from django.http import HttpResponse | ||
from django.template import loader | ||
from django.shortcuts import get_object_or_404 | ||
|
||
from ..models import Videogame_common | ||
from ..models import Studio | ||
from ..models import Publisher | ||
from ..models import Filter | ||
|
||
def index(request): | ||
# For small studio first | ||
#smallest_studio = Studio.objects.order_by("-known_popularity").order_by("-spotlight_count")[:5] | ||
def game(request, videogame_id): | ||
a_game = get_object_or_404(Videogame_common, pk=videogame_id) | ||
negative_filters = Filter.objects.filter(valueforfilter__for_entity__pk = a_game.pk, valueforfilter__filter__is_positive=False) | ||
positive_filters = Filter.objects.filter(valueforfilter__for_entity__pk = a_game.pk, valueforfilter__filter__is_positive=True) | ||
|
||
# also with no publisher or a small one | ||
# Find the game with lowest time in the spotlight, and the fewer (bad) filters. Give a bonus for good filters | ||
latest_games = Videogame_common.objects.filter(Videogame_common.studios_set__size <= 5).filter(Videogame_common.publishers_set__size <= 5).order_by("-known_popularity").order_by("-spotlight_count")[:5] | ||
for aGame in latest_games: | ||
aGame.spotlight_count+=1 | ||
aGame.save() | ||
|
||
context = {"latest_games": latest_games} | ||
return render(request, "thefiltershop/index.html", context) | ||
return render(request, "thefiltershop/game.html", {"a_game": a_game, "title_image": a_game.image_set.first(), "screenshots": a_game.image_set.all()[2:], | ||
"negative_filters": negative_filters, "positive_filters": positive_filters}) | ||
|