def qe_result_list(context, cl): data = result_list(cl) data.update({ 'qe_fields': cl.model_admin.quick_editable, 'results': list(results(cl, context.request)), }) return data
def result_list_with_context(context, cl): """ Wraps Djangos default result_list to ammend the context with the request. This gives us access to the request in change_list_results. """ res = result_list(cl) res['request'] = context['request'] return res
def folderless_result_list(cl): """ Displays the headers and data list together """ context = result_list(cl) for row_no, row in enumerate(context['results']): for cell_no, cell in enumerate(row): # TODO: this feels awkward?! context['results'][row_no][cell_no] = format_html(cell.replace(DISMISS_STRING, REPLACE_STRING)) return context
def folderless_result_list(cl): """ Displays the headers and data list together """ context = result_list(cl) for row_no, row in enumerate(context['results']): for cell_no, cell in enumerate(row): # TODO: this feels awkward?! context['results'][row_no][cell_no] = format_html( cell.replace(DISMISS_STRING, REPLACE_STRING)) return context
def minke_result_list(context, cl): """ Support rendering of session-info-rows for changelist-results. """ sessions = cl.sessions if hasattr(cl, 'sessions') else cl.result_list cntxt = result_list(cl) # django1 has problems with RequestConext together with forloop, cycle and # nested inclusion-tags.So we use the context as dictonary. cntxt.update(context.flatten()) cntxt['results'] = zip(cntxt['results'], sessions) return cntxt
def test_suit_list_cells_handler_by_response(self): Book.objects.all().delete() for x in range(2): book = Book(pk=x, name="sky-%s" % x) book.save() self.get_changelist() cl = self.changelist results = result_list(cl)["results"] result_cells = cells_handler(results, cl) self.assertTrue('class="suit_cell_attr_class-name-sky-1' in result_cells[0][-1]) self.assertTrue(' data="1"' in result_cells[0][-1])
def result_list_patrimonio(cl): res = result_list(cl) results = res["results"] results = [r for r in results if r.endereco] results = sorted(results, key=lambda x: x.endereco.entidade) lista = [] for r in results: lista = lista + busca(r) res.update({"results": lista}) return res
def result_list_patrimonio(cl): res = result_list(cl) results = res['results'] results = [r for r in results if r.endereco] results = sorted(results, key=lambda x: x.endereco.entidade) lista = [] for r in results: lista = lista + busca(r) res.update({'results': lista}) return res
def test_suit_list_cells_handler_by_response(self): Book.objects.all().delete() for x in range(2): book = Book(pk=x, name='sky-%s' % x) book.save() self.get_changelist() cl = self.changelist results = result_list(cl)['results'] result_cells = cells_handler(results, cl) self.assertTrue( 'class="suit_cell_attr_class-name-sky-1' in result_cells[0][-1]) self.assertTrue(' data="1"' in result_cells[0][-1])
def position_result_list(change_list): """ Returns a template which iters through the models and appends a new position column. """ result = result_list(change_list) # Remove sortable attributes for x in range(0, len(result['result_headers'])): result['result_headers'][x]['sorted'] = False if result['result_headers'][x]['sortable']: result['result_headers'][x]['class_attrib'] = mark_safe( ' class="sortable"') # Append position <th> element result['result_headers'].append({ 'url_remove': '?o=', 'sort_priority': 1, 'sortable': True, 'class_attrib': mark_safe(' class="sortable sorted ascending"'), 'sorted': True, 'text': 'position', 'ascending': True, 'url_primary': '?o=-1', 'url_toggle': '?o=-1', }) # Append the editable field to every result item for x in range(0, len(result['results'])): obj = change_list.result_list[x] # Get position object c_type = ContentType.objects.get_for_model(obj) try: object_position = ObjectPosition.objects.get( content_type__pk=c_type.id, object_id=obj.id) except ObjectPosition.DoesNotExist: object_position = ObjectPosition.objects.create(content_object=obj) # Add the <td> html = ('<td><input class="vTextField" id="id_position-{0}"' ' maxlength="10" name="position-{0}" type="text"' ' value="{1}" /></td>').format(object_position.id, object_position.position) result['results'][x].append(mark_safe(html)) return result
def smart_result_list(cl): """ Displays the headers and data list together If there is only column the headers are not displayed as it is usually clear what is being displayed. This change comes from issue #67, if you want to always display the header use Django's `result_list`. """ result_list_context = admin_list.result_list(cl) # If there is one or less headers remove them. if len(result_list_context["result_headers"]): del result_list_context["result_headers"] return result_list_context
def voos_list(cl): context = result_list(cl) context['results'] = zip(cl.result_list, context['results']) return context
def preferences_result_list(cl): """ Display the headers and data list together. """ return admin_list.result_list(cl)
def user_result_list(cl): """ Display the headers and data list together. """ return admin_list.result_list(cl)