예제 #1
0
    def serialize(self):
        # Fix Tag Name
        eventElement = Linkable.serialize(self)
        eventElement.tag = bpmn + ('boundary' if self.attachedTo != None else
                                   camel_case(self.type.name)) + 'Event'
        # Add Cancel Attribute
        if self.attachedTo != None:
            eventElement.attrib['cancelActivity'] = str(self.cancelActivity)
            eventElement.attrib['attachedToRef'] = str(self.attachedTo.id)
        # Add Definition Element
        if self.definition != EventDefinition.Default:
            eventDefElement = et.Element(
                camel_case(self.definition.name) + 'EventDefinition')
            eventDefElement.attrib[
                'id'] = f'{self.id}_{self.definition.name}Definition'
            eventElement.append(eventDefElement)

        return eventElement
예제 #2
0
    def validate_form_data(self, data):
        try:
            for key, value in data.items():
                if value == None and key not in ['confirmPwd', 'image']:
                    raise Exception(camel_case(key), f'{key} Cannot be null!')

                elif key in ['firstName', 'lastName'] and not re.fullmatch(
                        '[A-Za-z]{2,15}( [A-Za-z]{2,15})?', value):
                    raise Exception(
                        camel_case(key),
                        f'\n1. Can contain 2 words with 1 space in between\n2.Must be between 2 - 15 alphabets each'
                    )

                elif key in [
                        'userName', 'password'
                ] and not re.fullmatch('^[a-zA-Z0-9_.-]+$', value):
                    raise Exception(
                        camel_case(key),
                        f'can only be alphanumeric and contain (. _ -)')

                elif key == 'email' and not re.fullmatch(
                        '[^@]+@[^@]+\.[^@]+', value):
                    raise Exception(
                        camel_case(key),
                        f'Please enter a valid email!\nExample: [email protected]'
                    )

                elif key == 'company' and value != None and not re.fullmatch(
                        '^[a-zA-Z0-9_]+( [a-zA-Z0-9_]+)*$', value):
                    raise Exception(
                        camel_case(key),
                        f'\n1. Must be between 4 - 20 characters\n2. Should not contain any special characters'
                    )

                elif key == 'gender' and value != None and value.lower(
                ) not in ['female', 'male']:
                    raise Exception(camel_case(key),
                                    f'Gender must be either male or female!')

                elif key == 'confirmPwd' and value != data['password']:
                    raise Exception(
                        'password confirmation',
                        f'Passwords don\'t match, please confirm your password!'
                    )

            return True

        except Exception as ex:
            MessageModal(self,
                         title=f'{ex.args[0]} Error',
                         message=ex.args[1],
                         messageType='error')
            return False
예제 #3
0
 def serialize(self):
     element = Linkable.serialize(self)
     element.tag = bpmn + camel_case(self.type.name) + 'Gateway'
     return element
예제 #4
0
 def get_tag(self):
     return camel_case(self.__class__.__name__)
예제 #5
0
    def validate_step(self):
        valid_fields = 0
        try:
            for i in self.up_congig[self.steptitles[self.current]]:
                if getattr(self, i.get('name')).get_text() == '' and i.get(
                        'name') not in ['txt_confirm']:
                    raise Exception(camel_case(i.get("label")),
                                    f'{i.get("label")} Cannot be null!')

                elif i.get('name') in [
                        'txt_firstname', 'txt_lastname'
                ] and not re.fullmatch('[A-Za-z]{2,15}( [A-Za-z]{2,15})?',
                                       getattr(self,
                                               i.get('name')).get_text()):
                    raise Exception(
                        camel_case(i.get("label")),
                        f'\n1.Can contain 2 words with 1 space in between\n2.Must be between 2 - 15 alphabets each'
                    )

                elif i.get('name') in [
                        'txt_up_username', 'txt_up_pwd'
                ] and not re.fullmatch('^[a-zA-Z0-9_.-]+$',
                                       getattr(self,
                                               i.get('name')).get_text()):
                    raise Exception(
                        camel_case(i.get("label")),
                        f'can only be alphanumeric and contain (. _ -)')

                elif i.get('name') == 'txt_email' and not re.fullmatch(
                        '[^@]+@[^@]+\.[^@]+',
                        getattr(self, i.get('name')).get_text()):
                    raise Exception(
                        camel_case(i.get("label")),
                        f'Please enter a valid email!\nEX: [email protected]'
                    )

                elif i.get('name') == 'txt_company' and getattr(
                        self,
                        i.get('name')).get_text() != '' and not re.fullmatch(
                            '^[a-zA-Z0-9_]+( [a-zA-Z0-9_]+)*$',
                            getattr(self, i.get('name')).get_text()):
                    raise Exception(
                        camel_case(i.get("label")),
                        f'\n1. Must be between 4 - 20 characters\n2. It should not contain any special characters'
                    )

                elif i.get('name') == 'txt_gender' and getattr(
                        self, i.get('name')).get_text() != '' and getattr(
                            self, i.get('name')).get_text().lower() not in [
                                'female', 'male'
                            ]:
                    raise Exception(camel_case(i.get("label")),
                                    f'Gender must be either male or female!')

                elif i.get('name') == 'txt_confirm' and getattr(
                        self, i.get('name')).get_text() != getattr(
                            self, 'txt_up_pwd').get_text():
                    raise Exception(
                        'Password confirmation',
                        f'Password doesn\'t match.\nPlease confirm your password!'
                    )

                valid_fields += 1

        except Exception as ex:
            MessageModal(self,
                         title=f'{ex.args[0]} Error',
                         message=ex.args[1],
                         messageType='error')
        finally:
            return valid_fields
예제 #6
0
 def serialize(self):
     taskElement = Activity.serialize(self)
     taskElement.tag = bpmn + 'task' if self.type == TaskType.Default else camel_case(
         self.type.name) + 'Task'
     return taskElement