示例#1
0
文件: antigo.py 项目: dezagfx/Pytunes
 def logincheck(self):
     self.username = str(self.lineEdit.text())
     self.password = str(self.lineEdit_2.text())
     if (self.username == "" or self.password == ""):
         messages = "Preencha todos os campos."
         self.label.setStyleSheet("color: red")
         self.label.setText("%s"%messages)
     
     else:
         
         response, ok = server.postServer(
                 'auth/login', 
                 {'user_name' : self.username,'password' : self.password}
         )
         if response['success'] == True:
            # QtWidgets.QMessageBox.information(
            #     self, "Sucesso", "Bem vindo/a: %s"% self.username
            # )
             self.label.setText("Loggin in...")
             session_lib.set_token(response['payload']['token'])
             self.label.setStyleSheet("color: green")
             self.accept()
         else:
             messages = "Login Inválido"
             self.label.setStyleSheet("color: red")
             self.label.setText("%s"%messages)
示例#2
0
 def add_to_playlist(self):
     playlist_id = self.comboBox.itemData(self.comboBox.currentIndex())
     #print(self.comboBox.itemData(self.comboBox.currentIndex()))
     r, ok = server.postServer("playlists/"+str(playlist_id)+"/add_music", {'token':session_lib.get_token(), 'music_id':self.music_id})
     print(r)
     if r['success'] is True:
         self.close()
示例#3
0
文件: antigo.py 项目: dezagfx/Pytunes
    def delete_playlist(self, pid):
        print("DDDDDDDDDDDpid", pid)
        r = server.postServer('playlists/delete', {'playlist_id':int(pid),'token':session_lib.get_token()})
        print(r)

        #if r['success'] is True:
        #time.sleep(2)
        self.user_playlist()
示例#4
0
文件: antigo.py 项目: dezagfx/Pytunes
    def addbutton(self):
        playlist_name = self.lineEdit.text()
        print(playlist_name)
        response, ok = server.postServer(
                    'playlists/add', 
                    {'playlist_name':playlist_name, 'token':session_lib.get_token()}
            )
        print(response)

        if response['success'] == True:
            self.close()
            time.sleep(0.05)
            self.user_interface.user_playlist()
示例#5
0
    def testarConta(self):

        response, ok = server.postServer(
                    'auth/create_account', 
                    {'name':self.newUser.text(),'password':self.newPassword.text(),'password_confirmation':self.confPassword.text(),'email':self.eMail.text()}
            )

        if response['success'] == True:
            QtWidgets.QMessageBox.information(self, "Sucesso", "Utilizador %s criado"% self.newUser.text())
            self.accept()

        else:
            fail = response['error_message']
            messages = "\n".join(fail)
            QtWidgets.QMessageBox.information(self, "Erro", "%s"%messages)
示例#6
0
文件: antigo.py 项目: dezagfx/Pytunes
    def window(self):
        if self._window is None:

            if session_lib.get_token() == "":
                self._window = Login()
                return self._window
            else:
                response, ok = server.postServer(
                    'auth/check_token', 
                    {'token' : session_lib.get_token()}
                )
                if response['success'] == True:
                    username = response['payload']['user']['name']
                    self._window = Pytunes(username)

                else:
                    print('fail')

        return self._window
示例#7
0
 def delete_playlist(self, pid):
     r = server.postServer('playlists/delete', {'playlist_id':int(pid),'token':session_lib.get_token()})
     self.user_playlist()