diff --git a/Account.py b/Account.py index e068c1c..1172fcf 100644 --- a/Account.py +++ b/Account.py @@ -1,6 +1,5 @@ """ Account Management - TODO: change password and add userName """ @@ -38,7 +37,6 @@ def logIn(email, psd): IF USER NOT EXISTS, return string -1: user not exists 2: already logged in - """ if DB.checkUserExists(email): @@ -92,7 +90,7 @@ def promoteToSU(email): return True -def createGuest(email, password): +def createGuest(email, password,name, techInterest): """ For GU :param email: @@ -100,7 +98,7 @@ def createGuest(email, password): :return: """ if not DB.checkUserExists(email): - DB.addUser(email, password, '2') # 2 for GU + DB.addUser(email, password, '2', name, techInterest) # 2 for GU return True diff --git a/Control.py b/Control.py index 9117032..dceab1a 100644 --- a/Control.py +++ b/Control.py @@ -9,7 +9,6 @@ def userType(email): """ - :param email: :return: return the user type of current user """ @@ -25,7 +24,6 @@ def userType(email): def ROOTUSER(email): """ GUI guide: 在初始登录界面,如果数据库有SU用户,可以直接登录SU - 在OU用户登录后,出现一个管理按钮。如果数据库里没有SU,弹窗询问是否升级为SU 如果选择是,当前OU升级为SU :param email: @@ -44,7 +42,7 @@ def signUp(email, password, name, techInterest): :return: """ if password == "": - if Account.createGuest(email, password): + if Account.createGuest(email, password, name, techInterest): return 0 if Account.createAcc(email, password, name, techInterest): @@ -55,7 +53,6 @@ def signUp(email, password, name, techInterest): def signIn(email, password): """ - :param email: required :param password: required only for OU and SU, GU can leave it blank :return: login status in string format @@ -92,4 +89,4 @@ def manage(email): if __name__ == '__main__': - signUp('test','123','haoran',['computer','sleep']) \ No newline at end of file + print(signUp('testababa123','','guest',['computer','sleep'])) \ No newline at end of file diff --git a/DB.py b/DB.py index bb5e684..59c483d 100644 --- a/DB.py +++ b/DB.py @@ -1,8 +1,7 @@ from firebase_admin import db -from Firebase_cred.Firebase import initial -from time import strftime, localtime +from Firebase_cred import Firebase -initial() +Firebase.initial() root = db.reference() tabooWord = root.child('Taboo_word') @@ -36,7 +35,7 @@ def addUser(email, psd, userType, name, techInterest): 'Password': psd, 'User_type': userType, 'Logged_in': False, - 'Name': name, + 'Name': name }) for interest in techInterest: @@ -83,7 +82,6 @@ def changeUserType(email, userType): def changeLoginStat(email, stat): """ - :param email: :param stat: False for logged out, True for logged in :return: @@ -198,4 +196,4 @@ def getApplDecision(email): if __name__ == '__main__': - print(getApplDecision('guest')) \ No newline at end of file + print(SUexists()) \ No newline at end of file diff --git a/Document.py b/Document.py index 39fed7e..a1f4635 100644 --- a/Document.py +++ b/Document.py @@ -51,7 +51,6 @@ def saveDoc(email, doc, fileName): def listallfiles(email): """ - :param email: :return: list of all the current user documents """ @@ -73,7 +72,6 @@ def listallfiles(email): def listallhistory(email, filename): """ - :param filename: :return: list of edit history for a file """ @@ -99,7 +97,6 @@ def getLastestVersion(email, filename): def openfile(email, fileOwner, filename, version): """ - :param email: :param filename: :param version: if blank then open the newest one, use listallhistory to get one of the version @@ -115,10 +112,10 @@ def openfile(email, fileOwner, filename, version): url = "https://firebasestorage.googleapis.com/v0/b/llhc-db662.appspot.com/o/savedocs%2F" + DB.removeIllegalChar( email) + "%2F" + filename + "%2F" + version + "?alt=media" - urllib.request.urlretrieve(url, "cache") - file = open('cache', "r") - fileout = file.read() - file.close() + urllib.request.urlretrieve(url, "../cache") + #file = open('../cache', "r") + #fileout = file.read() + #file.close() if not email == fileOwner: ref = DB.user.child(DB.removeIllegalChar(email)).child("View_counter") @@ -130,7 +127,7 @@ def openfile(email, fileOwner, filename, version): } }) - return fileout + #return fileout def isFileLocked(email, filename): @@ -171,7 +168,6 @@ def changeLock(email, filename): def getMostview(): """ - :return: the three of the most viewed docs """ @@ -221,4 +217,6 @@ def getPermissionFiles(permissionType): #print(getMostview()) #print(listallfiles('guest')) #setPermission('viewtest','test1','public') - getPermissionFiles('public') \ No newline at end of file + #print(getMostview()) + #saveDoc('hrgutou@gmail.com','test.txt','test2') + pass \ No newline at end of file diff --git a/GUI/Controller.py b/GUI/Controller.py deleted file mode 100644 index 6a3dcac..0000000 --- a/GUI/Controller.py +++ /dev/null @@ -1,36 +0,0 @@ -import sys -from PyQt5 import QtCore, QtWidgets -from GUI.login import Login -from GUI.Signup import Signup - - -class Controller: - - def __init__(self): - pass - - def show_login(self): - self.login = Login() - if self.login.signup_event(): - self.login.switch_window.connect(self.show_signup) - - else: - print("not a new account") - self.login.show() - - def show_signup(self): - self.login.email_field.setText("") - self.login.password_field.setText("") - self.window = Signup() - self.window.show() - - -def main(): - app = QtWidgets.QApplication(sys.argv) - controller = Controller() - controller.show_login() - sys.exit(app.exec_()) - - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/GUI/OUSUmainwindow.py b/GUI/OUSUmainwindow.py new file mode 100644 index 0000000..0858d81 --- /dev/null +++ b/GUI/OUSUmainwindow.py @@ -0,0 +1,155 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'mainwindow.ui' +# +# Created by: PyQt5 UI code generator 5.11.3 +# +# WARNING! All changes made in this file will be lost! +import time + +from PyQt5 import QtCore, QtGui, QtWidgets +from PyQt5.QtWidgets import QDialog +import User, DB +#from GUI.editor import Ui_MainWindow as EDITOR +from GUI import editor_Dialog +from GUI.editor_Dialog import Ui_Dialog as UI_Dialog_editor + + +import atexit + +class OUSU_mainwindow_Dialog(QDialog): + def setupUi(self, Dialog, email): + QtWidgets.QWidget.__init__(self) + + self.email = email + userType = DB.currentUserGroup(email) + + if userType == 1: + self.userObject = User.OU(email) ######## object + else: + self.userObject = User.SU(email) ######## object + + + Dialog.setObjectName("Dialog") + Dialog.resize(792, 563) + Dialog.setStyleSheet("QDialog {background-image: url(images/ou_su_image.JPG)\n" +"}") + self.welcome_label = QtWidgets.QLabel(Dialog) + self.welcome_label.setGeometry(QtCore.QRect(30, 20, 181, 31)) + self.welcome_label.setStyleSheet("#welcome_label{\n" +" color: purple\n" +"}") + self.welcome_label.setObjectName("welcome_label") + self.email_label = QtWidgets.QLabel(Dialog) + self.email_label.setGeometry(QtCore.QRect(20, 50, 201, 16)) + self.email_label.setStyleSheet("#email_label{\n" +" color: purple;\n" +"}") + self.email_label.setText("") + self.email_label.setObjectName("email_label") + self.email_label.setText(email) + self.listWidget = QtWidgets.QListWidget(Dialog) + self.listWidget.setGeometry(QtCore.QRect(-5, 141, 811, 421)) + self.listWidget.setObjectName("listWidget") + self.addItem() + + + self.horizontalLayoutWidget = QtWidgets.QWidget(Dialog) + self.horizontalLayoutWidget.setGeometry(QtCore.QRect(430, 40, 341, 83)) + self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget") + self.horizontalLayout = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget) + self.horizontalLayout.setContentsMargins(0, 0, 0, 0) + self.horizontalLayout.setObjectName("horizontalLayout") + self.textEdit = QtWidgets.QTextEdit(self.horizontalLayoutWidget) + self.textEdit.setMaximumSize(QtCore.QSize(16777215, 20)) + self.textEdit.setObjectName("textEdit") + self.horizontalLayout.addWidget(self.textEdit) + self.search_button = QtWidgets.QPushButton(self.horizontalLayoutWidget) + self.search_button.setObjectName("search_button") + self.horizontalLayout.addWidget(self.search_button) + self.manage_button = QtWidgets.QPushButton(Dialog) + self.manage_button.setGeometry(QtCore.QRect(650, 0, 114, 32)) + self.manage_button.setObjectName("manage_button") + self.manage_button.setText("Manage") + self.manage_button.setVisible(False) + + # check if SU exist + if not DB.SUexists(): + print("not exist ") + self.manage_button.setVisible(True) + else: + if DB.currentUserGroup(email) == 0: + self.manage_button.setVisible(True) + #########################3 button event ######################## + self.manage_button.clicked.connect(self.manage_event) + self.listWidget.itemActivated.connect(self.listClickListener) + ####################################################################### + + + self.retranslateUi(Dialog) + QtCore.QMetaObject.connectSlotsByName(Dialog) + Dialog.setTabOrder(self.textEdit, self.search_button) + + def retranslateUi(self, Dialog): + _translate = QtCore.QCoreApplication.translate + Dialog.setWindowTitle(_translate("Dialog", "Dialog")) + self.welcome_label.setText(_translate("Dialog", "

