Skip to content

Commit

Permalink
Order games by known popularity.
Browse files Browse the repository at this point in the history
Made filters looking like filter
Made full game boxes the hyperlink.
  • Loading branch information
abecam committed Oct 21, 2023
1 parent 5fc2f8f commit f6bad24
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 69 deletions.
2 changes: 2 additions & 0 deletions thefiltershop/filtershop_main/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,8 @@ def get_review_count(modeladmin, request, one_entry):
video_game = models.Videogame_common.objects.all().get(name=one_entry.name)
if reviewCountContent > 200 :
reviewCountContent = 200
if reviewCountContent < 11 :
reviewCountContent = 0
video_game.known_popularity = reviewCountContent / 2
video_game.save()
return True
Expand Down
139 changes: 133 additions & 6 deletions thefiltershop/filtershop_main/static/thefiltershop/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ body {
}

a {
border: 2px solid #bbd6d8;
border-radius: 5px;
background: #bbd6d8;
text-decoration: none;
border: 2px solid #bbd6d8;
border-radius: 5px;
background: #bbd6d8;
text-decoration: none;
}

/* visited link */
Expand All @@ -46,11 +46,12 @@ a:visited {
background: #c6e8eb;
}

.image_link a {
border: 2px solid #cfcfcf;
.image_link {
border: 0px solid #cfcfcf;
border-radius: 0px;
background: none;
text-decoration: none;
text-align: center;
}

img {
Expand Down Expand Up @@ -122,4 +123,130 @@ a:visited {
gap: 1rem;
align-items: center;
justify-content: center;
}

.positive_filter {
display: inline-block;
position: relative;
width: 100%;
height: 70px;
background: none;
border: none;
border-radius: 0%;
font-weight: normal;
font-size: 24px;
margin: 0px;
color:rgb(23, 127, 218);
text-shadow: 1px 1px#cfcfcf;
padding: 0%;
vertical-align: middle;
}

.positive_filter img {
position: absolute;
max-width: 100%;
height: 100%;
top: 0%;
left: 0%;
padding: 0%;
}

.positive_filter .filter_name {
display: table-cell;
position: absolute;
width: 100%;
height: 100%;
top: 30%;
left: 20%;
padding: 0%;
}

.positive_filter .filter_name a {
border: none;
border-radius: none;
background: none;
text-decoration: none;
color:rgb(23, 127, 218);
}

.positive_filter details {
display: table-cell;
position: absolute;
top: 25%;
left: 30%;
padding: 0%;
vertical-align: middle;
}

.positive_filter details span {
position: relative;
width: 100%;
height: 100%;
top: 15%;
left: 0%;
padding: 0%;
color:rgb(17, 85, 131);
}

.negative_filter {
display: inline-block;
position: relative;
width: 100%;
height: 70px;
background: none;
border: none;
border-radius: 0%;
font-weight: normal;
font-size: 24px;
margin: 0px;
color:#e9e9e9;
text-shadow: 1px 1px #7c7c7c;
padding: 0%;
vertical-align: middle;
}

.negative_filter img {
position: absolute;
max-width: 100%;
height: 100%;
top: 0%;
left: 0%;
padding: 0%;
}

.negative_filter .filter_name {
display: table-cell;
position: absolute;
width: 100%;
height: 100%;
top: 30%;
left: 20%;
padding: 0%;
}

.negative_filter .filter_name a {
border: none;
border-radius: none;
background: none;
text-decoration: none;
color:#e9e9e9;
}

.negative_filter details {
display: table-cell;
position: absolute;
top: 25%;
left: 30%;
padding: 0%;
vertical-align: middle;
}

.negative_filter details span {
position: relative;
width: 100%;
height: 100%;
top: 15%;
left: 0%;
padding: 0%;
color:rgb(122, 33, 33);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% load static %}
{% if not no_button %}
<!-- A Button will switch between the filters up or down -->
<script>
<!-- Small logic to toggle visibility-->
Expand Down Expand Up @@ -31,62 +33,41 @@
}
}
</script>
{% endif %}
{% if is_on_top and is_filter and not no_button %}
<button class="button_toggle_filters_pos" onclick="toggleVisibilityFilters('event')" id="button_toggle_filters_pos">Show filters at the end</button>
{% endif %}
<div class="filters">
{% if is_on_top %}
<div class="negative_filters">
<div class="negative_filters" style="display: block;">
{% else %}
<div class="positive_filters">
<div class="positive_filters" style="display: block;" >
{% endif %}
{% for filter in positive_filters %}
<div class="positive_filter">{{ filter.name }}
<div class="filter_description">
<div class="positive_filter">
<img src="{% static 'images/FilterGreen.png' %}" alt="Green Filter" class="positive_filter_img">
<div class="filter_name">
<a href={% url 'filtershop_games:one_filter' filter.id %}>{{ filter.name }}</a>
</div>
<details>
<summary>More details</summary>
<span>{{ filter.description }}</span>
</details>
</div>
</div>
{% endfor %}
{% for filter in negative_filters %}
<div class="negative_filter">{{ filter.name }}
<div class="filter_description">
<details>
<summary>More details</summary>
<span>{{ filter.description }}</span>
</details>
<div class="negative_filter">
<img src="{% static 'images/FilterRed.png' %}" alt="Red Filter" class="negative_filter_img">
<div class="filter_name">
<a href={% url 'filtershop_games:one_filter' filter.id %}>{{ filter.name }}</a>
</div>
<details>
<summary>More details</summary>
<span>{{ filter.description }}</span>
</details>
</div>
{% endfor %}
</div>
{% if is_on_top %}
<div class="positive_filters">
{% else %}
<div class="negative_filters">
{% endif %}
{% for filter in positive_filters %}
<div class="positive_filter">{{ filter.name }}
<div class="filter_description">
<details>
<summary>More details</summary>
<span>{{ filter.description }}</span>
</details>
</div>
</div>
{% endfor %}
{% for filter in positive_filters %}
<div class="positive_filter">{{ filter.name }}
<div class="filter_description">
<details>
<summary>More details</summary>
<span>{{ filter.description }}</span>
</details>
</div>
</div>
{% endfor %}
</div>
</div>
{% if not no_button %}
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

