diff --git a/mishmash/__about__.py b/mishmash/__about__.py index 6d77015..3195904 100644 --- a/mishmash/__about__.py +++ b/mishmash/__about__.py @@ -14,7 +14,7 @@ def __parse_version(v): # pragma: nocover return ver, rel, ver_info -__version__ = "0.3b8" +__version__ = "0.3b9" __release_name__ = "" __years__ = "2013-2018" diff --git a/mishmash/web/static/js/mishmash.js b/mishmash/web/static/js/mishmash.js new file mode 100644 index 0000000..0de7d50 --- /dev/null +++ b/mishmash/web/static/js/mishmash.js @@ -0,0 +1,13 @@ + +function searchParamsFromAlbumTypeChecks() { + var all_checked = true; + var search = ""; + + $(".type-checkbox").each(function(i) { + all_checked &= this.checked; + search += (search ? "&" : "?") + + ("type=" + (this.checked ? this.name : ("!" + this.name))); + }); + + return !all_checked ? search : ""; +} diff --git a/mishmash/web/templates/album.pt b/mishmash/web/templates/album.pt index 77a3068..18f4149 100644 --- a/mishmash/web/templates/album.pt +++ b/mishmash/web/templates/album.pt @@ -1,5 +1,4 @@ - -
+
@@ -67,5 +66,4 @@
-
-
+
diff --git a/mishmash/web/templates/albums.pt b/mishmash/web/templates/albums.pt index 6d8fb49..aec6a8c 100644 --- a/mishmash/web/templates/albums.pt +++ b/mishmash/web/templates/albums.pt @@ -1,5 +1,4 @@ - -
+
@@ -8,6 +7,7 @@ ${L} 
+
@@ -29,53 +29,12 @@
+ -
-
+
diff --git a/mishmash/web/templates/artist.pt b/mishmash/web/templates/artist.pt index d792f69..40ab241 100644 --- a/mishmash/web/templates/artist.pt +++ b/mishmash/web/templates/artist.pt @@ -1,5 +1,4 @@ - -
+
@@ -10,7 +9,7 @@
- +
diff --git a/mishmash/web/templates/artists.pt b/mishmash/web/templates/artists.pt index b2d1a3e..c81211e 100644 --- a/mishmash/web/templates/artists.pt +++ b/mishmash/web/templates/artists.pt @@ -1,11 +1,22 @@ - -
+
+
+
+
+ ${L}  +
+
+
+
-
- ${L}  -
+
+ + + + +
@@ -19,6 +30,13 @@ + + + -
-
+
diff --git a/mishmash/web/templates/home.pt b/mishmash/web/templates/home.pt index 0ed905c..13c9d09 100644 --- a/mishmash/web/templates/home.pt +++ b/mishmash/web/templates/home.pt @@ -1,5 +1,4 @@ - -
+

Browse:

@@ -16,6 +15,5 @@
-
-
+
diff --git a/mishmash/web/templates/new_music.pt b/mishmash/web/templates/new_music.pt index a36f71e..17bf677 100644 --- a/mishmash/web/templates/new_music.pt +++ b/mishmash/web/templates/new_music.pt @@ -1,5 +1,4 @@ - -
+
- - + diff --git a/mishmash/web/templates/search_results.pt b/mishmash/web/templates/search_results.pt index 8798d30..7dd6976 100644 --- a/mishmash/web/templates/search_results.pt +++ b/mishmash/web/templates/search_results.pt @@ -1,5 +1,4 @@ - -
+
@@ -30,5 +29,4 @@
-
-
+
diff --git a/mishmash/web/views.py b/mishmash/web/views.py index 17f0358..f2dd5f7 100644 --- a/mishmash/web/views.py +++ b/mishmash/web/views.py @@ -57,6 +57,7 @@ def allArtistsView(request): buckets = set() artist_dict = {} + artist_types = {} def _whichBucket(name): first_l = name[0].upper() @@ -65,12 +66,21 @@ def _whichBucket(name): buckets.add(first_l) return first_l + active_types = _getActiveAlbumTypes(request.params) session = request.DBSession for artist in session.query(Artist)\ .order_by(Artist.sort_name).all(): - types = set([a.type for a in artist.albums]) - print("TYPES: ", types) + types = set([alb.type for alb in artist.albums]) + for t in types: + if t not in artist_types: + artist_types[t] = { + "active": t in active_types, + } + + if not active_types.intersection(types): + continue + bucket = _whichBucket(artist.sort_name) if bucket not in artist_dict: artist_dict[bucket] = [] @@ -96,8 +106,7 @@ def _whichBucket(name): buckets.remove(OTHER) buckets.append(OTHER) - return ResponseDict(artist_keys=buckets, - artist_dict=artist_dict) + return ResponseDict(artist_keys=buckets, artist_dict=artist_dict, artist_types=artist_types) @view_config(route_name="artist", renderer="templates/artist.pt", @@ -223,12 +232,7 @@ def allAlbumsView(request): album_dict = {} album_types = {} - inc_types = set([p for p in request.params.getall("type") if p[0] != '!']) - exc_types = set([p[1:] for p in request.params.getall("type") if p[0] == '!']) - active_types = set(ALBUM_TYPE_IDS).difference(exc_types) - if inc_types: - active_types = active_types.intersection(inc_types) - + active_types = _getActiveAlbumTypes(request.params) session = request.DBSession for album in session.query(Album)\ .order_by(Album.original_release_date).all(): @@ -253,3 +257,11 @@ def allAlbumsView(request): return ResponseDict(album_decades=buckets, album_dict=album_dict, album_types=album_types) + +def _getActiveAlbumTypes(params): + inc_types = set([p for p in params.getall("type") if p[0] != '!']) + exc_types = set([p[1:] for p in params.getall("type") if p[0] == '!']) + active_types = set(ALBUM_TYPE_IDS).difference(exc_types) + if inc_types: + active_types = active_types.intersection(inc_types) + return active_types