
from ...util.framework import create_blueprint

from ..brand.models import Brand


blueprint = create_blueprint('core_admin', __name__)


@blueprint.app_context_processor
def inject_brands():
    return {
        'all_brands': Brand.query.all(),
    }


from ...util.framework import create_blueprint

from ..brand import service as brand_service


blueprint = create_blueprint('core_admin', __name__)


@blueprint.app_context_processor
def inject_brands():
    brands = brand_service.get_brands()

    return {
        'all_brands': brands,
    }

Move database query assembly and execution from view functions to services ('core_admin' blueprint)
Move database query assembly and execution from view functions to services ('core_admin' blueprint)

  
  from ...util.framework import create_blueprint
  
- from ..brand.models import Brand
+ from ..brand import service as brand_service
  
  
  blueprint = create_blueprint('core_admin', __name__)
  
  
  @blueprint.app_context_processor
  def inject_brands():
+     brands = brand_service.get_brands()
+ 
      return {
-         'all_brands': Brand.query.all(),
+         'all_brands': brands,
      }
  
Move database query assembly and execution from view functions to services ('core_admin' blueprint)
## Code Before:

from ...util.framework import create_blueprint

from ..brand.models import Brand


blueprint = create_blueprint('core_admin', __name__)


@blueprint.app_context_processor
def inject_brands():
    return {
        'all_brands': Brand.query.all(),
    }

## Instruction:
Move database query assembly and execution from view functions to services ('core_admin' blueprint)
## Code After:

from ...util.framework import create_blueprint

from ..brand import service as brand_service


blueprint = create_blueprint('core_admin', __name__)


@blueprint.app_context_processor
def inject_brands():
    brands = brand_service.get_brands()

    return {
        'all_brands': brands,
    }
