예제 #1
0
    def get(self, **kwargs):
        context = {
            'all_news': News.all().order('-date'),
            }

        context = request_context(context)

        return render_response('news.html', **context)
예제 #2
0
def request_context(context):
    def js_string(value):
        return '\'' + value + '\''

    now = datetime.datetime.now(pytz.timezone('America/Argentina/Buenos_Aires'))
    # TODO: convert this to a JSON file
    js_settings = {
        'MEDIA_URL': js_string(settings.MEDIA_URL),
        'INITIAL_LOCATION': settings.INITIAL_LOCATION,
        'WEEKDAY': js_string(utils.get_weekday_display()),
        'CLOCK': simplejson.dumps({
                'year': now.year, 'month': now.month, 'day': now.day,
                'hour': now.hour, 'minute': now.minute, 'second': now.second
                })
        }

    context.update({
            'MEDIA_URL': settings.MEDIA_URL,
            'JS_SETTINGS': js_settings,
            'news': News.all().order('-date')[:5],
            })
    return context
예제 #3
0
 def get(self):
     news = News.all().order("title").fetch(MAX_FETCH_LIMIT)
     news_list = []
     for item in news:
         news_list.append(item.to_json_dict("title", "is_starred", "is_active", "is_deleted", "when_created"))
     self.response.out.write(json.dumps(news_list))