Add copyright/copyrightURL support and display it in the release view

This commit is contained in:
emeric
2018-09-21 14:00:15 +02:00
parent c464200644
commit f5f6136159
13 changed files with 139 additions and 19 deletions
+43 -1
View File
@@ -19,6 +19,8 @@
#include "Release.hpp"
#include "utils/Logger.hpp"
#include "Artist.hpp"
#include "Cluster.hpp"
#include "SqlQuery.hpp"
@@ -163,7 +165,7 @@ Release::getReleaseYear(bool original) const
.groupBy(field)
.bind(this->id());
/* various dates, no date */
// various dates => no date
if (dates.empty() || dates.size() > 1)
return boost::none;
@@ -175,6 +177,46 @@ Release::getReleaseYear(bool original) const
return boost::none;
}
boost::optional<std::string>
Release::getCopyright() const
{
assert(session());
Wt::Dbo::collection<std::string> copyrights = session()->query<std::string>
("SELECT copyright FROM track t INNER JOIN release r ON r.id = t.release_id")
.where("r.id = ?")
.groupBy("copyright")
.bind(this->id());
std::vector<std::string> values(copyrights.begin(), copyrights.end());
// various copyrights => no copyright
if (values.empty() || values.size() > 1 || values.front().empty())
return boost::none;
return values.front();
}
boost::optional<std::string>
Release::getCopyrightURL() const
{
assert(session());
Wt::Dbo::collection<std::string> copyrights = session()->query<std::string>
("SELECT copyright_url FROM track t INNER JOIN release r ON r.id = t.release_id")
.where("r.id = ?")
.groupBy("copyright_url")
.bind(this->id());
std::vector<std::string> values(copyrights.begin(), copyrights.end());
// various copyright URLs => no copyright URL
if (values.empty() || values.size() > 1 || values.front().empty())
return boost::none;
return values.front();
}
std::vector<Wt::Dbo::ptr<Artist>>
Release::getArtists() const
{