diff --git a/mslib/index.py b/mslib/index.py index 36b110e05..bf87b28a6 100644 --- a/mslib/index.py +++ b/mslib/index.py @@ -81,7 +81,6 @@ def create_app(name="", imprint=None, gdpr=None): @APP.route('/xstatic//') def files(name, filename): - base_path = _xstatic(name) if base_path is None: abort(404) diff --git a/mslib/mscolab/file_manager.py b/mslib/mscolab/file_manager.py index 2b06fff4c..d6e76afc0 100644 --- a/mslib/mscolab/file_manager.py +++ b/mslib/mscolab/file_manager.py @@ -236,7 +236,6 @@ def modify_user(self, user, attribute=None, value=None, action=None): db.session.delete(user) db.session.commit() user_query = User.query.filter_by(id=user.id).first() - # on delete we return successful deleted if user_query is None: return True elif action == "update_idp_user": @@ -246,6 +245,7 @@ def modify_user(self, user, attribute=None, value=None, action=None): db.session.commit() else: return False + # This is the default, when we not have a special action user_query = User.query.filter_by(id=user.id).first() if user_query is None: return False diff --git a/mslib/mscolab/migrations/versions/922e4d9c94e2_to_version_10_0_0.py b/mslib/mscolab/migrations/versions/922e4d9c94e2_to_version_10_0_0.py index c03710ee4..21c353c28 100644 --- a/mslib/mscolab/migrations/versions/922e4d9c94e2_to_version_10_0_0.py +++ b/mslib/mscolab/migrations/versions/922e4d9c94e2_to_version_10_0_0.py @@ -21,6 +21,7 @@ def upgrade(): # ### commands auto generated by Alembic - please adjust! ### with op.batch_alter_table('users', schema=None) as batch_op: batch_op.add_column(sa.Column('profile_image_path', sa.String(length=255), nullable=True)) + batch_op.add_column(sa.Column('fullname', sa.String(length=255), nullable=True)) # ### end Alembic commands ### @@ -29,5 +30,6 @@ def downgrade(): # ### commands auto generated by Alembic - please adjust! ### with op.batch_alter_table('users', schema=None) as batch_op: batch_op.drop_column('profile_image_path') + batch_op.drop_column('fullname') - # ### end Alembic commands ### + # ### end Alembic commands ### diff --git a/mslib/mscolab/models.py b/mslib/mscolab/models.py index dcec139f1..a12c2deca 100644 --- a/mslib/mscolab/models.py +++ b/mslib/mscolab/models.py @@ -64,11 +64,13 @@ class User(db.Model): confirmed_on = db.Column(AwareDateTime, nullable=True) permissions = db.relationship('Permission', cascade='all,delete,delete-orphan', backref='user') authentication_backend = db.Column(db.String(255), nullable=False, default='local') + fullname = db.Column(db.String(255), nullable=True) - def __init__(self, emailid, username, password, profile_image_path=None, confirmed=False, + def __init__(self, emailid, username, password, fullname="", profile_image_path=None, confirmed=False, confirmed_on=None, authentication_backend='local'): self.username = str(username) self.emailid = str(emailid) + self.fullname = str(fullname) self.hash_password(password) self.profile_image_path = profile_image_path self.registered_on = datetime.datetime.now(tz=datetime.timezone.utc) @@ -77,7 +79,7 @@ def __init__(self, emailid, username, password, profile_image_path=None, confirm self.authentication_backend = str(authentication_backend) def __repr__(self): - return f'' + return f'' def hash_password(self, password): self.password = pwd_context.hash(password) diff --git a/mslib/mscolab/mscolab.py b/mslib/mscolab/mscolab.py index da8f26897..16d4fa9bb 100644 --- a/mslib/mscolab/mscolab.py +++ b/mslib/mscolab/mscolab.py @@ -429,9 +429,10 @@ def main(): for line in args.users_by_file.readlines(): info = line.split() username = info[0] + fullname = info[1] emailid = info[-1][1:-1] password = secrets.token_hex(8) - add_user(emailid, username, password) + add_user(emailid, username, password, fullname) elif args.default_operation: confirmation = confirm_action( "Are you sure you want to add users to the default TEMPLATE operation? (y/[n]):") diff --git a/mslib/mscolab/seed.py b/mslib/mscolab/seed.py index dc9c17439..e573c7018 100644 --- a/mslib/mscolab/seed.py +++ b/mslib/mscolab/seed.py @@ -107,7 +107,7 @@ def delete_user(email): return False -def add_user(email, username, password): +def add_user(email, username, password, fullname=""): """ on db level we add a user """ @@ -118,11 +118,11 @@ def add_user(email, username, password): user_email_exists = User.query.filter_by(emailid=str(email)).first() user_name_exists = User.query.filter_by(username=str(username)).first() if not user_email_exists and not user_name_exists: - db_user = User(email, username, password) + db_user = User(email, username, password, fullname) db.session.add(db_user) db.session.commit() db.session.close() - logging.info("Userdata: %s %s %s", email, username, password) + logging.info("Userdata: %s %s %s %s", email, username, password, fullname) return True else: logging.info("%s already in db", user_name_exists) @@ -225,55 +225,65 @@ def seed_data(): 'username': 'a', 'id': 8, 'password': 'a', - 'emailid': 'a@notexisting.org' + 'emailid': 'a@notexisting.org', + 'fullname': 'A User' }, { 'username': 'b', 'id': 9, 'password': 'b', - 'emailid': 'b@notexisting.org' + 'emailid': 'b@notexisting.org', + 'fullname': 'B User' }, { 'username': 'c', 'id': 10, 'password': 'c', - 'emailid': 'c@notexisting.org' + 'emailid': 'c@notexisting.org', + 'fullname': 'C User' }, { 'username': 'd', 'id': 11, 'password': 'd', - 'emailid': 'd@notexisting.org' + 'emailid': 'd@notexisting.org', + 'fullname': 'D User' }, { 'username': 'test1', 'id': 12, 'password': 'test1', - 'emailid': 'test1@notexisting.org' + 'emailid': 'test1@notexisting.org', + 'fullname': 'Test User one' }, { 'username': 'test2', 'id': 13, 'password': 'test2', - 'emailid': 'test2@notexisting.org' + 'emailid': 'test2@notexisting.org', + 'fullname': 'Test User two' }, { 'username': 'test3', 'id': 14, 'password': 'test3', - 'emailid': 'test3@notexisting.org' + 'emailid': 'test3@notexisting.org', + 'fullname': 'Test User three' }, { 'username': 'test4', 'id': 15, 'password': 'test4', - 'emailid': 'test4@notexisting.org' + 'emailid': 'test4@notexisting.org', + 'fullname': 'Test User four' }, { 'username': 'mscolab_user', 'id': 16, 'password': 'password', - 'emailid': 'mscolab_user@notexisting.org' + 'emailid': 'mscolab_user@notexisting.org', + 'fullname': 'mscolab user' }, { 'username': 'merge_waypoints_user', 'id': 17, 'password': 'password', - 'emailid': 'merge_waypoints_user@notexisting.org' + 'emailid': 'merge_waypoints_user@notexisting.org', + 'fullname': 'merge waypoints user' }] for user in users: - db_user = User(user['emailid'], user['username'], user['password']) + db_user = User(user['emailid'], user['username'], user['password'], user['fullname']) db_user.id = user['id'] db.session.add(db_user) diff --git a/mslib/mscolab/server.py b/mslib/mscolab/server.py index f43fdd154..979291bb1 100644 --- a/mslib/mscolab/server.py +++ b/mslib/mscolab/server.py @@ -248,7 +248,7 @@ def check_login(emailid, password): return False -def register_user(email, password, username): +def register_user(email, password, username, fullname=""): if len(str(email.strip())) == 0 or len(str(username.strip())) == 0: return {"success": False, "message": "Your username or email cannot be empty"} is_valid_username = True if username.find("@") == -1 else False @@ -263,7 +263,7 @@ def register_user(email, password, username): user_exists = User.query.filter_by(username=str(username)).first() if user_exists: return {"success": False, "message": "This username is already registered"} - user = User(email, username, password) + user = User(email, username, password, fullname) result = fm.modify_user(user, action="create") return {"success": result} @@ -370,14 +370,14 @@ def get_auth_token(): token = user.generate_auth_token() return json.dumps({ 'token': token, - 'user': {'username': user.username, 'id': user.id}}) + 'user': {'username': user.username, 'id': user.id}, 'fullname': user.fulllname}) else: return "False" else: token = user.generate_auth_token() return json.dumps({ 'token': token, - 'user': {'username': user.username, 'id': user.id}}) + 'user': {'username': user.username, 'id': user.id, 'fullname': user.fullname}}) else: logging.debug("Unauthorized user: %s", emailid) return "False" @@ -405,7 +405,8 @@ def user_register_handler(): email = request.form['email'] password = request.form['password'] username = request.form['username'] - result = register_user(email, password, username) + fullname = request.form.get('fullname', "") + result = register_user(email, password, username, fullname) status_code = 200 try: if result["success"]: @@ -432,7 +433,7 @@ def confirm_email(token): if email is False: return jsonify({"success": False}), 401 user = User.query.filter_by(emailid=email).first_or_404() - if user.confirmed: + if user.confirmed: return render_template('user/confirmed.html', username=user.username) else: fm.modify_user(user, attribute="confirmed_on", value=datetime.datetime.now(tz=datetime.timezone.utc)) @@ -443,7 +444,7 @@ def confirm_email(token): @APP.route('/user', methods=["GET"]) @verify_user def get_user(): - return json.dumps({'user': {'id': g.user.id, 'username': g.user.username}}) + return json.dumps({'user': {'id': g.user.id, 'username': g.user.username, 'fullname': g.user.fullname}}) @APP.route('/upload_profile_image', methods=["POST"]) @@ -616,6 +617,15 @@ def set_version_name(): return jsonify({"success": True, "message": "Successfully set version name"}) +@APP.route("/edit_user_info", methods=["POST"]) +@verify_user +def edit_user_info(): + user = g.user + fullname = request.form.get("fullname") + result = fm.modify_user(user, attribute="fullname", value=fullname) + return jsonify({"success": result}), 200 + + @APP.route('/authorized_users', methods=['GET']) @verify_user def authorized_users(): diff --git a/mslib/msui/mscolab.py b/mslib/msui/mscolab.py index 2b959c7d0..9c6f5dcbb 100644 --- a/mslib/msui/mscolab.py +++ b/mslib/msui/mscolab.py @@ -445,6 +445,7 @@ def new_user_handler(self): password = self.newPasswordLe.text() re_password = self.newConfirmPasswordLe.text() username = self.newUsernameLe.text() + fullname = self.newFullnameLe.text() if password != re_password: self.set_status("Error", 'Your passwords don\'t match.') return @@ -452,7 +453,8 @@ def new_user_handler(self): data = { "email": emailid, "password": password, - "username": username + "username": username, + "fullname": fullname } session = requests.Session() session.auth = self.auth @@ -870,6 +872,7 @@ def on_context_menu(point): self.profile_dialog.setupUi(self.prof_diag) self.profile_dialog.buttonBox.accepted.connect(lambda: self.prof_diag.close()) self.profile_dialog.usernameLabel_2.setText(self.user['username']) + self.profile_dialog.fullNameLabel_2.setText(self.user['fullname']) self.profile_dialog.mscolabURLLabel_2.setText(self.mscolab_server_url) self.profile_dialog.emailLabel_2.setText(self.email) self.profile_dialog.deleteAccountBtn.clicked.connect(self.delete_account) @@ -931,9 +934,11 @@ def upload_image(self): def delete_account(self, _=None): # ToDo rename to delete_own_account reply = QMessageBox.question( - self.ui, self.tr('Continue?'), + self.ui, + self.tr('Continue?'), self.tr("You're about to delete your account. You cannot undo this operation!"), - QMessageBox.Yes | QMessageBox.No, QMessageBox.No) + QMessageBox.Yes | QMessageBox.No, + QMessageBox.No) if reply == QMessageBox.No: return try: diff --git a/mslib/msui/qt5/ui_add_user_dialog.py b/mslib/msui/qt5/ui_add_user_dialog.py index bf4b0003f..4648c6a10 100644 --- a/mslib/msui/qt5/ui_add_user_dialog.py +++ b/mslib/msui/qt5/ui_add_user_dialog.py @@ -1,17 +1,20 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'mslib/msui/ui/ui_add_user.ui' +# Form implementation generated from reading ui file 'ui_add_user_dialog.ui' # -# Created by: PyQt5 UI code generator 5.9.2 +# Created by: PyQt5 UI code generator 5.15.9 # -# WARNING! All changes made in this file will be lost! +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + from PyQt5 import QtCore, QtGui, QtWidgets + class Ui_addUserDialog(object): def setupUi(self, addUserDialog): addUserDialog.setObjectName("addUserDialog") - addUserDialog.resize(375, 232) + addUserDialog.resize(375, 293) self.gridLayout = QtWidgets.QGridLayout(addUserDialog) self.gridLayout.setObjectName("gridLayout") self.verticalLayout = QtWidgets.QVBoxLayout() @@ -19,34 +22,45 @@ def setupUi(self, addUserDialog): self.formLayout = QtWidgets.QFormLayout() self.formLayout.setFieldGrowthPolicy(QtWidgets.QFormLayout.ExpandingFieldsGrow) self.formLayout.setLabelAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.formLayout.setHorizontalSpacing(7) self.formLayout.setVerticalSpacing(14) self.formLayout.setObjectName("formLayout") + self.usernameLabel = QtWidgets.QLabel(addUserDialog) + self.usernameLabel.setObjectName("usernameLabel") + self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.usernameLabel) self.username = QtWidgets.QLineEdit(addUserDialog) self.username.setObjectName("username") self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.username) + self.fullnamelabel = QtWidgets.QLabel(addUserDialog) + self.fullnamelabel.setObjectName("fullnamelabel") + self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.fullnamelabel) + self.fullname = QtWidgets.QLineEdit(addUserDialog) + self.fullname.setText("") + self.fullname.setObjectName("fullname") + self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.fullname) + self.emailIDLabel = QtWidgets.QLabel(addUserDialog) + self.emailIDLabel.setObjectName("emailIDLabel") + self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.emailIDLabel) self.emailid = QtWidgets.QLineEdit(addUserDialog) self.emailid.setObjectName("emailid") - self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.emailid) + self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.emailid) self.passwordLabel = QtWidgets.QLabel(addUserDialog) self.passwordLabel.setObjectName("passwordLabel") - self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.passwordLabel) + self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.passwordLabel) self.password = QtWidgets.QLineEdit(addUserDialog) self.password.setEchoMode(QtWidgets.QLineEdit.Password) self.password.setObjectName("password") - self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.password) + self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.password) self.confirmPasswordLabel = QtWidgets.QLabel(addUserDialog) self.confirmPasswordLabel.setObjectName("confirmPasswordLabel") - self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.confirmPasswordLabel) + self.formLayout.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.confirmPasswordLabel) self.rePassword = QtWidgets.QLineEdit(addUserDialog) self.rePassword.setEchoMode(QtWidgets.QLineEdit.Password) self.rePassword.setObjectName("rePassword") - self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.rePassword) - self.emailIDLabel = QtWidgets.QLabel(addUserDialog) - self.emailIDLabel.setObjectName("emailIDLabel") - self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.emailIDLabel) - self.usernameLabel = QtWidgets.QLabel(addUserDialog) - self.usernameLabel.setObjectName("usernameLabel") - self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.usernameLabel) + self.formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.rePassword) + self.verticalLayout_2 = QtWidgets.QVBoxLayout() + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.formLayout.setLayout(6, QtWidgets.QFormLayout.FieldRole, self.verticalLayout_2) self.verticalLayout.addLayout(self.formLayout) self.buttonBox = QtWidgets.QDialogButtonBox(addUserDialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) @@ -56,18 +70,20 @@ def setupUi(self, addUserDialog): self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) self.retranslateUi(addUserDialog) - self.buttonBox.accepted.connect(addUserDialog.accept) - self.buttonBox.rejected.connect(addUserDialog.reject) + self.buttonBox.accepted.connect(addUserDialog.accept) # type: ignore + self.buttonBox.rejected.connect(addUserDialog.reject) # type: ignore QtCore.QMetaObject.connectSlotsByName(addUserDialog) def retranslateUi(self, addUserDialog): _translate = QtCore.QCoreApplication.translate addUserDialog.setWindowTitle(_translate("addUserDialog", "Add user")) + self.usernameLabel.setText(_translate("addUserDialog", "Username:")) self.username.setPlaceholderText(_translate("addUserDialog", "John Doe")) + self.fullnamelabel.setText(_translate("addUserDialog", "Fullname:")) + self.fullname.setPlaceholderText(_translate("addUserDialog", "John Michael Doe")) + self.emailIDLabel.setText(_translate("addUserDialog", "Email:")) self.emailid.setPlaceholderText(_translate("addUserDialog", "johndoe@gmail.com")) self.passwordLabel.setText(_translate("addUserDialog", "Password:")) self.password.setPlaceholderText(_translate("addUserDialog", "Your password")) self.confirmPasswordLabel.setText(_translate("addUserDialog", "Confirm Password:")) self.rePassword.setPlaceholderText(_translate("addUserDialog", "Confirm your password")) - self.emailIDLabel.setText(_translate("addUserDialog", "Email:")) - self.usernameLabel.setText(_translate("addUserDialog", "Username:")) diff --git a/mslib/msui/qt5/ui_mscolab_connect_dialog.py b/mslib/msui/qt5/ui_mscolab_connect_dialog.py index 93f8ee09b..d6dfbf6a1 100644 --- a/mslib/msui/qt5/ui_mscolab_connect_dialog.py +++ b/mslib/msui/qt5/ui_mscolab_connect_dialog.py @@ -2,9 +2,10 @@ # Form implementation generated from reading ui file 'ui_mscolab_connect_dialog.ui' # -# Created by: PyQt5 UI code generator 5.12.3 +# Created by: PyQt5 UI code generator 5.15.9 # -# WARNING! All changes made in this file will be lost! +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. from PyQt5 import QtCore, QtGui, QtWidgets @@ -13,7 +14,7 @@ class Ui_MSColabConnectDialog(object): def setupUi(self, MSColabConnectDialog): MSColabConnectDialog.setObjectName("MSColabConnectDialog") - MSColabConnectDialog.resize(478, 271) + MSColabConnectDialog.resize(446, 332) self.gridLayout_4 = QtWidgets.QGridLayout(MSColabConnectDialog) self.gridLayout_4.setObjectName("gridLayout_4") self.horizontalLayout_2 = QtWidgets.QHBoxLayout() @@ -83,40 +84,47 @@ def setupUi(self, MSColabConnectDialog): self.newUsernameLe = QtWidgets.QLineEdit(self.newuserPage) self.newUsernameLe.setObjectName("newUsernameLe") self.gridLayout_2.addWidget(self.newUsernameLe, 1, 1, 1, 1) - self.newPasswordLabel = QtWidgets.QLabel(self.newuserPage) - self.newPasswordLabel.setObjectName("newPasswordLabel") - self.gridLayout_2.addWidget(self.newPasswordLabel, 3, 0, 1, 1, QtCore.Qt.AlignRight) - self.newConfirmPasswordLabel = QtWidgets.QLabel(self.newuserPage) - self.newConfirmPasswordLabel.setObjectName("newConfirmPasswordLabel") - self.gridLayout_2.addWidget(self.newConfirmPasswordLabel, 4, 0, 1, 1, QtCore.Qt.AlignRight) self.newUserTopicLabel = QtWidgets.QLabel(self.newuserPage) font = QtGui.QFont() font.setPointSize(16) self.newUserTopicLabel.setFont(font) self.newUserTopicLabel.setObjectName("newUserTopicLabel") - self.gridLayout_2.addWidget(self.newUserTopicLabel, 0, 1, 1, 1, QtCore.Qt.AlignLeft) + self.gridLayout_2.addWidget(self.newUserTopicLabel, 0, 1, 1, 1) self.newEmailLe = QtWidgets.QLineEdit(self.newuserPage) self.newEmailLe.setObjectName("newEmailLe") - self.gridLayout_2.addWidget(self.newEmailLe, 2, 1, 1, 1) - self.newEmailLabel = QtWidgets.QLabel(self.newuserPage) - self.newEmailLabel.setObjectName("newEmailLabel") - self.gridLayout_2.addWidget(self.newEmailLabel, 2, 0, 1, 1, QtCore.Qt.AlignRight) + self.gridLayout_2.addWidget(self.newEmailLe, 8, 1, 1, 1) self.newUserBb = QtWidgets.QDialogButtonBox(self.newuserPage) self.newUserBb.setLayoutDirection(QtCore.Qt.LeftToRight) self.newUserBb.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) self.newUserBb.setObjectName("newUserBb") - self.gridLayout_2.addWidget(self.newUserBb, 5, 1, 1, 1, QtCore.Qt.AlignLeft) + self.gridLayout_2.addWidget(self.newUserBb, 11, 1, 1, 1, QtCore.Qt.AlignLeft) self.newPasswordLe = QtWidgets.QLineEdit(self.newuserPage) self.newPasswordLe.setEchoMode(QtWidgets.QLineEdit.Password) self.newPasswordLe.setObjectName("newPasswordLe") - self.gridLayout_2.addWidget(self.newPasswordLe, 3, 1, 1, 1) - self.newUsernameLabel = QtWidgets.QLabel(self.newuserPage) - self.newUsernameLabel.setObjectName("newUsernameLabel") - self.gridLayout_2.addWidget(self.newUsernameLabel, 1, 0, 1, 1, QtCore.Qt.AlignRight) + self.gridLayout_2.addWidget(self.newPasswordLe, 9, 1, 1, 1) + self.newEmailLabel = QtWidgets.QLabel(self.newuserPage) + self.newEmailLabel.setObjectName("newEmailLabel") + self.gridLayout_2.addWidget(self.newEmailLabel, 8, 0, 1, 1, QtCore.Qt.AlignRight) self.newConfirmPasswordLe = QtWidgets.QLineEdit(self.newuserPage) self.newConfirmPasswordLe.setEchoMode(QtWidgets.QLineEdit.Password) self.newConfirmPasswordLe.setObjectName("newConfirmPasswordLe") - self.gridLayout_2.addWidget(self.newConfirmPasswordLe, 4, 1, 1, 1) + self.gridLayout_2.addWidget(self.newConfirmPasswordLe, 10, 1, 1, 1) + self.newFullnameLe = QtWidgets.QLineEdit(self.newuserPage) + self.newFullnameLe.setObjectName("newFullnameLe") + self.gridLayout_2.addWidget(self.newFullnameLe, 2, 1, 1, 1) + self.newConfirmPasswordLabel = QtWidgets.QLabel(self.newuserPage) + self.newConfirmPasswordLabel.setObjectName("newConfirmPasswordLabel") + self.gridLayout_2.addWidget(self.newConfirmPasswordLabel, 10, 0, 1, 1, QtCore.Qt.AlignRight) + self.newPasswordLabel = QtWidgets.QLabel(self.newuserPage) + self.newPasswordLabel.setObjectName("newPasswordLabel") + self.gridLayout_2.addWidget(self.newPasswordLabel, 9, 0, 1, 1, QtCore.Qt.AlignRight) + self.newFullnameLabel = QtWidgets.QLabel(self.newuserPage) + self.newFullnameLabel.setMinimumSize(QtCore.QSize(107, 25)) + self.newFullnameLabel.setObjectName("newFullnameLabel") + self.gridLayout_2.addWidget(self.newFullnameLabel, 2, 0, 1, 1) + self.newUsernameLabel = QtWidgets.QLabel(self.newuserPage) + self.newUsernameLabel.setObjectName("newUsernameLabel") + self.gridLayout_2.addWidget(self.newUsernameLabel, 1, 0, 1, 1) self.stackedWidget.addWidget(self.newuserPage) self.httpAuthPage = QtWidgets.QWidget() self.httpAuthPage.setObjectName("httpAuthPage") @@ -198,15 +206,14 @@ def setupUi(self, MSColabConnectDialog): self.gridLayout_4.addLayout(self.statusHL, 4, 0, 1, 1) self.retranslateUi(MSColabConnectDialog) - self.stackedWidget.setCurrentIndex(3) + self.stackedWidget.setCurrentIndex(1) QtCore.QMetaObject.connectSlotsByName(MSColabConnectDialog) MSColabConnectDialog.setTabOrder(self.urlCb, self.connectBtn) MSColabConnectDialog.setTabOrder(self.connectBtn, self.loginEmailLe) MSColabConnectDialog.setTabOrder(self.loginEmailLe, self.loginPasswordLe) MSColabConnectDialog.setTabOrder(self.loginPasswordLe, self.loginBtn) MSColabConnectDialog.setTabOrder(self.loginBtn, self.addUserBtn) - MSColabConnectDialog.setTabOrder(self.addUserBtn, self.newUsernameLe) - MSColabConnectDialog.setTabOrder(self.newUsernameLe, self.newEmailLe) + MSColabConnectDialog.setTabOrder(self.addUserBtn, self.newEmailLe) MSColabConnectDialog.setTabOrder(self.newEmailLe, self.newPasswordLe) MSColabConnectDialog.setTabOrder(self.newPasswordLe, self.newConfirmPasswordLe) MSColabConnectDialog.setTabOrder(self.newConfirmPasswordLe, self.httpPasswordLe) @@ -231,14 +238,16 @@ def retranslateUi(self, MSColabConnectDialog): self.loginEmailLe.setPlaceholderText(_translate("MSColabConnectDialog", "Email ID")) self.loginPasswordLe.setPlaceholderText(_translate("MSColabConnectDialog", "Password")) self.newUsernameLe.setPlaceholderText(_translate("MSColabConnectDialog", "John Doe")) - self.newPasswordLabel.setText(_translate("MSColabConnectDialog", "Password:")) - self.newConfirmPasswordLabel.setText(_translate("MSColabConnectDialog", "Confirm Password:")) self.newUserTopicLabel.setText(_translate("MSColabConnectDialog", "New User Details")) self.newEmailLe.setPlaceholderText(_translate("MSColabConnectDialog", "johndoe@gmail.com")) - self.newEmailLabel.setText(_translate("MSColabConnectDialog", "Email:")) self.newPasswordLe.setPlaceholderText(_translate("MSColabConnectDialog", "New Password")) - self.newUsernameLabel.setText(_translate("MSColabConnectDialog", "Username:")) + self.newEmailLabel.setText(_translate("MSColabConnectDialog", "Email:")) self.newConfirmPasswordLe.setPlaceholderText(_translate("MSColabConnectDialog", "Confirm New Password")) + self.newFullnameLe.setPlaceholderText(_translate("MSColabConnectDialog", "John Michael Doe")) + self.newConfirmPasswordLabel.setText(_translate("MSColabConnectDialog", "Confirm Password:")) + self.newPasswordLabel.setText(_translate("MSColabConnectDialog", "Password:")) + self.newFullnameLabel.setText(_translate("MSColabConnectDialog", "