Welcome,

")) + self.search_button.setText(_translate("Dialog", "Search")) + + def listClickListener(self,item): + clickedTarget = item.text() + if not clickedTarget == "New Document": + clickedTarget = clickedTarget.replace(" ","_") + self.userObject.openDoc(self.email, clickedTarget, "") + #this will store a cache file in disk for BE to read + editor_Dialog.loadBE() + time.sleep(1) + self.editorWindow = QtWidgets.QDialog() + self.editor = UI_Dialog_editor() + self.editor.setupUi(self.editorWindow) + self.editor.setFileName(clickedTarget) + self.editorWindow.exec_() + self.editor.uploadDoc(self.email, False) + else: + ### This will create a new document ### + editor_Dialog.loadBE() + time.sleep(1) + self.editorWindow = QtWidgets.QDialog() + self.editor = UI_Dialog_editor() + self.editor.setupUi(self.editorWindow) + self.editorWindow.exec_() + self.editor.uploadDoc(self.email, True)#true because it is new file + + def manage_event(self): + print("manage button is clicked") + + def addItem(self): + self.listWidget.addItem("New Document") + + listofFile = self.userObject.listallfiles() + if listofFile == 0: + listofFile = self.userObject.mostPopular() + # got the list of tuples + + + # else: + # for file in listofFile: + # + # self.listWidget.addItem(file.replace("_", " ")) + + + ##if click New Document, call editor + + + #def clickList(self): + +def exitEvent(): + pass +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + Dialog = QtWidgets.QDialog() + ui = OUSU_mainwindow_Dialog() + ui.setupUi(Dialog) + Dialog.show() + sys.exit(app.exec_()) \ No newline at end of file diff --git a/GUI/Signup.py b/GUI/Signup.py index c354ef2..303f625 100644 --- a/GUI/Signup.py +++ b/GUI/Signup.py @@ -1,30 +1,38 @@ -from PyQt5 import QtCore, QtWidgets -from PyQt5.QtCore import QSize -from PyQt5.QtGui import QImage, QPalette, QBrush +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'signup.ui' +# +# Created by: PyQt5 UI code generator 5.11.3 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets import Control -class Signup(QtWidgets.QWidget): - switch_window = QtCore.pyqtSignal() +import sys - def __init__(self): +class Signup_Dialog(QtWidgets.QWidget): + def setupUi(self, Dialog): QtWidgets.QWidget.__init__(self) - self.setWindowTitle('Signup Page') - oImage = QImage("images/signup_image.jpeg") - sImage = oImage.scaled(QSize(605, 458)) # resize Image to widgets size - palette = QPalette() - palette.setBrush(10, QBrush(sImage)) # 10 = Windowrole - self.setPalette(palette) - self.resize(605, 458) - self.setMinimumSize(QtCore.QSize(605, 458)) - self.setMaximumSize(QtCore.QSize(605, 458)) - self.setBaseSize(QtCore.QSize(605, 358)) - - self.signup_button = QtWidgets.QPushButton(self) + Dialog.setObjectName("Dialog") + Dialog.setEnabled(True) + Dialog.resize(590, 458) + Dialog.setMinimumSize(QtCore.QSize(590, 458)) + Dialog.setMaximumSize(QtCore.QSize(594, 458)) + Dialog.setBaseSize(QtCore.QSize(590, 458)) + Dialog.setStyleSheet("QDialog{\n" +" background-image: url(images/signup_image.jpeg);\n" +"}\n" +"QPushButton{\n" +" background-color:rgb(255, 255, 255)\n" +" border: none;\n" +"}") + self.signup_button = QtWidgets.QPushButton(Dialog) self.signup_button.setGeometry(QtCore.QRect(230, 410, 93, 28)) self.signup_button.setObjectName("signup_button") ################################# signup button event ########### self.signup_button.clicked.connect(self.signup_event) ################################################################# - self.formLayoutWidget_2 = QtWidgets.QWidget(self) + self.formLayoutWidget_2 = QtWidgets.QWidget(Dialog) self.formLayoutWidget_2.setGeometry(QtCore.QRect(20, 240, 411, 173)) self.formLayoutWidget_2.setObjectName("formLayoutWidget_2") self.formLayout_2 = QtWidgets.QFormLayout(self.formLayoutWidget_2) @@ -53,7 +61,7 @@ def __init__(self): self.password_field = QtWidgets.QLineEdit(self.formLayoutWidget_2) self.password_field.setEchoMode(QtWidgets.QLineEdit.PasswordEchoOnEdit) self.password_field.setObjectName("password_field") - self.password_field.setPlaceholderText("Create a password") + self.password_field.setPlaceholderText("Enter your password") self.formLayout_2.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.password_field) self.label = QtWidgets.QLabel(self.formLayoutWidget_2) self.label.setObjectName("label") @@ -61,17 +69,19 @@ def __init__(self): self.confirm_password_field = QtWidgets.QLineEdit(self.formLayoutWidget_2) self.confirm_password_field.setEchoMode(QtWidgets.QLineEdit.PasswordEchoOnEdit) self.confirm_password_field.setDragEnabled(False) + self.confirm_password_field.setPlaceholderText("") self.confirm_password_field.setObjectName("confirm_password_field") self.confirm_password_field.setPlaceholderText("Confirm your password") self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.confirm_password_field) self.email_field = QtWidgets.QLineEdit(self.formLayoutWidget_2) self.email_field.setText("") + self.email_field.setPlaceholderText("") self.email_field.setObjectName("email_field") self.email_field.setPlaceholderText("Enter your email") self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.email_field) - self.retranslateUi(self) - QtCore.QMetaObject.connectSlotsByName(self) + self.retranslateUi(Dialog) + QtCore.QMetaObject.connectSlotsByName(Dialog) def retranslateUi(self, Dialog): _translate = QtCore.QCoreApplication.translate @@ -90,39 +100,58 @@ def signup_event(self): email = self.email_field.text() password = self.password_field.text() name = self.name_field.text() - techInterest = [self.interest_field.text()] + confirm = self.confirm_password_field.text() + techInterest = self.interest_field.text() print(email) print(password) print(name) print(techInterest) #============================================= + print("this is the value from control: ", Control.signUp(email, password, name, techInterest)) + if (password == confirm): + print("this is the value from control inside of if: ", Control.signUp(email, password, name, techInterest)) + # sign up successful + if Control.signUp(email, password, name, techInterest) == 1: + em = QtWidgets.QMessageBox() + em.setText("Sign Up Successfully") + em.setStandardButtons(QtWidgets.QMessageBox.Ok) + em.exec_() - print("sign up button is pressed") - # sign up successful - if Control.signUp(email, password, name, techInterest) == 1: - em = QtWidgets.QMessageBox() - em.setText("Sign Up Successfully") - em.setStandardButtons(QtWidgets.QMessageBox.Ok) - em.exec_() - if QtWidgets.QMessageBox.Ok: - self.close() - return 1 + # guest user registered + elif Control.signUp(email, password, name, techInterest) == 0: + em = QtWidgets.QMessageBox() + em.setText("Guest User Registered") + em.setStandardButtons(QtWidgets.QMessageBox.Ok) + em.exec_() - # guest user registered - elif Control.signUp(email, password, name, techInterest) == 0: - em = QtWidgets.QMessageBox() - em.setText("Guest User Registered") - em.setStandardButtons(QtWidgets.QMessageBox.Ok) - em.exec_() - return 0 + # account existed, go back to login page + else: + em = QtWidgets.QMessageBox() + em.setIcon(QtWidgets.QMessageBox.Warning) + em.setText("User already existed, please login") + em.setStandardButtons(QtWidgets.QMessageBox.Ok) + em.exec_() + - # account existed, go back to login page else: em = QtWidgets.QMessageBox() em.setIcon(QtWidgets.QMessageBox.Warning) - em.setText("User already existed, please login") + em.setText("Password doesn't match, please try again") em.setStandardButtons(QtWidgets.QMessageBox.Ok) em.exec_() - return -1 + self.password_field.setText("") + self.confirm_password_field.setText("") + + + +if __name__ == "__main__": + + app = QtWidgets.QApplication(sys.argv) + Dialog = QtWidgets.QDialog() + ui = Signup_Dialog() + ui.setupUi(Dialog) + Dialog.show() + sys.exit(app.exec_()) + diff --git a/GUI/form.ui b/GUI/form.ui deleted file mode 100644 index 24454e8..0000000 --- a/GUI/form.ui +++ /dev/null @@ -1,37 +0,0 @@ - - - Form - - - - 0 - 0 - 605 - 458 - - - - - 605 - 458 - - - - - 605 - 458 - - - - - 605 - 458 - - - - Form - - - - - diff --git a/GUI/images/login_image.jpeg b/GUI/images/login_image.jpeg new file mode 100644 index 0000000..b0a6b2d Binary files /dev/null and b/GUI/images/login_image.jpeg differ diff --git a/GUI/images/ou_su_image.JPG b/GUI/images/ou_su_image.JPG new file mode 100644 index 0000000..c82b3ff Binary files /dev/null and b/GUI/images/ou_su_image.JPG differ diff --git a/GUI/images/signup_image.jpeg b/GUI/images/signup_image.jpeg new file mode 100644 index 0000000..38df382 Binary files /dev/null and b/GUI/images/signup_image.jpeg differ diff --git a/GUI/login.py b/GUI/login.py index 33e8352..60de47a 100644 --- a/GUI/login.py +++ b/GUI/login.py @@ -1,36 +1,61 @@ -from PyQt5 import QtCore, QtWidgets +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'login.ui' +# +# Created by: PyQt5 UI code generator 5.11.3 +# +# WARNING! All changes made in this file will be lost! + +import sys +from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtCore import QSize from PyQt5.QtGui import QImage, QPalette, QBrush -import Control +import User +import Control +import DB +from GUI.signup import Signup_Dialog +from GUI.OUSUmainwindow import OUSU_mainwindow_Dialog -class Login(QtWidgets.QWidget): - switch_window = QtCore.pyqtSignal() - def __init__(self): +class Ui_Dialog(QtWidgets.QWidget): + def setupUi(self, Dialog): QtWidgets.QWidget.__init__(self) - self.setWindowTitle('Login Page') + Dialog.setObjectName("Dialog") + Dialog.resize(605, 458) + Dialog.setMinimumSize(QtCore.QSize(605, 458)) + Dialog.setMaximumSize(QtCore.QSize(605, 458)) + Dialog.setBaseSize(QtCore.QSize(605, 358)) + Dialog.setStyleSheet("QDialog{\n" +" background-image: url(images/login_image.jpeg)\n" +"}\n" +"QPushButton{\n" +" background-color:rgb(255, 255, 255)\n" +" border: none;\n" +"}") + Dialog.setSizeGripEnabled(False) + Dialog.setWindowTitle('Login Page') oImage = QImage("images/login_image.jpeg") sImage = oImage.scaled(QSize(605, 458)) # resize Image to widgets size palette = QPalette() palette.setBrush(10, QBrush(sImage)) # 10 = Windowrole - self.setPalette(palette) - self.resize(605, 458) - self.setMinimumSize(QtCore.QSize(605, 458)) - self.setMaximumSize(QtCore.QSize(605, 458)) - self.setBaseSize(QtCore.QSize(605, 358)) + Dialog.setPalette(palette) + Dialog.resize(605, 458) + Dialog.setMinimumSize(QtCore.QSize(605, 458)) + Dialog.setMaximumSize(QtCore.QSize(605, 458)) + Dialog.setBaseSize(QtCore.QSize(605, 358)) - self.login_button = QtWidgets.QPushButton(self) + self.login_button = QtWidgets.QPushButton(Dialog) self.login_button.setGeometry(QtCore.QRect(300, 390, 93, 28)) #########################3 Login button event ######################## self.login_button.clicked.connect(self.login_event) ####################################################################### - self.signup_button = QtWidgets.QPushButton(self) + self.signup_button = QtWidgets.QPushButton(Dialog) self.signup_button.setGeometry(QtCore.QRect(200, 390, 93, 31)) #########################3 Signup button event ######################## self.signup_button.clicked.connect(self.signup_event) ####################################################################### - self.formLayoutWidget = QtWidgets.QWidget(self) + self.formLayoutWidget = QtWidgets.QWidget(Dialog) self.formLayoutWidget.setGeometry(QtCore.QRect(140, 300, 291, 81)) self.formLayoutWidget.setObjectName("formLayoutWidget") self.formLayout = QtWidgets.QFormLayout(self.formLayoutWidget) @@ -53,9 +78,10 @@ def __init__(self): self.label = QtWidgets.QLabel(self.formLayoutWidget) self.label.setObjectName("label") self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label) + self.retranslateUi(Dialog) + QtCore.QMetaObject.connectSlotsByName(Dialog) - self.retranslateUi(self) - QtCore.QMetaObject.connectSlotsByName(self) + page_status = 0 def retranslateUi(self, Dialog): _translate = QtCore.QCoreApplication.translate @@ -65,6 +91,7 @@ def retranslateUi(self, Dialog): self.label_2.setText(_translate("Dialog", "Email:")) self.label.setText(_translate("Dialog", "Password:")) + # event handler for login button def login_event(self): print("login is pressed") @@ -76,7 +103,17 @@ def login_event(self): #============================================ - if status == -1: + print("this is status: ", status) + if (not email): + em = QtWidgets.QMessageBox() + em.setIcon(QtWidgets.QMessageBox.Warning) + em.setText("Please enter email!") + em.setStandardButtons(QtWidgets.QMessageBox.Ok) + em.exec_() + self.email_field.setText("") + self.password_field.setText("") + + elif status == -1: em = QtWidgets.QMessageBox() em.setIcon(QtWidgets.QMessageBox.Warning) em.setText("Account not found, Please create an account") @@ -84,10 +121,25 @@ def login_event(self): em.exec_() self.signup_event() + # correct users elif status == 1: - print('here') - self.isIn_event() #!ISSUE + print('login login') + self.mainwinodw = QtWidgets.QDialog() + self.ui = OUSU_mainwindow_Dialog() + self.ui.setupUi(self.mainwinodw, self.email_field.text()) + em = QtWidgets.QMessageBox() + em.setText("Welcome, "+ self.email_field.text()) + em.setStandardButtons(QtWidgets.QMessageBox.Ok) + em.exec_() + Dialog.close() + self.mainwinodw.exec_() + + + Control.signOut(self.email_field.text()) + #===== USER object + + # already login elif status == 2: @@ -100,9 +152,25 @@ def login_event(self): else: # THIS RETURN 3, LAUNCH GUEST UI print("HERE ADD GUEST UI") + def signup_event(self): - self.switch_window.emit() - return -1 + print("sign up button is clicked") + Dialog.close() + self.signUpWindow = QtWidgets.QDialog() + self.ui = Signup_Dialog() + self.ui.setupUi(self.signUpWindow) + self.signUpWindow.exec_() + self.email_field.setText("") + self.password_field.setText("") + Dialog.show() + + + +if __name__ == "__main__": - def isIn(self): - return 1 + app = QtWidgets.QApplication(sys.argv) + Dialog = QtWidgets.QDialog() + ui = Ui_Dialog() + ui.setupUi(Dialog) + Dialog.show() + sys.exit(app.exec_()) \ No newline at end of file diff --git a/GUI/login.ui b/GUI/login.ui new file mode 100644 index 0000000..7bb0ff1 --- /dev/null +++ b/GUI/login.ui @@ -0,0 +1,110 @@ + + + Dialog + + + + 0 + 0 + 605 + 458 + + + + + 605 + 458 + + + + + 605 + 458 + + + + + 605 + 358 + + + + Dialog + + + QDialog{ + background-image: url(Users/kappa/Library/Containers/com.tencent.xinWeChat/Data/Library/Application Support/com.tencent.xinWeChat/2.0b4.0.9/1feec28dbcbbd41c908e5319f9080e3b/Message/MessageTemp/047868fcf45822c2e58d288b5fe5d070/Image/5041543441403_.pic.jpg) +} +QPushButton{ + background-color:rgb(255, 255, 255) + border: none; +} + + + false + + + + + 110 + 320 + 361 + 130 + + + + + + + font: 13pt ".SF NS Text"; + + + Email: + + + + + + + + + + + + + + Password: + + + + + + + QLineEdit::PasswordEchoOnEdit + + + + + + + + + Sign Up + + + + + + + Login + + + + + + + + + + + diff --git a/GUI/mainwindow.ui b/GUI/mainwindow.ui deleted file mode 100644 index 6da9707..0000000 --- a/GUI/mainwindow.ui +++ /dev/null @@ -1,86 +0,0 @@ - - - Dialog - - - - 0 - 0 - 605 - 458 - - - - - 605 - 458 - - - - - 605 - 458 - - - - - 605 - 458 - - - - Dialog - - - - - 450 - 60 - 114 - 32 - - - - Manage - - - - - - 0 - 160 - 611 - 301 - - - - - - - 0 - 40 - 160 - 80 - - - - - - - Welcome, - - - - - - - dadssada - - - - - - - - - diff --git a/GUI/ou_su_mainwindow.ui b/GUI/ou_su_mainwindow.ui new file mode 100644 index 0000000..f12b351 --- /dev/null +++ b/GUI/ou_su_mainwindow.ui @@ -0,0 +1,115 @@ + + + Dialog + + + + 0 + 0 + 792 + 563 + + + + Dialog + + + QDialog {background-image: url(///Users/kappa/Library/Containers/com.tencent.xinWeChat/Data/Library/Application Support/com.tencent.xinWeChat/2.0b4.0.9/1feec28dbcbbd41c908e5319f9080e3b/Message/MessageTemp/047868fcf45822c2e58d288b5fe5d070/File/editabletreemodel/img/IMG_2432.JPG) +} + + + + + 30 + 20 + 91 + 16 + + + + #welcome_label{ + color: purple +} + + + <html><head/><body><p><span style=" font-size:18pt; font-weight:600;">Welcome, </span></p></body></html> + + + + + + 20 + 50 + 201 + 16 + + + + #email_label{ + color: purple; +} + + + + + + + + + 430 + 40 + 341 + 83 + + + + + + + + 16777215 + 20 + + + + + + + + Search + + + + + + + + + 650 + 0 + 114 + 32 + + + + Manage + + + + + + -5 + 141 + 811 + 421 + + + + + + textEdit + search_button + + + + diff --git a/GUI/signup.ui b/GUI/signup.ui new file mode 100644 index 0000000..0b75b1c --- /dev/null +++ b/GUI/signup.ui @@ -0,0 +1,159 @@ + + + Dialog + + + true + + + + 0 + 0 + 590 + 458 + + + + + 590 + 458 + + + + + 594 + 458 + + + + + 590 + 458 + + + + Dialog + + + QDialog{ + background-image: url(Users/kappa/Library/Containers/com.tencent.xinWeChat/Data/Library/Application Support/com.tencent.xinWeChat/2.0b4.0.9/1feec28dbcbbd41c908e5319f9080e3b/Message/MessageTemp/9e20f478899dc29eb19741386f9343c8/Image/541543462213_.pic.jpg); +} +QPushButton{ + background-color:rgb(255, 255, 255) + border: none; +} + + + + + 230 + 410 + 93 + 28 + + + + Sign Up + + + + + + 20 + 240 + 411 + 173 + + + + + + + Email: + + + + + + + Name: + + + + + + + QLineEdit::PasswordEchoOnEdit + + + + + + + + + + Technical Interests: + + + + + + + QLineEdit::PasswordEchoOnEdit + + + + + + + Password: + + + + + + + QLineEdit::PasswordEchoOnEdit + + + + + + + Confirm Your Password: + + + + + + + QLineEdit::PasswordEchoOnEdit + + + false + + + + + + + + + + <html><head/><body><p>sadsad</p></body></html> + + + + + + + + + + + + + + + diff --git a/Taboo.py b/Taboo.py index 3dc57a0..01b0f9d 100644 --- a/Taboo.py +++ b/Taboo.py @@ -1,6 +1,5 @@ import DB - #For SU "=================================================" @@ -20,8 +19,11 @@ def addTaboo(listoftaboo): def getTaboo(): try: listoftaboo = DB.tabooWord.get() - listoftaboo.pop(0) - return listoftaboo + result =[] + for key in listoftaboo: + result.append(listoftaboo[key]) + + return result except Exception as e: print("getTaboo()") @@ -82,4 +84,4 @@ def deleteSuggestTaboo(email, listofword): if __name__ == '__main__': - getSuggestedTaboo() \ No newline at end of file + print(getTaboo()) \ No newline at end of file diff --git a/User.py b/User.py index 39082ff..d3332f9 100644 --- a/User.py +++ b/User.py @@ -7,16 +7,17 @@ Main class for User, subclasses will be SU, OU, and GU. """ -class User(): + +class User: def __init__(self, email): self.email = email - def openDoc(self, fileOwner,filename, version): + def openDoc(self, fileOwner, filename, version): Document.openfile(self.email, fileOwner, filename, version) - def retriveOldVer(self,filename): + def retriveOldVer(self, filename): """:return list of all docs versions""" - Document.listallhistory(self.email,filename) + Document.listallhistory(self.email, filename) def filomplain(self, filename, complain): DB.fileComplain(self.email, filename, complain) @@ -26,7 +27,6 @@ def suggestTaboo(self, listofwords): def getPermission(self, permissionType): """ - :param permissionType: private, public, restricted, shared :return: return all docs with the same permission type in dict{username:[list of filename]} """ @@ -34,23 +34,20 @@ def getPermission(self, permissionType): def mostPopular(self): """ - :return: three tuples of the most viewed documents Format is 'fileOwner','DocName', 'Views' Use open Doc to open the files - CAUTION: check file property before open """ return Document.getMostview() - + def getEmail(self): + return self.email class GU(User): def __init__(self, email): User.__init__(self, email) - - def apply(self, name, techInterests): """ Apply to be an OU @@ -63,10 +60,8 @@ def apply(self, name, techInterests): def applybutton(self): """ - :return: 0 application not found for this GU, call Account.OUapplication(GUemail, name, listoftechInterests) 1 already applied, display error message - """ if DB.getApplDecision(self.email) is None: return 0 @@ -74,15 +69,15 @@ def applybutton(self): return 1 elif DB.getApplDecision(self.email) == 'Denied': return -1 - else: #approved + else: # approved return 2 def GUpromotion(self, psd): - Account.GUpromotion(self.email,psd) + Account.GUpromotion(self.email, psd) class OU(User): - def __init__(self,email): + def __init__(self, email): User.__init__(self, email) def listallfiles(self): @@ -100,11 +95,26 @@ def saveDoc(self, docLocation, filename): else: return "File is locked, save unsuccessful" - def setPermission(self, DocID, permission): + def setPermission(self, filename, permissionINT): """each document default permission is private""" - pass + """ + permission: 1: public 2: restrict 3: shared 4: private + """ - def invitation(self, email):#also need ability to deny or cancel a invitation. + if permissionINT == 1: + permission = "public" + elif permissionINT == 2: + permission = "restrict" + elif permissionINT == 3: + permission = "shared" + elif permissionINT == 4: + permission = "private" + else: + return False + + Document.setPermission(self.email, filename, permission) + + def invitation(self, email): # also need ability to deny or cancel a invitation. pass def sentInvitation(self, email): @@ -121,7 +131,6 @@ def lockFile(self, filename): return Document.isFileLocked(self.email, filename) - def ActionRestrict(self): pass # When the OU has been reported of using taboo word, all the activity under OU @@ -129,13 +138,13 @@ def ActionRestrict(self): def Report(self): pass - #report other OU's update to onwer - #report onwer to SU + # report other OU's update to onwer + # report onwer to SU def search(self): pass - #search file by keyword - #search other user by name or info + # search file by keyword + # search other user by name or info class SU(OU): @@ -144,7 +153,6 @@ def __init__(self, email): def reviewApplication(self): """ - :return: a dictionary for all application """ allApplication = DB.checkApplication() @@ -153,7 +161,6 @@ def reviewApplication(self): def applicationDecision(self, GU, decision): """ - :param GU: :param decision: 1 for approve, 0 for deny :return: @@ -165,8 +172,6 @@ def applicationDecision(self, GU, decision): else: return "Decision input error" - - def getSuggestTaboo(self): """ :return: Return the suggested Taboo word in dictionary. @@ -175,33 +180,32 @@ def getSuggestTaboo(self): def getTaboo(self): """ - :return: current list of taboo words in database. """ return Taboo.getTaboo() def deleteTaboo(self, listofwords): """ - :param listofwords: :return: True when finished deleting """ return Taboo.deleteTaboo(listofwords) - def addTaboo(self, listoftaboo): """ - :param listoftaboo: :return: added words """ if Taboo.addTaboo(listoftaboo): return True - def complain(self,DocID): + def complain(self, DocID): """TODO: dont know what is this""" pass + + if __name__ == "__main__": - newuser = OU('test') - print(newuser.mostPopular()) \ No newline at end of file + newuser = OU('viewtest') + newuser.openDoc('viewtest','fafa','') + #post() \ No newline at end of file