Ejemplo n.º 1
0
    def lbl_forgotpwd_click(self, event):
        if getattr(self, 'txt_in_username').get_text() == '':
            MessageModal(
                self,
                title='Error',
                message=
                f'Please enter your username to recieve an email containing the verification code!',
                messageType='info')
        else:
            user = Container.filter(
                User, User.userName == getattr(
                    self, 'txt_in_username').get_text()).first()
            if user == None:
                MessageModal(self,
                             title='Error',
                             message=f'This username doesn\'t exist!',
                             messageType='error')
            else:
                sparepwd = Container.filter(
                    SparePwd, SparePwd.userId == user.id).first()
                if sparepwd == None or sparepwd.expirationDate < datetime.now(
                ):
                    sparepwd = SparePwd(user=user,
                                        expirationDate=datetime.now() +
                                        timedelta(days=1),
                                        verificationCode=generate_code())
                    Container.save(sparepwd)

                MessageModal(
                    self,
                    title='Success',
                    message='A verification code has been sent to your email!',
                    messageType='info')
                send_email(user, sparepwd.verificationCode)
Ejemplo n.º 2
0
 def generate_link(msg2, modal, slink, privilege):
     msg2.destroy()
     if slink != None: Container.deleteObject(slink)
     link= f'bpmntool//{dataObject.title}/{datetime.now()}/'
     Container.save(ShareLink(link=link, expirationDate=datetime.now()+timedelta(days=1), privilege= privilege, project=dataObject))
     self.clean_notifications()
     set_link(link)
Ejemplo n.º 3
0
            def revert_changes(msg, history):
                history.project.file = history.file
                history.project.lastEdited = history.editDate
                history.project.image = history.image
                Container.save(history.project)
                msg.destroy()

                for li in self.historyItems:
                    if li.dataObject.editDate >= history.editDate:
                        Container.deleteObject(li.dataObject)
                        li.destroy()

                photo = getdisplayableimage(history.image,
                                            (self.frm_preview.winfo_width(),
                                             self.frm_preview.winfo_height()))
                self.lbl_image.configure(image=photo)
                self.lbl_image.image = photo

                MessageModal(
                    self,
                    title=f'Success',
                    message=
                    f'Changes reverted to the following date:\n{history.editDate.strftime("%x - %X")}!',
                    messageType='info')
                getattr(
                    self, 'lbl_' + CollaborationWindow.lblSettings[2]['prop']
                )['text'] = history.editDate.strftime(
                    "%d/%m/%Y"
                ) if datetime.datetime.now(
                ).strftime("%x") != history.editDate.strftime(
                    "%x") else 'Today at - ' + history.editDate.strftime("%X")
Ejemplo n.º 4
0
 def btn_signup_next(self, event):
     validated_fields = self.validate_step()
     if self.current + 1 == 3 and validated_fields == 2:
         if Container.filter(
                 User, User.userName == getattr(
                     self, 'txt_up_username').get_text()).first() != None:
             MessageModal(
                 self,
                 title='UserName taken',
                 message=
                 f'{getattr(self, "txt_up_username").get_text()} is already taken\nplease pick another userName!',
                 messageType='error')
         else:
             atts = {}
             Container.save(
                 User(email=self.txt_email.get_text(),
                      userName=self.txt_up_username.get_text(),
                      firstName=self.txt_firstname.get_text(),
                      lastName=self.txt_lastname.get_text(),
                      password=self.txt_up_pwd.get_text(),
                      company=self.txt_company.get_text(),
                      gender=self.txt_gender.get_text()))
             self.empty_all()
             MessageModal(
                 self,
                 title='Success',
                 message=
                 'Account created !\nFeel free to Login and good luck with your work!',
                 messageType='info')
             MoveTransition(self.frm_veil_set_x, self.frm_veil_get_x, 0,
                            2.5)
     else:
         return validated_fields
