ajax.py
1.06 KB
# -*- coding: utf-8 -*-
from common.decorators import ajax, render, render_ajax
from paginer import types, PaginationList
@render_ajax(template='ajax_paginer.html', method='post')
def get_page_content(request, paginer_id, paginer_type, params, action, page_nr,
group_actions=None):
paginer = PaginationList()
paginer.add(
paginer_id, paginer_type, params, action=action,
group_actions=group_actions)
return {
'paginer': paginer,
'id': paginer_id,
'page_nr': page_nr,
}
@render()
@ajax(method='get', encode_result=False)
def new_filter_row(request, list_type):
filter_field_form_class = types[list_type].filter_field_form
form = filter_field_form_class(prefix='field_NUM')
return {'form': form}
@render()
@ajax(method='get', encode_result=False)
def field_form(request, list_type, field_name):
filter_data = types[list_type].filters[field_name]
lookup_choices = filter_data[1]
form = filter_data[2](prefix='value_NUM')
return {'lookup_choices': lookup_choices, 'form': form}