Example #1
0
def update_template_fields(database, template):
    """Updates the fields array in the given template. The given template dictionary
    object must contain the template id and the new fields array. Returns the updated
    template dictionary object.
    """
    template = template_dao.update_template(database, template, changes=['fields'])
    return template
Example #2
0
def update_template(database, template, changes=None):
    """ Updates the template with the given changes. Returns the updated template
    dictionary object.
    """
    template = template_dao.update_template(database,
                                            template,
                                            changes=changes)
    return template
Example #3
0
def set_template_removal_date(database, template, remove_date):
    """Sets a removal date to the given template. Returns the updated template record.
    """
    if type(database) in [dict, OrderedDict]:
        database = database['database']
    template = template_model.update_remove_date(template, remove_date)
    template = template_dao.update_template(database, template, changes=['remove_date'])
    return template
Example #4
0
def update_template_fields(database, template):
    """Updates the fields array in the given template. The given template dictionary
    object must contain the template id and the new fields array. Returns the updated
    template dictionary object.
    """
    template = template_dao.update_template(database,
                                            template,
                                            changes=['fields'])
    return template
Example #5
0
def set_template_removal_date(database, template, remove_date):
    """Sets a removal date to the given template. Returns the updated template record.
    """
    if type(database) in [dict, OrderedDict]:
        database = database['database']
    template = template_model.update_remove_date(template, remove_date)
    template = template_dao.update_template(database,
                                            template,
                                            changes=['remove_date'])
    return template
Example #6
0
def move_template(database, template, new_structure, new_name):
    """Moves a template from its current structure to the new structure.
    If the name is different, also updates the name.
    """
    if type(template) in [dict, OrderedDict]:
        template_id = template['_id']
        template = template_dao.get_template_by_id(database, template_id)
    else:
        template = template_dao.get_template_by_id(database, template)
    structure_processor.remove_template_from_structure(database,
                                                       template['structure'],
                                                       template)
    changes = []
    if template['name'] != new_name:
        template = template_model.set_template_name(template, new_name)
        changes.append('name')
    template = template_model.set_template_structure(template, new_structure)
    changes.append('structure')
    template = template_dao.update_template(database,
                                            template,
                                            changes=changes)
    structure_processor.add_template_to_structure(database, new_structure,
                                                  template)
    return template
Example #7
0
 def update_template(template):
     template = template_dao.update_template(database,
                                             template,
                                             changes=changes)
     return template