Ejemplo n.º 1
0
    def get(self, month):
        if month.capitalize() in seasons().keys():
            recipes = uniq([k for k in queryForMonth(seasons()[month][0])] +
                           [k for k in queryForMonth(seasons()[month][1])] +
                           [k for k in queryForMonth(seasons()[month][2])])
            recipes = [Recipe.get(k) for k in recipes]
        else:
            recipes = [r for r in Recipe.gql('WHERE %s = TRUE' % month.lower())]

        templatevalues = RequestContext(self.request, {
            'month' : month.capitalize(),
            'recipes' : recipes,
            'json' : simplejson.dumps([r.to_dict() for r in recipes]),
            })

        path = os.path.join(os.path.dirname(__file__), 'month.html')
        self.response.out.write(template.render(path, templatevalues))
Ejemplo n.º 2
0
def newSeasonStruct(name, extraCls, extraMonths):
    thismonth = date.today().strftime("%B")
    months = helpers.seasons()[name]
    s = expando()
    s.name = name
    s.cls = name.lower() + ' ' + extraCls
    if thismonth in months: s.cls += ' current'
    s.months = ','.join(["#%s" % m[:3] for m in months]) + ',' + extraMonths
    return s