Fullname:

")) + self.newUsernameLabel.setText(_translate("MSColabConnectDialog", "

Username:

")) self.httpTopicLabel.setText(_translate("MSColabConnectDialog", "HTTP Server Authentication")) self.httpPasswordLe.setPlaceholderText(_translate("MSColabConnectDialog", "Server Auth Password")) self.httpPasswordLabel.setText(_translate("MSColabConnectDialog", "Password:")) diff --git a/mslib/msui/qt5/ui_mscolab_profile_dialog.py b/mslib/msui/qt5/ui_mscolab_profile_dialog.py index 2006db807..131ff5631 100644 --- a/mslib/msui/qt5/ui_mscolab_profile_dialog.py +++ b/mslib/msui/qt5/ui_mscolab_profile_dialog.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'mslib/msui/ui/ui_mscolab_profile_dialog.ui' +# Form implementation generated from reading ui file 'ui_mscolab_profile_dialog.ui' # # Created by: PyQt5 UI code generator 5.15.9 # -# WARNING! All changes made in this file will be lost! +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. from PyQt5 import QtCore, QtGui, QtWidgets @@ -13,21 +14,23 @@ class Ui_ProfileWindow(object): def setupUi(self, ProfileWindow): ProfileWindow.setObjectName("ProfileWindow") - ProfileWindow.resize(387, 149) + ProfileWindow.resize(387, 200) self.gridLayout = QtWidgets.QGridLayout(ProfileWindow) self.gridLayout.setObjectName("gridLayout") self.infoGl = QtWidgets.QGridLayout() self.infoGl.setObjectName("infoGl") - self.emailLabel_2 = QtWidgets.QLabel(ProfileWindow) - self.emailLabel_2.setText("") - self.emailLabel_2.setObjectName("emailLabel_2") - self.infoGl.addWidget(self.emailLabel_2, 1, 2, 1, 1) + self.label_5 = QtWidgets.QLabel(ProfileWindow) + self.label_5.setObjectName("label_5") + self.infoGl.addWidget(self.label_5, 3, 1, 1, 1, QtCore.Qt.AlignLeft) + self.label_2 = QtWidgets.QLabel(ProfileWindow) + self.label_2.setObjectName("label_2") + self.infoGl.addWidget(self.label_2, 1, 1, 1, 1, QtCore.Qt.AlignLeft) + self.label_3 = QtWidgets.QLabel(ProfileWindow) + self.label_3.setObjectName("label_3") + self.infoGl.addWidget(self.label_3, 2, 1, 1, 1, QtCore.Qt.AlignLeft) self.label = QtWidgets.QLabel(ProfileWindow) self.label.setObjectName("label") self.infoGl.addWidget(self.label, 0, 1, 1, 1, QtCore.Qt.AlignLeft) - self.emailLabel = QtWidgets.QLabel(ProfileWindow) - self.emailLabel.setObjectName("emailLabel") - self.infoGl.addWidget(self.emailLabel, 1, 0, 1, 1) self.usernameLabel = QtWidgets.QLabel(ProfileWindow) self.usernameLabel.setObjectName("usernameLabel") self.infoGl.addWidget(self.usernameLabel, 0, 0, 1, 1) @@ -35,24 +38,31 @@ def setupUi(self, ProfileWindow): self.usernameLabel_2.setText("") self.usernameLabel_2.setObjectName("usernameLabel_2") self.infoGl.addWidget(self.usernameLabel_2, 0, 2, 1, 1) - self.label_3 = QtWidgets.QLabel(ProfileWindow) - self.label_3.setObjectName("label_3") - self.infoGl.addWidget(self.label_3, 2, 1, 1, 1) + self.fullNameLabel = QtWidgets.QLabel(ProfileWindow) + self.fullNameLabel.setObjectName("fullNameLabel") + self.infoGl.addWidget(self.fullNameLabel, 1, 0, 1, 1) + self.fullNameLabel_2 = QtWidgets.QLabel(ProfileWindow) + self.fullNameLabel_2.setText("") + self.fullNameLabel_2.setObjectName("fullNameLabel_2") + self.infoGl.addWidget(self.fullNameLabel_2, 1, 2, 1, 1) + self.emailLabel = QtWidgets.QLabel(ProfileWindow) + self.emailLabel.setObjectName("emailLabel") + self.infoGl.addWidget(self.emailLabel, 2, 0, 1, 1) + self.mscolabURLLabel = QtWidgets.QLabel(ProfileWindow) + self.mscolabURLLabel.setObjectName("mscolabURLLabel") + self.infoGl.addWidget(self.mscolabURLLabel, 3, 0, 1, 1) self.mscolabURLLabel_2 = QtWidgets.QLabel(ProfileWindow) self.mscolabURLLabel_2.setText("") self.mscolabURLLabel_2.setObjectName("mscolabURLLabel_2") - self.infoGl.addWidget(self.mscolabURLLabel_2, 2, 2, 1, 1) - self.label_2 = QtWidgets.QLabel(ProfileWindow) - self.label_2.setObjectName("label_2") - self.infoGl.addWidget(self.label_2, 1, 1, 1, 1, QtCore.Qt.AlignLeft) - self.mscolabURLLabel = QtWidgets.QLabel(ProfileWindow) - self.mscolabURLLabel.setObjectName("mscolabURLLabel") - self.infoGl.addWidget(self.mscolabURLLabel, 2, 0, 1, 1) + self.infoGl.addWidget(self.mscolabURLLabel_2, 3, 2, 1, 1) + self.emailLabel_2 = QtWidgets.QLabel(ProfileWindow) + self.emailLabel_2.setText("") + self.emailLabel_2.setObjectName("emailLabel_2") + self.infoGl.addWidget(self.emailLabel_2, 2, 2, 1, 1) self.gridLayout.addLayout(self.infoGl, 0, 0, 1, 2) self.gravatarVl = QtWidgets.QVBoxLayout() self.gravatarVl.setObjectName("gravatarVl") self.gravatarLabel = QtWidgets.QLabel(ProfileWindow) - self.gravatarLabel.setText("") self.gravatarLabel.setPixmap(QtGui.QPixmap(":/gravatars/default-gravatars/default.png")) self.gravatarLabel.setScaledContents(True) self.gravatarLabel.setObjectName("gravatarLabel") @@ -69,14 +79,7 @@ def setupUi(self, ProfileWindow): self.uploadImageBtn.setObjectName("uploadImageBtn") self.horizontalLayout.addWidget(self.uploadImageBtn) self.buttonBox = QtWidgets.QDialogButtonBox(ProfileWindow) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.buttonBox.sizePolicy().hasHeightForWidth()) - self.buttonBox.setSizePolicy(sizePolicy) - self.buttonBox.setMouseTracking(False) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Ok) - self.buttonBox.setCenterButtons(False) self.buttonBox.setObjectName("buttonBox") self.horizontalLayout.addWidget(self.buttonBox, 0, QtCore.Qt.AlignHCenter) self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 3) @@ -87,14 +90,14 @@ def setupUi(self, ProfileWindow): def retranslateUi(self, ProfileWindow): _translate = QtCore.QCoreApplication.translate ProfileWindow.setWindowTitle(_translate("ProfileWindow", "MSColab Profile")) + self.label_5.setText(_translate("ProfileWindow", ":")) + self.label_2.setText(_translate("ProfileWindow", ":")) + self.label_3.setText(_translate("ProfileWindow", ":")) self.label.setText(_translate("ProfileWindow", ":")) + self.usernameLabel.setText(_translate("ProfileWindow", "Username")) + self.fullNameLabel.setText(_translate("ProfileWindow", "Full Name")) self.emailLabel.setText(_translate("ProfileWindow", "Email")) - self.usernameLabel.setText(_translate("ProfileWindow", "Name")) - self.label_3.setText(_translate("ProfileWindow", ":")) - self.label_2.setText(_translate("ProfileWindow", ":")) self.mscolabURLLabel.setText(_translate("ProfileWindow", "Mscolab")) self.deleteAccountBtn.setText(_translate("ProfileWindow", "Delete Account")) self.uploadImageBtn.setText(_translate("ProfileWindow", "Change Avatar")) - - from . import resources_rc diff --git a/mslib/msui/ui/ui_add_user.ui b/mslib/msui/ui/ui_add_user_dialog.ui similarity index 85% rename from mslib/msui/ui/ui_add_user.ui rename to mslib/msui/ui/ui_add_user_dialog.ui index b67a29c58..6bdb396b4 100644 --- a/mslib/msui/ui/ui_add_user.ui +++ b/mslib/msui/ui/ui_add_user_dialog.ui @@ -7,7 +7,7 @@ 0 0 375 - 232 + 293 @@ -25,11 +25,18 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - -1 + 7 14 + + + + Username: + + + @@ -37,21 +44,45 @@ + + + + Fullname: + + + + + + + + + John Michael Doe + + + + + + + Email: + + + + johndoe@gmail.com - + Password: - + QLineEdit::Password @@ -61,14 +92,14 @@ - + Confirm Password: - + QLineEdit::Password @@ -78,19 +109,8 @@ - - - - Email: - - - - - - - Username: - - + + diff --git a/mslib/msui/ui/ui_mscolab_connect_dialog.ui b/mslib/msui/ui/ui_mscolab_connect_dialog.ui index 595eee1dd..7c08f5ed9 100644 --- a/mslib/msui/ui/ui_mscolab_connect_dialog.ui +++ b/mslib/msui/ui/ui_mscolab_connect_dialog.ui @@ -6,8 +6,8 @@ 0 0 - 478 - 271 + 446 + 332 @@ -15,7 +15,7 @@ - + @@ -68,7 +68,7 @@ - 3 + 1 @@ -182,21 +182,7 @@ - - - - Password: - - - - - - - Confirm Password: - - - - + @@ -208,21 +194,14 @@ - + johndoe@gmail.com - - - - Email: - - - - + Qt::LeftToRight @@ -232,7 +211,7 @@ - + QLineEdit::Password @@ -242,14 +221,14 @@ - - + + - Username: + Email: - + QLineEdit::Password @@ -259,6 +238,47 @@ + + + + John Michael Doe + + + + + + + Confirm Password: + + + + + + + Password: + + + + + + + + 107 + 25 + + + + <html><head/><body><p align="right">Fullname:</p></body></html> + + + + + + + <html><head/><body><p align="right">Username:</p></body></html> + + + @@ -453,7 +473,6 @@ loginPasswordLe loginBtn addUserBtn - newUsernameLe newEmailLe newPasswordLe newConfirmPasswordLe diff --git a/mslib/msui/ui/ui_mscolab_profile_dialog.ui b/mslib/msui/ui/ui_mscolab_profile_dialog.ui index b41cd361b..c9498c20f 100644 --- a/mslib/msui/ui/ui_mscolab_profile_dialog.ui +++ b/mslib/msui/ui/ui_mscolab_profile_dialog.ui @@ -7,7 +7,7 @@ 0 0 387 - 149 + 200 @@ -16,31 +16,38 @@ - - + + - + : - - + + : - - + + - Email + : + + + + + + + : - Name + Username @@ -51,43 +58,54 @@ - - + + - : + Full Name - - + + - - + + - : + Email - + Mscolab + + + + + + + + + + + + + + - - - :/gravatars/default-gravatars/default.png @@ -125,21 +143,9 @@ - - - 0 - 0 - - - - false - QDialogButtonBox::Ok - - false - diff --git a/tests/_test_msui/test_mscolab.py b/tests/_test_msui/test_mscolab.py index ad00b1ec2..bfd0c391f 100644 --- a/tests/_test_msui/test_mscolab.py +++ b/tests/_test_msui/test_mscolab.py @@ -239,7 +239,7 @@ def assert_(): assert self.main_window.mscolab.connect_window is None qtbot.wait_until(assert_) - def _create_user(self, username, email, password): + def _create_user(self, username, email, password, fullname=""): QtTest.QTest.mouseClick(self.window.addUserBtn, QtCore.Qt.LeftButton) self.window.newUsernameLe.setText(str(username)) self.window.newEmailLe.setText(str(email)) diff --git a/tests/utils.py b/tests/utils.py index b7a47b7e9..39600b74d 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -122,8 +122,8 @@ def mscolab_register_user(app, msc_url, email, password, username): return response -def mscolab_register_and_login(app, msc_url, email, password, username): - register_user(email, password, username) +def mscolab_register_and_login(app, msc_url, email, password, username, fullname=""): + register_user(email, password, username, fullname) data = { 'email': email, 'password': password @@ -179,8 +179,8 @@ def mscolab_create_content(app, msc_url, data, path_name='example', content=None return response -def mscolab_delete_all_operations(app, msc_url, email, password, username): - response = mscolab_register_and_login(app, msc_url, email, password, username) +def mscolab_delete_all_operations(app, msc_url, email, password, username, fullname=""): + response = mscolab_register_and_login(app, msc_url, email, password, username, fullname) data = json.loads(response.get_data(as_text=True)) url = urljoin(msc_url, 'operations') response = app.test_client().get(url, data=data) @@ -200,8 +200,8 @@ def mscolab_create_operation(app, msc_url, response, path='f', description='desc return data, response -def mscolab_get_operation_id(app, msc_url, email, password, username, path): - response = mscolab_register_and_login(app, msc_url, email, password, username) +def mscolab_get_operation_id(app, msc_url, email, password, username, fullname, path): + response = mscolab_register_and_login(app, msc_url, email, password, username, fullname) data = json.loads(response.get_data(as_text=True)) url = urljoin(msc_url, 'operations') response = app.test_client().get(url, data=data)