Ejemplo n.º 5
0
 def create_session():
     project = Project(title= title+'Project', creationDate= date, lastEdited= date, owner= HomeWindow.ACTIVE_USER)
     session = Session(title= title, creationDate= date, owner= HomeWindow.ACTIVE_USER, project= project)
     message = Message(content=f'welcome to the chat',user=HomeWindow.ACTIVE_USER, session=session, sentDate=session.creationDate)
     Container.save(project, session, message)
     seenmessage = SeenMessage(date=session.creationDate, seer=HomeWindow.ACTIVE_USER, messageId=message.id)
     Container.save(seenmessage)
     self.lv_session.grid_item(session, {'title': session.title, 'creationDate': project.creationDate, 'lastEdited': project.lastEdited, 'memberCount': str(Container.filter(Collaboration,Collaboration.sessionId == session.id).count()+1)}, None, lambda i: self.create_list_item(i, HomeWindow.SESSION_LI), 15)
Ejemplo n.º 6
0
 def configure_notif_listitem(self, root, item):
     li= ListItemFactory.NotificationListItem(root, item)
     li.window = self
     # save notification that are not recieveInv as seen 
     if item.type != NotificationType.INVITED.value and Container.filter(SeenNotification, SeenNotification.notificationId == item.id, SeenNotification.seerId == SessionWindow.ACTIVE_USER.id).first() == None: 
             Container.save(SeenNotification(date= datetime.datetime.now(), seer= SessionWindow.ACTIVE_USER, notification= item))
     # append this item to a list
     self.created_notif_items.append (li)
     # return 
     return li
Ejemplo n.º 7
0
 def save_changes(self, event):
     data = self.get_form_data()
     # check if data is validated
     if self.validate_form_data(data) == True:
         # make changes on current user
         for key, value in data.items():
             if hasattr(ProfileWindow.ACTIVE_USER, key):
                 setattr(ProfileWindow.ACTIVE_USER, key, value)
         # save changes
         Container.save(ProfileWindow.ACTIVE_USER)
         # reload the window
         self.refresh_window('Changes saved succefully!')
Ejemplo n.º 8
0
 def generate_link(msg2, modal, inv, privilege):
     msg2.destroy()
     if inv != None: Container.deleteObject(inv)
     link = f'bpmntool//{self.session.title}/{datetime.datetime.now()}/'
     Container.save(
         InvitationLink(link=link,
                        expirationDate=datetime.datetime.now() +
                        datetime.timedelta(days=1),
                        privilege=privilege,
                        sender=CollaborationWindow.ACTIVE_USER,
                        session=self.session))
     self.clean_notifications()
     set_link(link)
Ejemplo n.º 9
0
def uploadimagefile(userid):
    if userid != 0:
        user = Container.filter(User).get(userid)
        filename = filedialog.askopenfilename(
            initialdir="/", title="select image to upload to user", filetypes=(("jpeg/jpg files", "*.jpg"), ("png files", "*.png"), ("all files", "*.*")))
        if filename.lower().endswith(('.png', '.jpg')) == True:
            bytesimage = filetobytes(filename)
            user.image = bytesimage
            Container.save(user)
            image = getdisplayableimage(bytesimage, (200, 200))
            displayimage(image)
        else:
            messagebox.askokcancel(root, message='please choose an image file')
    else:
        messagebox.askokcancel(root, message='please enter a user id')
Ejemplo n.º 10
0
 def send_message(self, event, listItem):
     if self.txt_message.get() != '' and not str.isspace(
             self.txt_message.get(
             )) and listItem != None and self.is_hint_deleted == True:
         msg = Message(content=self.txt_message.get(),
                       sentDate=datetime.datetime.now(),
                       user=DiscussionWindow.ACTIVE_USER,
                       session=listItem.dataObject.session)
         Container.save(msg)
         listItem.dataObject = msg
         listItem.lbl_content['text'] = self.txt_message.get() if len(
             self.txt_message.get()) < 20 else (
                 self.txt_message.get()[:17] + '...')
         self.txt_message.delete(0, END)
         self.fill_discussion(listItem.dataObject.session)
