Пример #1
0
 def load_from_web(self, form):
     try:
         self.title = form['title']
         self.script = form['script'].split(';')[0]
         self.type = form['type']
         self.execution_start = load_time(form['execution_start'])
         self.is_widget = form['is_widget'] == 'Y'
         self.recipients = nwe(form['recipients'])
         self.group = nwe(form['group'])
     except BadRequestKeyError:
         abort(403)
Пример #2
0
 def load_from_web(self, form):
     try:
         self.name = form['name']
         self.user = form['user']
         self.email = nwe(form['email'])
         self.xmpp_user = nwe(form['xmpp_user'])
         self.active = 'active' in form
         if 'clear_password' in form:
             self.password = sha256(b'padrao').hexdigest()
     except BadRequestKeyError:
         abort(403)
Пример #3
0
 def load_from_web(self, form):
     try:
         self.title = form['title']
         self.script = form['script'].split(';')[0]
         self.type = form['type']
         self.execution_start = load_time(form['execution_start'])
         self.is_widget = form['is_widget'] == 'Y'
         self.recipients = nwe(form['recipients'])
         self.group = nwe(form['group'])
     except BadRequestKeyError:
         abort(403)
Пример #4
0
 def load_from_web(self, form):
     try:
         self.name = form['name']
         self.user = form['user']
         self.email = nwe(form['email'])
         self.xmpp_user = nwe(form['xmpp_user'])
         self.active = 'active' in form
         if 'clear_password' in form:
             self.password = sha256(b'padrao').hexdigest()
     except BadRequestKeyError:
         abort(403)
Пример #5
0
 def load_from_web(self, form):
     try:
         self.date = load_date(form['date'])
         self.type = nwe(form['type'])
         self.conclusion = form['conclusion'] == 'Y'
         self.observations = nwe(form['observations'])
         self.document_ext = replace_when_none(
             nwe(form['document_filename'].split('.')[-1]),
             self.document_ext)
         if len(form['document']) > 0:
             self.document = b64decode(
                 form['document'].split(';base64,')[1].encode())
     except BadRequestKeyError as ke:
         abort(403)
Пример #6
0
 def load_from_web(self, form):
     try:
         self.date = load_date(form['date'])
         self.type = nwe(form['type'])
         self.conclusion = form['conclusion'] == 'Y'
         self.observations = nwe(form['observations'])
         self.document_ext = replace_when_none(
             nwe(form['document_filename'].split('.')[-1]),
             self.document_ext)
         if len(form['document']) > 0:
             self.document = b64decode(
                 form['document'].split(';base64,')[1].encode())
     except BadRequestKeyError as ke:
         abort(403)
Пример #7
0
 def load_from_web(self, form):
     try:
         self.relative_start = load_date(form['relative_start'])
         self.relative_end = load_date(form['relative_end'])
         self.use_start = load_date(form['use_start'])
         self.use_end = load_date(form['use_end'])
         self.allowance_start = load_date(form['allowance_start'])
         self.allowance_end = load_date(form['allowance_end'])
         self.observations = nwe(form['observations'])
         self.document_ext = replace_when_none(
             nwe(form['document_filename'].split('.')[-1]),
             self.document_ext)
         if len(form['document']) > 0:
             self.document = b64decode(
                 form['document'].split(';base64,')[1].encode())
     except BadRequestKeyError:
         abort(403)
Пример #8
0
 def load_from_web(self, form):
     try:
         self.type = int(form['type'])
         self.date = load_date(form['date'])
         self.reason = int(form['reason'])
         self.requester = form['requester']
         self.witness1 = nwe(form['witness1'])
         self.witness2 = nwe(form['witness2'])
         self.observations = nwe(form['observations'])
         self.document_ext = replace_when_none(
             nwe(form['document_filename'].split('.')[-1]),
             self.document_ext)
         if len(form['document']) > 0:
             self.document = b64decode(
                 form['document'].split(';base64,')[1].encode())
     except BadRequestKeyError:
         abort(403)
Пример #9
0
 def load_from_web(self, form):
     try:
         self.relative_start = load_date(form['relative_start'])
         self.relative_end = load_date(form['relative_end'])
         self.use_start = load_date(form['use_start'])
         self.use_end = load_date(form['use_end'])
         self.allowance_start = load_date(form['allowance_start'])
         self.allowance_end = load_date(form['allowance_end'])
         self.observations = nwe(form['observations'])
         self.document_ext = replace_when_none(
             nwe(form['document_filename'].split('.')[-1]),
             self.document_ext)
         if len(form['document']) > 0:
             self.document = b64decode(
                 form['document'].split(';base64,')[1].encode())
     except BadRequestKeyError:
         abort(403)
