diff --git a/qgis-app/plugins/views.py b/qgis-app/plugins/views.py index 8cb6adaf..d1897117 100644 --- a/qgis-app/plugins/views.py +++ b/qgis-app/plugins/views.py @@ -545,7 +545,7 @@ def get_context_data(self, **kwargs): messages.error(self.request, msg, fail_silently=True) context.update( { - "rating": int(plugin.rating.get_rating()), + "rating": plugin.rating.get_rating(), "votes": plugin.rating.votes, } ) diff --git a/qgis-app/settings_docker.py b/qgis-app/settings_docker.py index bb151b7f..1aa2d82e 100644 --- a/qgis-app/settings_docker.py +++ b/qgis-app/settings_docker.py @@ -5,6 +5,7 @@ SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) from datetime import timedelta +from django.contrib.staticfiles.storage import ManifestStaticFilesStorage DEBUG = ast.literal_eval(os.environ.get("DEBUG", "True")) THUMBNAIL_DEBUG = DEBUG @@ -31,6 +32,10 @@ # Example: "http://example.com/static/", "http://static.example.com/" STATIC_URL = "/static/" +# Manage static files storage ensuring that their +# filenames contain a hash of their content for cache busting +STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage' + INSTALLED_APPS = [ "django.contrib.auth", "django.contrib.contenttypes", diff --git a/qgis-app/static/jquery-ratings/half-and-quarter-star-16.png b/qgis-app/static/jquery-ratings/half-and-quarter-star-16.png new file mode 100644 index 00000000..09b5589b Binary files /dev/null and b/qgis-app/static/jquery-ratings/half-and-quarter-star-16.png differ diff --git a/qgis-app/static/jquery-ratings/half-and-quarter-star.png b/qgis-app/static/jquery-ratings/half-and-quarter-star.png new file mode 100644 index 00000000..dba6d557 Binary files /dev/null and b/qgis-app/static/jquery-ratings/half-and-quarter-star.png differ diff --git a/qgis-app/static/jquery-ratings/half-star-16.png b/qgis-app/static/jquery-ratings/half-star-16.png new file mode 100644 index 00000000..993a9cc9 Binary files /dev/null and b/qgis-app/static/jquery-ratings/half-star-16.png differ diff --git a/qgis-app/static/jquery-ratings/half-star.png b/qgis-app/static/jquery-ratings/half-star.png new file mode 100644 index 00000000..5560b627 Binary files /dev/null and b/qgis-app/static/jquery-ratings/half-star.png differ diff --git a/qgis-app/static/jquery-ratings/jquery.ratings.css b/qgis-app/static/jquery-ratings/jquery.ratings.css index 9c9cdbf4..cc55d031 100644 --- a/qgis-app/static/jquery-ratings/jquery.ratings.css +++ b/qgis-app/static/jquery-ratings/jquery.ratings.css @@ -11,3 +11,17 @@ .jquery-ratings-full { background-image: url('full-star-16.png'); } + + +.jquery-ratings-quarter { + background-image: url('quarter-star-16.png'); +} + +.jquery-ratings-half { + background-image: url('half-star-16.png'); +} + +.jquery-ratings-half-and-quarter { + background-image: url('half-and-quarter-star-16.png'); +} + diff --git a/qgis-app/static/jquery-ratings/jquery.ratings.js b/qgis-app/static/jquery-ratings/jquery.ratings.js index 3d5a2a77..30519668 100644 --- a/qgis-app/static/jquery-ratings/jquery.ratings.js +++ b/qgis-app/static/jquery-ratings/jquery.ratings.js @@ -42,8 +42,21 @@ jQuery.fn.ratings = function(stars, initialRating) { star.addClass('jquery-ratings-star'); //Add the full css class if the star is beneath the initial rating. + // The last star will depend on the decimal left if(starIdx < initialRating) { - star.addClass('jquery-ratings-full'); + let ratingDiff = initialRating - starIdx + if (ratingDiff > 0 && ratingDiff <= 0.3) { + star.addClass('jquery-ratings-quarter'); + } + else if (ratingDiff > 0.3 && ratingDiff <= 0.6) { + star.addClass('jquery-ratings-half'); + } + else if (ratingDiff > 0.6 && ratingDiff <= 0.9) { + star.addClass('jquery-ratings-half-and-quarter'); + } + else { + star.addClass('jquery-ratings-full'); + } } //add the star to the container @@ -65,13 +78,28 @@ jQuery.fn.ratings = function(stars, initialRating) { //Unhighlight unselected stars. for(var index = this.rating; index < stars; index++) { starsCollection[index].removeClass('jquery-ratings-full'); + starsCollection[index].removeClass('jquery-ratings-half-and-quarter'); + starsCollection[index].removeClass('jquery-ratings-half'); + starsCollection[index].removeClass('jquery-ratings-quarter'); } }); container.mouseleave(function() { //Highlight selected stars. for(var index = 0; index < containerElement.rating; index++) { - starsCollection[index].addClass('jquery-ratings-full'); + let ratingDiff = containerElement.rating - index + if (ratingDiff > 0 && ratingDiff <= 0.3) { + starsCollection[index].addClass('jquery-ratings-quarter'); + } + else if (ratingDiff > 0.3 && ratingDiff <= 0.6) { + starsCollection[index].addClass('jquery-ratings-half'); + } + else if (ratingDiff > 0.6 && ratingDiff <= 0.9) { + starsCollection[index].addClass('jquery-ratings-half-and-quarter'); + } + else { + starsCollection[index].addClass('jquery-ratings-full'); + } } //Unhighlight unselected stars. for(var index = containerElement.rating; index < stars ; index++) { diff --git a/qgis-app/static/jquery-ratings/quarter-star-16.png b/qgis-app/static/jquery-ratings/quarter-star-16.png new file mode 100644 index 00000000..edbada17 Binary files /dev/null and b/qgis-app/static/jquery-ratings/quarter-star-16.png differ diff --git a/qgis-app/static/jquery-ratings/quarter-star.png b/qgis-app/static/jquery-ratings/quarter-star.png new file mode 100644 index 00000000..d39759e0 Binary files /dev/null and b/qgis-app/static/jquery-ratings/quarter-star.png differ