Create a fake user if not existing

This commit is contained in:
emeric
2018-03-04 16:09:03 +01:00
parent bbb988266d
commit a3fd11c85b
4 changed files with 14 additions and 1 deletions
+6
View File
@@ -83,6 +83,12 @@ User::getAll(Wt::Dbo::Session& session)
return std::vector<pointer>(res.begin(), res.end());
}
User::pointer
User::create(Wt::Dbo::Session& session)
{
return session.add(new User());
}
User::pointer
User::getById(Wt::Dbo::Session& session, id_type id)
{
+3
View File
@@ -64,6 +64,9 @@ class User
typedef Wt::Dbo::ptr<User> pointer;
// utility
static pointer create(Wt::Dbo::Session& session);
// accessors
static pointer getById(Wt::Dbo::Session& session, id_type id);
static std::vector<pointer> getAll(Wt::Dbo::Session& session);
+4
View File
@@ -101,6 +101,10 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env, Wt::Dbo::SqlConnecti
Wt::Dbo::Transaction transaction(DboSession());
firstConnection = (Database::User::getAll(DboSession()).size() == 0);
// Create a fake user
// TODO settings
Database::User::create(DboSession());
}
LMS_LOG(UI, DEBUG) << "Creating root widget. First connection = " << std::boolalpha << firstConnection;
+1 -1
View File
@@ -120,7 +120,7 @@ Playlist::addSome()
return;
bool moreResults;
auto tracks = playlist->getTracks(_entriesContainer->count(), 20, moreResults);
auto tracks = playlist->getTracks(_entriesContainer->count(), 50, moreResults);
for (auto track : tracks)
{
Wt::WTemplate* entry = new Wt::WTemplate(Wt::WString::tr("template-playlist-entry"), _entriesContainer);