Пример #10
0
 def load_from_web(self, form):
     try:
         self.type = int(form['type'])
         self.date = load_date(form['date'])
         self.reason = int(form['reason'])
         self.requester = form['requester']
         self.witness1 = nwe(form['witness1'])
         self.witness2 = nwe(form['witness2'])
         self.observations = nwe(form['observations'])
         self.document_ext = replace_when_none(
             nwe(form['document_filename'].split('.')[-1]),
             self.document_ext)
         if len(form['document']) > 0:
             self.document = b64decode(
                 form['document'].split(';base64,')[1].encode())
     except BadRequestKeyError:
         abort(403)
Пример #11
0
def normalize_text(value, change_to=''):
    """
When value is None or an empty string replace it for rpcl.
    :param value:
    :param change_to:
    :return:
    """
    if isinstance(value, int) or isinstance(value, float):
        value = str(value)
    return replace_when_none(nwe(value), change_to)
Пример #12
0
 def get(self, result_type=T_CLASS, **where_clauses):
     """
 Get objects from specifieds clauses.
 :param result_type: type to store in resultset:
                     'class' for a model.
                     'dict' for a dictionary
                     'list' for a list.
 :param where_clauses: clauses according with model fields.
 :return:
     """
     connection = self._obj.create_connection()
     query = replace_when_none(nwe(self._custom_qry_init_part), self._qry_init_part)
     where_clauses = normalize_db_values(where_clauses, self._obj)
     self._resultset = ()
     result_type = T_DICT if self._custom_qry_init_part else result_type
     if len(where_clauses) == 0:
         query += ' 1=1'
     else:
         for key in where_clauses.keys():
             sep = '__'
             if sep in key:
                 opt = key.split(sep)[-1]
                 if opt in self._where_opt:
                     if where_clauses[key] is None and opt == 'not':
                         query += ' {} is not %({})s ' \
                                  'AND'.format(self._obj.normalize_column(
                             key.split(sep + opt)[0]), key)
                     else:
                         query += ' {} {} %({})s AND'.format(
                             self._obj.normalize_column(
                                 key.split(sep + opt)[0]),
                             self._where_opt[opt], key)
                     continue
             if where_clauses[key] is None:
                 query += ' {} is %({})s AND'.format(
                     self._obj.normalize_column(key), key)
             else:
                 query += ' {} = %({})s AND'.format(
                     self._obj.normalize_column(key), key)
     query = query.strip('AND') + self._order_by
     if result_type == T_CLASS:
         self._populate_dict(connection.query_with_columns(query,
                                                           where_clauses))
     elif result_type == T_DICT:
         self._populate_dict(
             connection.query_with_columns(query, where_clauses),
             result_type)
     else:
         self._populate(connection.query(query, where_clauses))
     connection.close()
     self._order_by = ''
     self._custom_qry_init_part = ''
     return self
