amuse.git

commit 03dbd9fc1a04bb656f97c9cb53000ff01ed462f5

Author: Adam <git@apiote.tk>

show watched parts of film collections

 libamuse/film.go | 22 ++++++++++++++++++++++
 templates/film.html | 3 ++-
 tmdb/film.go | 1 +


diff --git a/libamuse/film.go b/libamuse/film.go
index 95f17c8919374c76cd314c9e10c738d4964b68bc..e9f1629cb18468afb1797b4efafd6447061bbf17 100644
--- a/libamuse/film.go
+++ b/libamuse/film.go
@@ -35,6 +35,27 @@ 	}
 	return gott.Tuple(args), err
 }
 
+func getCollectionWatches(args ...interface{}) (interface{}, error) {
+	result := args[1].(*Result)
+	film := result.result.(*tmdb.Film)
+
+	if result.user.IsEmpty() {
+		return gott.Tuple(args), nil
+	}
+
+	for i, part := range film.Collection.Parts {
+		experiences, err := db.GetItemExperiences(result.user.Username, strconv.FormatInt(int64(part.Id), 10), datastructure.ItemTypeFilm)
+		if err != nil {
+			return gott.Tuple(args), err
+		}
+		if len(experiences) > 0 {
+			part.IsWatched = true
+			film.Collection.Parts[i] = part
+		}
+	}
+	return gott.Tuple(args), nil
+}
+
 func renderFilm(args ...interface{}) interface{} {
 	result := args[1].(*Result)
 	film := result.result.(*tmdb.Film)
@@ -65,6 +86,7 @@ 		Bind(parseLanguage).
 		Bind(verifyToken).
 		Bind(getFilm).
 		Bind(getCollection).
+		Bind(getCollectionWatches).
 		Bind(getBasedOn).
 		Bind(getFilmExperiences).
 		Bind(isOnWantList).




diff --git a/templates/film.html b/templates/film.html
index 357b8b004c994d2457dfc01342b2381549250574..4c80b2dc6b51490f8d5e6379ab8e618a6e5b1035 100644
--- a/templates/film.html
+++ b/templates/film.html
@@ -148,8 +148,9 @@ 							
<div class="margin-lr-1"> <p class="sans">{{.Title}}</p> {{if not .Release_date.IsZero}} - <span class="sans font-_875 text-grey">{{.Release_date.Year}}</span> + <p class="sans font-_875 text-grey">{{.Release_date.Year}}</p> {{end}} + {{if .IsWatched}}<p class="material-icon font-_875 text-grey">&#xe8f4;</p>{{end}} </div> </div> </a> diff --git a/tmdb/film.go b/tmdb/film.go index 628a4de850d48555ce6e1583c0d7d8f03c675909..c633f2564a9d395d41aeda0556e15a2b7bf1970c 100644 --- a/tmdb/film.go +++ b/tmdb/film.go @@ -25,6 +25,7 @@ Release_date_str string `json:"release_date"` Release_date time.Time Poster_path string `json:"poster_path"` Title string + IsWatched bool } }