{% for game in page_obj %}
<div class="game-card">
<div class='game-card-content'>
<img src="{{game.vignette.url}}" alt="{{game.name}}"/>
<a href="{% url 'filtershop_games:game' game.id %}" class="image_link">
<div class='game-card-content'>
<img src="{{game.vignette.url}}" alt="{{game.name}}"/>

<p>{{ game.description }}</p>
<a href="{% url 'filtershop_games:game' game.id %}" class="image_link">Read More</a>
</div>
<p>{{ game.description }}</p>
</div>
</a>
<div style="row-container">
{% for category in game.categories.all %}
<a class="badge" href="{% url 'filtershop_games:artisans_games' %}?category_id={{ category.id }}">{{ category.name }}</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

{% for game in page_obj %}
<div class="game-card">
<div class='game-card-content'>
<img src="{{game.vignette.url}}" alt="{{game.name}}"/>
<a href="{% url 'filtershop_games:game' game.id %}" class="image_link">
<div class='game-card-content'>
<img src="{{game.vignette.url}}" alt="{{game.name}}"/>

<p>{{ game.description }}</p>
<a href="{% url 'filtershop_games:game' game.id %}" class="image_link">Read More</a>
</div>
<p>{{ game.description }}</p>
</div>
</a>
<div style="row-container">
{% for category in game.categories.all %}
<a class="badge" href="{% url 'filtershop_games:best_of_the_rest' %}?category_id={{ category.id }}">{{ category.name }}</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

{% for game in page_obj %}
<div class="game-card">
<div class='game-card-content'>
<img src="{{game.vignette.url}}" alt="{{game.name}}"/>
<a href="{% url 'filtershop_games:game' game.id %}" class="image_link">
<div class='game-card-content'>
<img src="{{game.vignette.url}}" alt="{{game.name}}"/>

