# Path: template_maker/database.py
# class CRUDMixin(object):
# class Model(CRUDMixin, db.Model):
# class SurrogatePK(object):
#     def create(cls, **kwargs):
#     def update(self, commit=True, **kwargs):
#     def save(self, commit=True):
#     def delete(self, commit=True):
#     def get_by_id(cls, id):
# def ReferenceCol(tablename, nullable=False, ondelete=None, pk_name='id', **kwargs):
# 
# Path: template_maker/builder/models.py
# class TemplatePlaceholders(Model):
#     '''
#     The placeholders associated with each section
# 
#     Fields:
#     - name: The actual name of the placeholder
#     - template_id: Foreign Key back to the TemplateBase model
#     - section_id: Foreign Key back to the TemplateSection model
#     '''
# 
#     __tablename__ = 'template_placeholders'
#     id = Column(db.Integer, primary_key=True)
#     full_name = Column(db.Text)
#     display_name = Column(db.Text)
#     type = Column(db.Integer, db.ForeignKey('placeholder_types.id'))
#     template_id = ReferenceCol('template_base')
#     section_id = ReferenceCol('template_section')
# 
#     def __init__(self, name=None, template_id=None, section_id=None):
#         self.name = name
#         self.template_id = template_id
#         self.section_id = section_id


from template_maker.database import db
from template_maker.builder.models import TemplatePlaceholders
from bs4 import BeautifulSoup
VARIABLE_TYPE_MAPS = {
    'text': 1, 'date': 2,'number': 3, 'float': 4
}

def get_all_placeholders(html):
    '''
    Uses BeautifulSoup to parse through an HTML block and
    return all .fr-placeholder span tags
    '''
    soup = BeautifulSoup(html)
    return soup.find_all('span', {'class': 'js-fr-placeholder'})

def get_template_placeholders(template_id):
    '''
    Gets the placeholders associated with each template

    Returns a list of placeholders associated with the template
    along with the sections that they are tied to
    '''
    return TemplatePlaceholders.query.filter(
        TemplatePlaceholders.template_id==template_id
    ).order_by(TemplatePlaceholders.id).all()

def get_section_placeholders(section_id):
    '''
    Gets the placeholders associated with each section

    Returns a list of TemplatePlaceholders associated
    with the input section_id
    '''

# Path: template_maker/database.py
# class CRUDMixin(object):
# class Model(CRUDMixin, db.Model):
# class SurrogatePK(object):
#     def create(cls, **kwargs):
#     def update(self, commit=True, **kwargs):
#     def save(self, commit=True):
#     def delete(self, commit=True):
#     def get_by_id(cls, id):
# def ReferenceCol(tablename, nullable=False, ondelete=None, pk_name='id', **kwargs):
# 
# Path: template_maker/builder/models.py
# class TemplatePlaceholders(Model):
#     '''
#     The placeholders associated with each section
# 
#     Fields:
#     - name: The actual name of the placeholder
#     - template_id: Foreign Key back to the TemplateBase model
#     - section_id: Foreign Key back to the TemplateSection model
#     '''
# 
#     __tablename__ = 'template_placeholders'
#     id = Column(db.Integer, primary_key=True)
#     full_name = Column(db.Text)
#     display_name = Column(db.Text)
#     type = Column(db.Integer, db.ForeignKey('placeholder_types.id'))
#     template_id = ReferenceCol('template_base')
#     section_id = ReferenceCol('template_section')
# 
#     def __init__(self, name=None, template_id=None, section_id=None):
#         self.name = name
#         self.template_id = template_id
#         self.section_id = section_id


# Path: template_maker/data/placeholders.py
from template_maker.database import db
from template_maker.builder.models import TemplatePlaceholders
from bs4 import BeautifulSoup

VARIABLE_TYPE_MAPS = {
    'text': 1, 'date': 2,'number': 3, 'float': 4
}

def get_all_placeholders(html):
    '''
    Uses BeautifulSoup to parse through an HTML block and
    return all .fr-placeholder span tags
    '''
    soup = BeautifulSoup(html)
    return soup.find_all('span', {'class': 'js-fr-placeholder'})

def get_template_placeholders(template_id):
    '''
    Gets the placeholders associated with each template

    Returns a list of placeholders associated with the template
    along with the sections that they are tied to
    '''
    return TemplatePlaceholders.query.filter(
        TemplatePlaceholders.template_id==template_id
    ).order_by(TemplatePlaceholders.id).all()

def get_section_placeholders(section_id):
    '''
    Gets the placeholders associated with each section

    Returns a list of TemplatePlaceholders associated
    with the input section_id
    '''

    return TemplatePlaceholders.query.filter(