Пример #13
0
    def load_from_web(self, form, files):
        try:
            self.department = Department()
            self.enterprise = Enterprise()
            self.role = Role()

            self.name = form['name']
            self.department.load(int(form['departament']))
            self.enterprise.load(int(form['enterprise']))
            self.role.load(int(form['role']))
            self.registry = load_int(form['registry'])
            self.name_tag = load_int(form['name_tag'])
            self.active = form['active'] == 'Y'
            self.cpf = load_int(form['cpf'])
            self.sex = nwe(form['sex'])
            self.rg = nwe(form['rg'])
            self.rg_issuing = nwe(form['rg_issuing'])
            self.rg_date = nwe(form['rg_date'])
            self.born_date = load_date(form['born_date'])
            self.cnh = nwe(form['cnh'])
            self.cnh_category = nwe(form['cnh_category'])
            self.ctps = nwe(form['ctps'])
            self.ctps_series = nwe(form['ctps_series'])
            self.ctps_fu = nwe(form['ctps_fu'])
            self.ctps_date = nwe(form['ctps_date'])
            self.nacionality = nwe(form['nacionality'])
            self.place_of_birth = nwe(form['place_of_birth'])
            self.phone = load_int_as_str(form['phone'])
            self.cellphone = load_int_as_str(form['cellphone'])
            self.zipcode = load_int_as_str(form['zipcode'])
            self.address = nwe(form['address'])
            self.address_adjunct = nwe(form['address_adjunct'])
            self.neighborhood = nwe(form['neighborhood'])
            self.city = nwe(form['city'])
            self.fu = nwe(form['fu'])
            self.father_name = nwe(form['father_name'])
            self.mother_name = nwe(form['mother_name'])
            self.scholarity = load_int(form['scholarity'])
            self.scholarity_complete = form['scholarity_complete'] == 'Y'
            self.graduation = nwe(form['graduation'])
            self.post_graduation = nwe(form['post_graduation'])
            self.civil_state = nwe(form['civil_state'])
            self.spouse = nwe(form['spouse'])
            self.admission_date = load_date(form['admission_date'])
            self.demission_date = load_date(form['demission_date'])
            self.pis_date = load_date(form['pis_date'])
            self.pis_number = load_int(form['pis_number'])
            self.meal_on_enterprise = form['meal_on_enterprise'] == 'Y'
            self.salary = load_decimal(form['salary'])
            self.reservist = nwe(form['reservist'])
            self.bank = nwe(form['bank'])
            self.agency = nwe(form['agency'])
            self.account = nwe(form['account'])
            self.winthor_registry = load_int(form['winthor_registry'])
            self.transport_voucher = form['transport_voucher'] == 'Y'
            data = files['photo'].stream.read()
            if data != b'':
                self.photo = data
        except BadRequestKeyError:
            abort(403)
Пример #14
0
    def load_from_web(self, form, files):
        try:
            self.department = Department()
            self.enterprise = Enterprise()
            self.role = Role()

            self.name = form['name']
            self.department.load(int(form['departament']))
            self.enterprise.load(int(form['enterprise']))
            self.role.load(int(form['role']))
            self.registry = load_int(form['registry'])
            self.name_tag = load_int(form['name_tag'])
            self.active = form['active'] == 'Y'
            self.cpf = load_int(form['cpf'])
            self.sex = nwe(form['sex'])
            self.rg = nwe(form['rg'])
            self.rg_issuing = nwe(form['rg_issuing'])
            self.rg_date = nwe(form['rg_date'])
            self.born_date = load_date(form['born_date'])
            self.cnh = nwe(form['cnh'])
            self.cnh_category = nwe(form['cnh_category'])
            self.ctps = nwe(form['ctps'])
            self.ctps_series = nwe(form['ctps_series'])
            self.ctps_fu = nwe(form['ctps_fu'])
            self.ctps_date = nwe(form['ctps_date'])
            self.nacionality = nwe(form['nacionality'])
            self.place_of_birth = nwe(form['place_of_birth'])
            self.phone = load_int_as_str(form['phone'])
            self.cellphone = load_int_as_str(form['cellphone'])
            self.zipcode = load_int_as_str(form['zipcode'])
            self.address = nwe(form['address'])
            self.address_adjunct = nwe(form['address_adjunct'])
            self.neighborhood = nwe(form['neighborhood'])
            self.city = nwe(form['city'])
            self.fu = nwe(form['fu'])
            self.father_name = nwe(form['father_name'])
            self.mother_name = nwe(form['mother_name'])
            self.scholarity = load_int(form['scholarity'])
            self.scholarity_complete = form['scholarity_complete'] == 'Y'
            self.graduation = nwe(form['graduation'])
            self.post_graduation = nwe(form['post_graduation'])
            self.civil_state = nwe(form['civil_state'])
            self.spouse = nwe(form['spouse'])
            self.admission_date = load_date(form['admission_date'])
            self.demission_date = load_date(form['demission_date'])
            self.pis_date = load_date(form['pis_date'])
            self.pis_number = load_int(form['pis_number'])
            self.meal_on_enterprise = form['meal_on_enterprise'] == 'Y'
            self.salary = load_decimal(form['salary'])
            self.reservist = nwe(form['reservist'])
            self.bank = nwe(form['bank'])
            self.agency = nwe(form['agency'])
            self.account = nwe(form['account'])
            self.winthor_registry = load_int(form['winthor_registry'])
            self.transport_voucher = form['transport_voucher'] == 'Y'
            data = files['photo'].stream.read()
            if data != b'':
                self.photo = data
        except BadRequestKeyError:
            abort(403)