Ejemplo n.º 11
0
 def join_session(self, modal):
     link = modal.get_form_data()['txt_link']
     date = datetime.now()
     invlink = Container.filter(InvitationLink, InvitationLink.link == link).first()
     if invlink == None: MessageModal(self, title= f'Link error' ,message= 'This link doesn\'t exist!', messageType= 'error')
     elif invlink.expirationDate < datetime.now(): MessageModal(self, title= f'Link error' ,message= 'This link has expired!', messageType= 'error')
     elif Container.filter(Collaboration, Collaboration.userId == HomeWindow.ACTIVE_USER.id, Collaboration.sessionId == invlink.sessionId).first() != None or invlink.session.owner == HomeWindow.ACTIVE_USER:
         MessageModal(self, title= f'Error' ,message= f'You are already in {invlink.session.title} session!', messageType= 'error')
     else:
         # create relations if they don't exist
         if Container.filter(Relation,Relation.userOne == HomeWindow.ACTIVE_USER, Relation.userTwo == invlink.sender ).first() == None: Container.save(Relation(userOne= HomeWindow.ACTIVE_USER, userTwo= invlink.sender))
         if Container.filter(Relation,Relation.userTwo == HomeWindow.ACTIVE_USER, Relation.userOne == invlink.sender ).first() == None: Container.save(Relation(userTwo= HomeWindow.ACTIVE_USER, userOne= invlink.sender))
         # create collaboration
         Container.save(Collaboration(joiningDate= date, privilege= invlink.privilege, user= HomeWindow.ACTIVE_USER, session= invlink.session))
         # add an acceptedInv type notification
         noti = Notification(notificationTime= date, type= NotificationType.JOINED.value, nature= NotificationNature.INVLINK.value, invitationId= invlink.id, actor= HomeWindow.ACTIVE_USER, recipient= invlink.sender)
         modal.destroy()
         self.windowManager.run(CollaborationWindow(self.master, invlink.session))
Ejemplo n.º 12
0
def uploadxmlfile(projectid):
    if projectid != 0:
        project = Container.filter(Project).get(projectid)
        filename = filedialog.askopenfilename(
            initialdir="/", title="select xml file to upload to project", filetypes=(("xml files", "*.xml"), ("all files", "*.*")))
        if filename.lower().endswith('.xml') == True:
            bytesfile = filetobytes(filename)
            if len(bytesfile) != 0:
                project.file = bytesfile
                Container.save(project)
                element = bytestoelement(bytesfile)
                displaycontent(element)
            else:
                messagebox.showwarning(root, message='Empty xml file')
        else:
            messagebox.askokcancel(root, message='please choose an xml file')
    else:
        messagebox.askokcancel(root, message='please enter a project id')
Ejemplo n.º 13
0
 def send_invite(msg, user, privilege):
     inv = Invitation(privilege=privilege,
                      invitationTime=datetime.datetime.now(),
                      sender=CollaborationWindow.ACTIVE_USER,
                      recipient=user,
                      session=self.session)
     Container.save(inv)
     notif = Notification(type=NotificationType.INVITED.value,
                          notificationTime=datetime.datetime.now(),
                          nature=NotificationNature.INV.value,
                          invitationId=inv.id,
                          actor=inv.sender,
                          recipient=inv.recipient)
     Container.save(notif)
     msg.destroy()
     MessageModal(
         self,
         title=f'Success',
         message=f'Invitation sent to {user.userName} successfully!',
         messageType='info')