<p>{{ game.description }}</p>
<a href="{% url 'filtershop_games:game' game.id %}" class="image_link">Read More</a>
</div>
<p>{{ game.description }}</p>
</div>
</a>
<div style="row-container">
{% for category in game.categories.all %}
<a class="badge" href="{% url 'filtershop_games:indies_games' %}?category_id={{ category.id }}">{{ category.name }}</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

{% for shop in page_obj %}
<div class="game-card">
<div class='game-card-content'>
<img src="{{shop.vignette.url}}" alt="{{shop.name}}"/>
<a href="{% url 'filtershop_games:online_shop' shop.id %}" class="image_link">
<div class='game-card-content'>
<img src="{{shop.vignette.url}}" alt="{{shop.name}}"/>

<p>{{ shop.description }}</p>
<a href="{% url 'filtershop_games:online_shop' shop.id %}" class="image_link">Read More</a>
</div>
<p>{{ shop.description }}</p>
</div>
</a>
<div style="row-container">
{% for type in shop.shop_type.all %}
<a class="badge" href="{% url 'filtershop_games:online_artisans_shops' %}?shop_type={{ type }}">{{type }}</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

{% for shop in page_obj %}
<div class="game-card">
<a href="{% url 'filtershop_games:physical_shop' shop.id %}" class="image_link">
<div class='game-card-content'>
<img src="{{shop.vignette.url}}" alt="{{shop.name}}"/>

<p>{{ shop.description }}</p>
<a href="{% url 'filtershop_games:physical_shop' shop.id %}" class="image_link">Read More</a>
</div>
</div>
</a>
<div style="row-container">
{% for type in shop.shop_type.all %}
<a class="badge" href="{% url 'filtershop_games:physical_artisans_shops' %}?shop_type={{ type }}">{{type }}</a>
Expand Down
8 changes: 4 additions & 4 deletions thefiltershop/filtershop_main/views/list_games.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def get_all_games_for_size(max_size_of_studio) :

if max_size_of_studio != Studio.SizeInPersons.ARTISAN :
# No filter on publisher size for non-artisan
all_for_size = Videogame_common.objects.filter(studios__size_of_studio = max_size_of_studio)
all_for_size = Videogame_common.objects.filter(studios__size_of_studio = max_size_of_studio).order_by("known_popularity")
else :
all_for_size = Videogame_common.objects.filter(studios__size_of_studio = Studio.SizeInPersons.ARTISAN, publishers__size_of_publisher = Publisher.SizeInPersons.ARTISAN)
all_for_size = Videogame_common.objects.filter(studios__size_of_studio = Studio.SizeInPersons.ARTISAN, publishers__size_of_publisher = Publisher.SizeInPersons.ARTISAN).order_by("known_popularity")

return all_for_size

Expand All @@ -105,9 +105,9 @@ def get_all_best_of_the_rest(for_category) :
if for_category is not None :
# Apply category filtering if a category is selected
pre_filterd_games = Videogame_common.objects.filter (categories__id=for_category)
all_filtered_games = pre_filterd_games.annotate(number_of_filters=Count('valueforfilter', filter=Q(valueforfilter__filter__is_positive=False))).exclude( number_of_filters = 0).order_by("crapometer")[:100]
all_filtered_games = pre_filterd_games.annotate(number_of_filters=Count('valueforfilter', filter=Q(valueforfilter__filter__is_positive=False))).exclude( number_of_filters = 0).order_by("crapometer").order_by("known_popularity")[:100]
else :
all_filtered_games = Videogame_common.objects.annotate(number_of_filters=Count('valueforfilter', filter=Q(valueforfilter__filter__is_positive=False))).exclude( number_of_filters = 0).order_by("crapometer")[:100]
all_filtered_games = Videogame_common.objects.annotate(number_of_filters=Count('valueforfilter', filter=Q(valueforfilter__filter__is_positive=False))).exclude( number_of_filters = 0).order_by("crapometer").order_by("known_popularity")[:100]

# And exclude all that don't respect the rules
remaining_games = []
Expand Down

0 comments on commit f6bad24

Please sign in to comment.