Various UI small improvements (better error reporting in case of bad url, made the password change fields more explicit)

This commit is contained in:
emeric
2019-10-06 18:59:13 +02:00
parent b5cfe014ec
commit 174158aa63
17 changed files with 182 additions and 57 deletions
+10 -7
View File
@@ -39,6 +39,7 @@
#include "common/Validators.hpp"
#include "common/ValueStringModel.hpp"
#include "LmsApplication.hpp"
#include "LmsApplicationException.hpp"
namespace UserInterface {
@@ -54,8 +55,7 @@ class UserModel : public Wt::WFormModel
static const Field DemoField;
UserModel(std::optional<Database::IdType> userId)
: Wt::WFormModel(),
_userId(userId)
: _userId {userId}
{
if (!_userId)
{
@@ -126,8 +126,10 @@ class UserModel : public Wt::WFormModel
auto transaction {LmsApp->getDbSession().createSharedTransaction()};
const Database::User::pointer user {Database::User::getById(LmsApp->getDbSession(), *_userId)};
if (user == LmsApp->getUser())
throw LmsException("Cannot edit ourselves");
if (!user)
throw UserNotFoundException {*_userId};
else if (user == LmsApp->getUser())
throw UserNotAllowedException {};
auto transcodeBitrateLimitRow {_bitrateModel->getRowFromValue(user->getMaxAudioTranscodeBitrate())};
if (transcodeBitrateLimitRow)
@@ -240,12 +242,13 @@ UserView::refreshView()
auto transaction {LmsApp->getDbSession().createSharedTransaction()};
const Database::User::pointer user {Database::User::getById(LmsApp->getDbSession(), *userId)};
if (!user)
throw UserNotFoundException {*userId};
t->bindString("title", Wt::WString::tr("Lms.Admin.User.user-edit").arg(user->getLoginName()), Wt::TextFormat::Plain);
t->setCondition("if-has-last-login", true);
Wt::WLineEdit *lastLogin {t->bindNew<Wt::WLineEdit>("last-login")};
lastLogin->setText(user->getLastLogin().toString());
lastLogin->setEnabled(false);
t->bindString("last-login", user->getLastLogin().toString(), Wt::TextFormat::Plain);
}
else
{