예제 #1
0
def update_field(session, tid, field_id, field, language):
    """
    Update the specified field with the details.
    """
    field = db_update_field(session, tid, field_id, field, language)

    return serialize_field(session, tid, field, language)
예제 #2
0
파일: field.py 프로젝트: Taipo/GlobaLeaks
def create_field(store, field_dict, language, request_type=None):
    """
    Transaction that perform db_create_field
    """
    field = db_create_field(store, field_dict, language if request_type != 'import' else None)

    return serialize_field(store, field, language)
예제 #3
0
def create_field(session, tid, field_dict, language):
    """
    Transaction that perform db_create_field
    """
    field = db_create_field(session, tid, field_dict, language)

    return serialize_field(session, tid, field, language)
예제 #4
0
def update_field(session, tid, field_id, field, language):
    """
    Update the specified field with the details.
    """
    field = db_update_field(session, tid, field_id, field, language)

    return serialize_field(session, tid, field, language)
예제 #5
0
def create_field(session, tid, field_dict, language):
    """
    Transaction that perform db_create_field
    """
    field = db_create_field(session, tid, field_dict, language)

    return serialize_field(session, tid, field, language)
예제 #6
0
def create_field(store, field_dict, language, request_type=None):
    """
    Transaction that perform db_create_field
    """
    field = db_create_field(store, field_dict,
                            language if request_type != 'import' else None)

    return serialize_field(store, field, language)
예제 #7
0
def get_fieldtemplate_list(session, tid, language):
    """
    Serialize all the field templates localizing their content depending on the language.
    """
    templates = session.query(models.Field).filter(models.Field.tid.in_(set([1, tid])),
                                                   models.Field.instance == 'template',
                                                   models.Field.fieldgroup_id == None)

    return [serialize_field(session, tid, f, language) for f in templates]
예제 #8
0
def get_fieldtemplate_list(session, tid, language):
    """
    Serialize all the field templates localizing their content depending on the language.
    """
    templates = session.query(models.Field).filter(models.Field.tid.in_(set([1, tid])),
                                                   models.Field.instance == u'template',
                                                   models.Field.fieldgroup_id == None)

    return [serialize_field(session, tid, f, language) for f in templates]
예제 #9
0
def update_field(session, tid, field_id, field, language):
    """
    Transaction for updating a field
    :param session: An ORM session
    :param tid: The tenant ID
    :param request: The request data
    :param language: The language of the request
    :return: The serialized descriptor of the updated field
    """
    field = db_update_field(session, tid, field_id, field, language)

    return serialize_field(session, tid, field, language)
예제 #10
0
def update_field(session, tid, field_id, field, language):
    """
    Update the specified field with the details.

    :param session: the session on which perform queries.
    :param field_id: the field_id of the field to update
    :param field: the field definition dict
    :param language: the language of the field definition dict
    :return: a serialization of the object
    """
    field = db_update_field(session, tid, field_id, field, language)

    return serialize_field(session, tid, field, language)
예제 #11
0
def get_fieldtemplate_list(store, language):
    """
    Serialize all the field templates localizing their content depending on the language.

    :param store: the store on which perform queries.
    :param language: the language of the field definition dict
    :return: the current field list serialized.
    :rtype: list of dict
    """
    templates = store.find(models.Field,
                           instance=u'template',
                           fieldgroup_id=None)

    return [serialize_field(store, f, language) for f in templates]
예제 #12
0
def get_fieldtemplate_list(session, tid, language):
    """
    Transaction to retrieve the list of the field templates defined on a tenant

    :param session: An ORM session
    :param tid: The tenant ID on which perform the lookup
    :param language: The language of the request
    :return: The list of serialized field template descriptors
    """
    templates = session.query(models.Field).filter(models.Field.tid.in_(set([1, tid])),
                                                   models.Field.instance == 'template',
                                                   models.Field.fieldgroup_id.is_(None))

    return [serialize_field(session, tid, f, language) for f in templates]
예제 #13
0
def get_fieldtemplate_list(session, tid, language):
    """
    Serialize all the field templates localizing their content depending on the language.

    :param session: the session on which perform queries.
    :param language: the language of the field definition dict
    :return: the current field list serialized.
    :rtype: list of dict
    """
    templates = session.query(models.Field).filter(
        models.Field.tid.in_(set([1,
                                  tid])), models.Field.instance == u'template',
        models.Field.fieldgroup_id == None)

    return [serialize_field(session, tid, f, language) for f in templates]
예제 #14
0
파일: field.py 프로젝트: zhou0/GlobaLeaks
def get_field(store, field_id, language):
    """
    Serialize a specified field

    :param store: the store on which perform queries.
    :param field_id: the id corresponding to the field.
    :param language: the language in which to localize data
    :return: the currently configured field.
    :rtype: dict
    """
    field = store.find(models.Field, models.Field.id == field_id).one()
    if not field:
        raise errors.FieldIdNotFound

    return serialize_field(store, field, language)
예제 #15
0
파일: field.py 프로젝트: zhou0/GlobaLeaks
def update_field(store, field_id, field, language):
    """
    Update the specified field with the details.
    raises :class:`globaleaks.errors.FieldIdNotFound` if the field does
    not exist.

    :param store: the store on which perform queries.
    :param field_id: the field_id of the field to update
    :param field: the field definition dict
    :param language: the language of the field definition dict
    :return: a serialization of the object
    """
    field = db_update_field(store, field_id, field, language)

    return serialize_field(store, field, language)
예제 #16
0
파일: field.py 프로젝트: Taipo/GlobaLeaks
def get_field(store, field_id, language, request_type=None):
    """
    Serialize a specified field

    :param store: the store on which perform queries.
    :param field_id: the id corresponding to the field.
    :param language: the language in which to localize data
    :return: the currently configured field.
    :rtype: dict
    """
    field = store.find(models.Field, models.Field.id == field_id).one()
    if not field:
        raise errors.FieldIdNotFound

    return serialize_field(store, field, language if request_type != 'export' else None)
예제 #17
0
파일: field.py 프로젝트: Taipo/GlobaLeaks
def update_field(store, field_id, field, language, request_type=None):
    """
    Update the specified field with the details.
    raises :class:`globaleaks.errors.FieldIdNotFound` if the field does
    not exist.

    :param store: the store on which perform queries.
    :param field_id: the field_id of the field to update
    :param field: the field definition dict
    :param language: the language of the field definition dict
    :return: a serialization of the object
    """
    field = db_update_field(store, field_id, field, language if request_type != 'import' else None)

    return serialize_field(store, field, language)
예제 #18
0
def get_fieldtemplate_list(store, language, request_type=None):
    """
    Serialize all the field templates localizing their content depending on the language.

    :param store: the store on which perform queries.
    :param language: the language of the field definition dict
    :return: the current field list serialized.
    :rtype: list of dict
    """
    language = language if request_type != "export" else None

    ret = []
    for f in store.find(models.Field, And(models.Field.instance == u"template", models.Field.fieldgroup_id == None)):
        ret.append(serialize_field(store, f, language))

    return ret
예제 #19
0
def get_fieldtemplate_list(store, language, request_type=None):
    """
    Serialize all the field templates localizing their content depending on the language.

    :param store: the store on which perform queries.
    :param language: the language of the field definition dict
    :return: the current field list serialized.
    :rtype: list of dict
    """
    language = language if request_type != 'export' else None

    ret = []
    for f in store.find(
            models.Field,
            And(models.Field.instance == u'template',
                models.Field.fieldgroup_id == None)):
        ret.append(serialize_field(store, f, language))

    return ret