Ejemplo n.º 1
0
from django.template.loader import render_to_string
from django.views.generic import ListView, DetailView, View, CreateView, UpdateView, DeleteView
from django.template.defaultfilters import slugify
from django.utils.translation import ugettext_lazy as _
from django.views.generic.detail import SingleObjectTemplateResponseMixin

from yummy.forms import FavoriteRecipeForm, CookBookAddForm, CookBookDeleteForm, CookBookEditForm
from yummy.models import (Category, Ingredient, Recipe, WeekMenu,
                          IngredientGroup, IngredientInRecipe, Cuisine,
                          CookBookRecipe, CookBook, ShoppingList)
from yummy import conf
from yummy.utils import import_module_member

FUNC_QS_BY_RATING = conf.FUNC_QS_BY_RATING
if FUNC_QS_BY_RATING:
    FUNC_QS_BY_RATING = import_module_member(FUNC_QS_BY_RATING)

GET_THUMBNAIL_FUNC = conf.GET_THUMBNAIL_FUNC
if GET_THUMBNAIL_FUNC:
    GET_THUMBNAIL_FUNC = import_module_member(GET_THUMBNAIL_FUNC)
else:
    GET_THUMBNAIL_FUNC = lambda img: img


class JSONResponseMixin(object):
    def render_to_response(self, context):
        return self.get_json_response(self.convert_context_to_json(context))

    def get_json_response(self, content, **kwargs):
        return HttpResponse(content, content_type='application/json', **kwargs)
Ejemplo n.º 2
0
    (3, _("March")),
    (4, _("April")),
    (5, _("May")),
    (6, _("June")),
    (7, _("July")),
    (8, _("August")),
    (9, _("September")),
    (10, _("October")),
    (11, _("November")),
    (12, _("December")),
)

PHOTO_ORDER_GAP = 5

# get function to be load and get qs as arg to return qs by rating
FUNC_QS_BY_RATING = getattr(settings, 'YUMMY_FUNC_QS_BY_RATING', None)

CACHE_TIMEOUT = 60 * 10
CACHE_TIMEOUT_LONG = 60 * 60 * 1

CACHE_PREFIX = 'yummy:dummy'

_CACHE_FUNCTION = getattr(settings, 'YUMMY_CACHE_OBJECT_FUNC',
                          'yummy.utils.cache.get_cached_model')
GET_CACHE_FUNCTION = lambda: import_module_member(_CACHE_FUNCTION)
LISTING_PAGINATE_BY = getattr(settings, 'YUMMY_LISTING_PAGINATE_BY', 15)

GET_THUMBNAIL_FUNC = getattr(settings, 'YUMMY_GET_THUMBNAIL_FUNC', None)

DEFAULT_COOKBOOK = _("Favorite recipes")
Ejemplo n.º 3
0
    (2, _("February")),
    (3, _("March")),
    (4, _("April")),
    (5, _("May")),
    (6, _("June")),
    (7, _("July")),
    (8, _("August")),
    (9, _("September")),
    (10, _("October")),
    (11, _("November")),
    (12, _("December")),
)

PHOTO_ORDER_GAP = 5

# get function to be load and get qs as arg to return qs by rating
FUNC_QS_BY_RATING = getattr(settings, 'YUMMY_FUNC_QS_BY_RATING', None)

CACHE_TIMEOUT = 60 * 10
CACHE_TIMEOUT_LONG = 60 * 60 * 1

CACHE_PREFIX = 'yummy:dummy'

_CACHE_FUNCTION = getattr(settings, 'YUMMY_CACHE_OBJECT_FUNC', 'yummy.utils.cache.get_cached_model')
GET_CACHE_FUNCTION = lambda: import_module_member(_CACHE_FUNCTION)
LISTING_PAGINATE_BY = getattr(settings, 'YUMMY_LISTING_PAGINATE_BY', 15)

GET_THUMBNAIL_FUNC = getattr(settings, 'YUMMY_GET_THUMBNAIL_FUNC', None)

DEFAULT_COOKBOOK = _("Favorite recipes")