Ejemplo n.º 14
0
    def Configure_session(self, event, listItem):
        self.frm_veil.place_forget()

        self.fill_discussion(listItem.dataObject.session)

        self.lbl_sessionName['text'] = listItem.dataObject.session.title
        self.lbl_memberCount[
            'text'] = f'{Container.filter(Collaboration,Collaboration.sessionId == listItem.dataObject.session.id).count()+1} ' + translate(
                'Members')

        self.txt_message.bind('<Return>',
                              lambda event, listItem=listItem: self.
                              send_message(event, listItem))

        if self.currentItem != None:
            self.change_session_item_style(self.currentItem, self.CHAT_NORMAL)

        self.currentItem = listItem
        self.change_session_item_style(self.currentItem, self.CHAT_ACTIVE)

        currentSession = self.currentItem.dataObject.session

        # mark previous messages as seen
        prevmsgs = Container.filter(
            Message, Message.sessionId == currentSession.id,
            Message.userId != DiscussionWindow.ACTIVE_USER.id)
        # mark them as seen
        for m in prevmsgs:
            # check if already marked
            if len(
                    Container.filter(
                        SeenMessage, SeenMessage.messageId == m.id,
                        SeenMessage.seerId
                        == DiscussionWindow.ACTIVE_USER.id).all()) > 0:
                continue
            # mark as read
            Container.save(
                SeenMessage(date=datetime.datetime.now(),
                            seer=DiscussionWindow.ACTIVE_USER,
                            message=m))
Ejemplo n.º 15
0
def run():
    # Container.deleteObject(Container.filter(Project).first())
    user1 = User(firstName='Mohamed',
                 lastName='El Kalai',
                 userName='******')
    user2 = User(firstName='Ibrahim', lastName='Areda', userName='******')
    user3 = User(firstName='Chakir', email='*****@*****.**')
    user4 = User(firstName='Hodaifa', email='*****@*****.**')

    project1 = Project(title='bpmntool', owner=user1)
    project2 = Project(title='bpmntool2', owner=user2)

    session1 = Session(title='bpmntoolsession', owner=user1, project=project1)
    session2 = Session(title='session2', owner=user2, project=project2)

    # collab1 = Collaboration(user=recipient, session=session, joiningDate=datetime.datetime.now(),privilege='edit')
    # collab2 = Collaboration(user=recipient2, session=session,joiningDate=datetime.datetime.now(), privilege='edit')
    # collab3 = Collaboration(user=recipient3, session=session2,joiningDate=datetime.datetime.now(), privilege='edit')

    # message1 = Message(user=recipient, session=session, sentDate=datetime.datetime.now(), content='message2')
    # message2 = Message(user=recipient2, session=session, sentDate=datetime.datetime.now(), content='message1')
    # message3 = Message(user=recipient2, session=session, sentDate=datetime.datetime.now(), content='message3')
    # message4 = Message(user=recipient2, session=session, sentDate=datetime.datetime.now(), content='message4')
    # message5 = Message(user=recipient3, session=session2, sentDate=datetime.datetime.now(), content='wrong')
    # message6 = Message(user=recipient3, session=session2, sentDate=datetime.datetime.now(), content='wrong2')
    # message7 = Message(user=sender, session=session2, sentDate=datetime.datetime.now(), content='i sent it in session2')
    # message8 = Message(user=sender, session=session, sentDate=datetime.datetime.now(), content='wrong i sent it')

    # invitation = Invitation(sender=sender, recipient=recipient,
    #                         session=session, privilege='edit')

    # invitationLink = InvitationLink(sender=sender, session=session, link='invlinkkkkkkkkkkkk')

    # shareLink = ShareLink(project=project, link='sharelinkkkkkkkkk')

    Container.save(
        user1, user2, user3, user4, project1, project2, session1, session2
    )  #,invitation,invitationLink,shareLink,collab1,collab2,collab3,message1,message2,message3,message4,message5,message6,message7,message8)
Ejemplo n.º 16
0
 def create_project(bytesFile= None):
     project = Project(title= title, creationDate= datetime.now(), lastEdited= datetime.now(), owner= HomeWindow.ACTIVE_USER, file= bytesFile)
     Container.save(project)
     self.lv_project.grid_item(project, {'title': project.title, 'creationDate': project.creationDate, 'lastEdited': project.lastEdited}, None, lambda i: self.create_list_item(i, HomeWindow.PROJECT_LI), 15)