Exemple #1
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)
Exemple #2
0
def create_field(store, field_dict, language):
    """
    Transaction that perform db_create_field
    """
    field = db_create_field(store, field_dict, language)

    return serialize_field(store, field, language)
Exemple #3
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)
Exemple #4
0
def create_field(store, field_dict, language, import_export=None):
    """
    Transaction that perform db_create_field
    """
    field = db_create_field(store, field_dict, language if import_export != 'import' else None)

    return serialize_field(store, field, language if import_export != 'export' else None)
Exemple #5
0
def create_field(store, field_dict, language, import_export=None):
    """
    Transaction that perform db_create_field
    """
    field = db_create_field(store, field_dict,
                            language if import_export != 'import' else None)

    return serialize_field(store, field,
                           language if import_export != 'export' else None)
Exemple #6
0
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)
Exemple #7
0
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)
Exemple #8
0
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)
Exemple #9
0
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)
Exemple #10
0
def get_fieldtemplates_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
    """
    ret = []

    for f in store.find(models.Field, models.Field.instance == u'template'):
        if not store.find(models.FieldField, models.FieldField.child_id == f.id).one():
            ret.append(serialize_field(store, f, language))

    return ret
Exemple #11
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, models.Field.instance == u'template'):
        if f.fieldgroup is None:
            ret.append(serialize_field(store, f, language))

    return ret
Exemple #12
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, models.Field.instance == u'template'):
        if f.fieldgroup is None:
            ret.append(serialize_field(store, f, language))

    return ret
Exemple #13
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
    """
    ret = []

    for f in store.find(models.Field, models.Field.instance == u'template'):
        if not store.find(models.FieldField, models.FieldField.child_id
                          == f.id).one():
            ret.append(serialize_field(store, f, language))

    return ret
Exemple #14
0
 def _get_field(self, store, field_id):
     field = models.Field.get(store, field_id)
     return serialize_field(store, field, 'en')
Exemple #15
0
 def _get_field(self, store, field_id):
     field = models.Field.get(store, field_id)
     return serialize_field(store, field, 'en')