Ejemplo n.º 1
0
def EditFormDataBase(context, event):
    title = context.Title()
    description = context.Description()
    uid_form = IUUID(context)

    campo_chave = context.campo_chave
    campo_label = context.campo_label

    forms_id = int(context.forms_id)

    result = ModelsForm().get_Forns_byId(forms_id)
    if result:
        try:
            result.name_form = to_utf8(title)
        except:
            result.name_form = title

        try:
            result.description_form = to_utf8(description)
        except:
            result.description_form = description

        try:
            result.campo_label = to_utf8(campo_label)
        except:
            result.campo_label = campo_label

        try:
            result.campo_chave = to_utf8(campo_chave)
        except:
            result.campo_chave = campo_chave

        try:
            result.uid_form = to_utf8(uid_form)
        except:
            result.uid_form = uid_form

        BaseStore().store.flush()

    if context.active_workflow:
        result_fields_form = ModelsFormFields().get_Fields_ByIdForm(forms_id)

        for campo in campos_controle:
            campo['forms_id'] = int(forms_id)
            campo_name = campo.get('name_field')
            result_field = ModelsFormFields().get_Fields_ByField(
                campo_name, int(forms_id))
            if not result_field:
                campo['ordenacao'] = (result_fields_form.count())
                ModelsFormFields().set_FormFields(**campo)
Ejemplo n.º 2
0
def EditFormDataBase(context, event):
        title = context.Title()
        description = context.Description()
        uid_form = IUUID(context)

        campo_chave = context.campo_chave
        campo_label = context.campo_label

        forms_id = int(context.forms_id)

        result = ModelsForm().get_Forns_byId(forms_id)
        if result:
            try:result.name_form = to_utf8(title)
            except:result.name_form = title

            try:result.description_form = to_utf8(description)
            except:result.description_form = description

            try:result.campo_label = to_utf8(campo_label)
            except:result.campo_label = campo_label

            try:result.campo_chave = to_utf8(campo_chave)
            except:result.campo_chave = campo_chave

            try:result.uid_form = to_utf8(uid_form)
            except:result.uid_form = uid_form

            BaseStore().store.flush()


        if context.active_workflow:
            result_fields_form = ModelsFormFields().get_Fields_ByIdForm(forms_id)

            for campo in campos_controle:
                campo['forms_id'] = int(forms_id)
                campo_name = campo.get('name_field')
                result_field = ModelsFormFields().get_Fields_ByField(campo_name, int(forms_id))
                if not result_field:
                    campo['ordenacao'] = (result_fields_form.count())
                    ModelsFormFields().set_FormFields(**campo)
Ejemplo n.º 3
0
def CreatFormDataBase(context, event):
    title = context.Title()
    description = context.Description()
    uid_form = IUUID(context)

    forms_id = context.forms_id

    D={}
    try:D['name_form'] = to_utf8(title)
    except:D['name_form'] = title

    try:D['description_form'] = to_utf8(description)
    except:D['description_form'] = description

    try:D['uid_form'] = to_utf8(uid_form)
    except:D['uid_form'] = uid_form

    id_form = ModelsForm().set_Form(**D)
    if forms_id != id_form:
        context.forms_id = id_form


    if context.active_workflow:

        for campo in campos_controle:
            campo['forms_id'] = int(id_form)

            ModelsFormFields().set_FormFields(**campo)


    if 'original' in event.__dict__.keys():
        org = event.original
        new = event.object

        fields_org = ModelsFormFields().get_Fields_ByIdForm(int(org.forms_id))

        campos = ['name_field','type_fields', 'list_values','title','value_default',\
                  'description_fields','ordenacao','required','flag_ativo', 'flag_float_left']

        for item in fields_org:
            D={}
            for i in campos:
                D[i] = item.__getattribute__(i)

            D['forms_id'] = int(new.forms_id)

            ModelsFormFields().set_FormFields(**D)

        instances_org = ModelsFormInstance().get_Instance(int(org.forms_id))

        for instance in instances_org:
            values_instance = ModelsFormValues().get_FormValues_byForm_and_Instance(int(org.forms_id), instance.instance_id)

            id_inst = ModelsFormInstance().set_FormInstance(int(new.forms_id))

            campos_value = ['value', 'value_blob','fields']

            for value in values_instance:
                D={}
                for i in campos_value:
                    D[i] = value.__getattribute__(i)

                D['forms_id'] = int(new.forms_id)
                D['instance_id'] = id_inst

                ModelsFormValues().set_FormValues(**D)
Ejemplo n.º 4
0
def CreatFormDataBase(context, event):
    title = context.Title()
    description = context.Description()
    uid_form = IUUID(context)

    forms_id = context.forms_id

    D = {}
    try:
        D['name_form'] = to_utf8(title)
    except:
        D['name_form'] = title

    try:
        D['description_form'] = to_utf8(description)
    except:
        D['description_form'] = description

    try:
        D['uid_form'] = to_utf8(uid_form)
    except:
        D['uid_form'] = uid_form

    id_form = ModelsForm().set_Form(**D)
    if forms_id != id_form:
        context.forms_id = id_form

    if context.active_workflow:

        for campo in campos_controle:
            campo['forms_id'] = int(id_form)

            ModelsFormFields().set_FormFields(**campo)

    if 'original' in event.__dict__.keys():
        org = event.original
        new = event.object

        fields_org = ModelsFormFields().get_Fields_ByIdForm(int(org.forms_id))

        campos = ['name_field','type_fields', 'list_values','title','value_default',\
                  'description_fields','ordenacao','required','flag_ativo', 'flag_float_left']

        for item in fields_org:
            D = {}
            for i in campos:
                D[i] = item.__getattribute__(i)

            D['forms_id'] = int(new.forms_id)

            ModelsFormFields().set_FormFields(**D)

        instances_org = ModelsFormInstance().get_Instance(int(org.forms_id))

        for instance in instances_org:
            values_instance = ModelsFormValues(
            ).get_FormValues_byForm_and_Instance(int(org.forms_id),
                                                 instance.instance_id)

            id_inst = ModelsFormInstance().set_FormInstance(int(new.forms_id))

            campos_value = ['value', 'value_blob', 'fields']

            for value in values_instance:
                D = {}
                for i in campos_value:
                    D[i] = value.__getattribute__(i)

                D['forms_id'] = int(new.forms_id)
                D['instance_id'] = id_inst

                ModelsFormValues().set_FormValues(**D)