def cockpit_page_result_list(cl): """ Displays the headers and data list together Replaces admin template tag "result_list". Constructs page list according to the hierarchical structure. """ headers = list(result_headers(cl)) num_sorted_fields = 0 for h in headers: if h['sortable'] and h['sorted']: num_sorted_fields += 1 page_results = cl.result_list ordered_results = create_ordered_page_list(page_results) cl.result_list = ordered_results['ordered_list'] hierarchy_levels = ordered_results['hierarchy_levels'] list_results = list(results(cl)) # Hierarchical indentation i = 0 for result in list_results: result[1] = remove_tags(result[1], "th") result[1] = mark_safe(u"<th style='padding-left: %dpx;'>%s</th>" % (5 + hierarchy_levels[i] * 20, result[1])) i += 1 return {'cl': cl, 'result_hidden_fields': list(result_hidden_fields(cl)), 'result_headers': headers, 'num_sorted_fields': num_sorted_fields, 'results': list_results}
def totalsum_result_list( context, cl, totals, unit_of_measure, template_name="totalsum_change_list_results.html", ): pagination_required = (not cl.show_all or not cl.can_show_all) and cl.multi_page headers = list(result_headers(cl)) num_sorted_fields = 0 for h in headers: if h["sortable"] and h["sorted"]: num_sorted_fields += 1 c = { "cl": cl, "totals": totals, "unit_of_measure": unit_of_measure, "result_hidden_fields": list(result_hidden_fields(cl)), "result_headers": headers, "num_sorted_fields": num_sorted_fields, "results": list(results(cl)), "pagination_required": pagination_required, } t = loader.get_template(template_name) return t.render(c)
def totalsum_result_list(context, cl, totals, unit_of_measure, template_name="totalsum_change_list_results.html"): pagination_required = (not cl.show_all or not cl.can_show_all) and cl.multi_page headers = list(result_headers(cl)) num_sorted_fields = 0 for h in headers: if h['sortable'] and h['sorted']: num_sorted_fields += 1 c = { 'cl': cl, 'totals': totals, 'unit_of_measure': unit_of_measure, 'result_hidden_fields': list(result_hidden_fields(cl)), 'result_headers': headers, 'num_sorted_fields': num_sorted_fields, 'results': list(results(cl)), 'pagination_required': pagination_required } t = loader.get_template(template_name) return t.render(c)
def __convert_to_response_lists(self, grouping_rule_dict, cl): table_list = [] for group in grouping_rule_dict.keys(): cl.result_list = grouping_rule_dict[group] list_of_rules = list(results(cl)) table_list.append(ResultList(None, self.__get_table_string_list(group, list_of_rules, cl))) table_list += list_of_rules return table_list
def result_list(context): """ Displays the headers and data list together """ cl = context['cl'] return {'cl': cl, 'result_headers': result_headers(cl), 'results': results(cl), 'export_delimiter' : context['export_delimiter'], }
def plugin_admin_result_list(cl): plugin_results = [] for i, result in enumerate(list(results(cl))): item = cl.result_list[i] plugin_results.append(dict(result=result, broken=item.broken)) return { 'cl': cl, 'result_headers': list(result_headers(cl)), 'plugin_results': plugin_results }
def result_list(context): """ Displays the headers and data list together """ cl = context["cl"] return { "cl": cl, "result_headers": list(result_headers(cl)), "results": list(results(cl)), "export_delimiter": context["export_delimiter"], }
def result_list_new(cl): """ Display the headers and data list together. """ headers = list(result_headers(cl)) return { 'cl': cl, 'result_hidden_fields': list(result_hidden_fields(cl)), 'result_headers': headers, 'results': list(results(cl)) }
def result_linked_list(cl): headers = list(result_headers(cl)) num_sorted_fields = 0 for h in headers: if h['sortable'] and h['sorted']: num_sorted_fields += 1 return {'cl': cl, 'result_hidden_fields': list(result_hidden_fields(cl)), 'result_headers': headers, 'num_sorted_fields': num_sorted_fields, 'results': list(results(cl))}
def tree_results(cl): tree_results = list(results(cl)) sorted_tree_results = [] for id in cl.tree_sort(None): i = 0 for obj in cl.get_query_set(): if (obj.id == id): tree_results[i].insert(1, mark_safe(u'<td style="padding: 0 0 0 %spx; width: 50px;">|-</td>' % (cl.get_depth(obj) * 20 + 20))) sorted_tree_results.append(tree_results[i]) i += 1 return sorted_tree_results
def custom_result_list(cl): headers = list(admin_list.result_headers(cl)) num_sorted_fields = 0 for h in headers: if h['sortable'] and h['sorted']: num_sorted_fields += 1 return { 'cl': cl, 'result_hidden_fields': list(admin_list.result_hidden_fields(cl)), 'result_headers': headers, 'num_sorted_fields': num_sorted_fields, 'results': list(admin_list.results(cl)) }
def daf_result_list(cl): """ Displays the headers and data list together """ headers = list(result_headers(cl)) num_sorted_fields = 0 for h in headers: if h['sortable'] and h['sorted']: num_sorted_fields += 1 return {'cl': cl, 'result_hidden_fields': list(result_hidden_fields(cl)), 'result_headers': headers, 'num_sorted_fields': num_sorted_fields, 'results': list(results(cl))}
def editregion_result_list(cl): """ This literally only exists to change the template and fix it properly. """ headers = list(result_headers(cl)) num_sorted_fields = 0 for h in headers: # pragma: no cover .. this was just copypasted from Django if h["sortable"] and h["sorted"]: num_sorted_fields += 1 return { "cl": cl, "result_hidden_fields": list(result_hidden_fields(cl)), "result_headers": headers, "num_sorted_fields": num_sorted_fields, "results": list(results(cl)), }
def result_list(cl): """ Copy/pasted from django.contrib.admin.templatetags.admin_list just so I can modify the value passed to `.inclusion_tag()` in the decorator here. There must be a cleaner way... right? """ headers = list(result_headers(cl)) num_sorted_fields = 0 for h in headers: if h['sortable'] and h['sorted']: num_sorted_fields += 1 return {'cl': cl, 'result_hidden_fields': list(result_hidden_fields(cl)), 'result_headers': headers, 'num_sorted_fields': num_sorted_fields, 'results': list(results(cl))}
def render(self, context): cl = Variable(self.cl).resolve(context) cat_id = context['request'].GET.get('category__id__exact') if cat_id: # positions = cl.model.positions.get(id=cat_id) position_model = cl.model.positions.related.model positions = position_model.objects.filter(category=cat_id, related_model__in=cl.result_list).order_by('sort_order') cl.result_list = [position.related_model for position in positions] return loader.render_to_string("admin/change_list_results.html", { 'cl': cl, 'result_hidden_fields': list(result_hidden_fields(cl)), 'result_headers': list(result_headers(cl)), 'results': list(results(cl))} )
def result_sortable_list(cl): """ Displays the headers and data list together """ if not cl.params.get('o',None): # Disable sortable when admin filter data from result table according to fields from ..models import Sortable cl.result_list = Sortable.get_sortable_row(cl.opts.model_name, cl.result_list) headers = list(result_headers(cl)) num_sorted_fields = 0 for h in headers: if h['sortable'] and h['sorted']: num_sorted_fields += 1 return {'cl': cl, 'result_hidden_fields': list(result_hidden_fields(cl)), 'result_headers': headers, 'num_sorted_fields': num_sorted_fields, 'results': list(results(cl))}
def board_result_list(cl): """ Displays the headers and data list together """ css = list(result_css(cl)) headers = list(admin_list.result_headers(cl)) num_sorted_fields = 0 results = list(admin_list.results(cl)) for h in headers: if h["sortable"] and h["sorted"]: num_sorted_fields += 1 return { "cl": cl, "css": css, "result_hidden_fields": list(admin_list.result_hidden_fields(cl)), "result_headers": headers, "num_sorted_fields": num_sorted_fields, "results": results, }
def my_result_list(cl): headers = list(result_headers(cl)) num_sorted_fields = 0 for h in headers: if h['sortable'] and h['sorted']: num_sorted_fields += 1 rl = list(results(cl)) for i in range(len(rl)): for j in range(1,len(rl[i])): rl[i][j] = mark_safe(rl[i][j].replace( '<a ','<a class="btn-link" ').replace( '<th class="','<th style="vertical-align:middle" class="text-center ').replace( '<td class="','<td style="vertical-align:middle" class="') ) return {'cl': cl, 'result_hidden_fields': list(result_hidden_fields(cl)), 'result_headers': headers, 'num_sorted_fields': num_sorted_fields, 'results': rl,}
def obj_row(self, request, obj_id): body = json.loads(request.body) item = next(serializers.deserialize('python', body['data'])) list_display = self.get_list_display(request) list_display_links = self.get_list_display_links(request, list_display) list_filter = self.get_list_filter(request) search_fields = self.get_search_fields(request) list_select_related = self.get_list_select_related(request) # Check actions to see if any are available on this changelist actions = self.get_actions(request) if actions: # Add the action checkboxes if there are any actions available. list_display = ['action_checkbox'] + list(list_display) cl = SimpleRowChangeList(request, self.model, list_display, list_display_links, list_filter, self.date_hierarchy, search_fields, list_select_related, 1, self.list_max_show_all, self.list_editable, self, item=item.object) cl.formset = None if cl.list_editable: FormSet = self.get_changelist_formset(request) cl.formset = FormSet(queryset=cl.result_list) result = next(results(cl)) return render(request, 'admin/django_realtime_admin/row.html', { 'result': result, 'class_name': body['className'] })
def result_list(cl): """ Display the headers and data list together. """ headers = list(result_headers(cl)) result = list(results(cl)) count = 0 for item in result: count_tag = item[-1] if count_tag.find('field-count') != -1: count = count + int(re.search('\d+', count_tag).group()) if count > 0: headers[-1]['text'] = headers[-1]['text'] + '(本页共计' + str(count) + '份)' num_sorted_fields = 0 for h in headers: if h['sortable'] and h['sorted']: num_sorted_fields += 1 return { 'cl': cl, 'result_hidden_fields': list(result_hidden_fields(cl)), 'result_headers': headers, 'num_sorted_fields': num_sorted_fields, 'results': result, }
def newman_result_list(cl): return {'cl': cl, 'result_headers': list(result_headers(cl)), 'results': list(results(cl))}
def newman_result_list(cl): return { 'cl': cl, 'result_headers': list(result_headers(cl)), 'results': list(results(cl)) }
def article_result_list(cl): return {'cl': cl, 'result_hidden_fields': list(result_hidden_fields(cl)), 'result_headers': list(result_headers(cl)), 'results': zip(cl.result_list,list(results(cl)))}
def plugin_admin_result_list(cl): plugin_results = [] for i, result in enumerate(list(results(cl))): item = cl.result_list[i] plugin_results.append(dict(result=result, broken=item.broken)) return {"cl": cl, "result_headers": list(result_headers(cl)), "plugin_results": plugin_results}
def category_result_list(cl): return { 'cl': cl, 'result_headers': list(result_headers(cl)), 'results': list(results(cl)), }