<commit_before>"Django admin support for treebeard"

from django.contrib import admin, messages
from django.contrib.admin.views.main import ChangeList
from django.conf.urls.defaults import url, patterns
from django.http import HttpResponseBadRequest, HttpResponse

from treebeard.forms import MoveNodeForm
from treebeard.templatetags.admin_tree import check_empty_dict
from treebeard.exceptions import InvalidPosition, MissingNodeOrderBy, InvalidMoveToDescendant, PathOverflow

class TreeChangeList(ChangeList):
    def get_ordering(self):
        """
        Overriding default's ChangeList.get_ordering so we don't sort the
        results by '-id' as default
        """
        lookup_opts, params = self.lookup_opts, self.params
        ordering = self.model_admin.ordering or lookup_opts.ordering or None

        if ordering is not None or not check_empty_dict(params):
            return super(TreeChangeList, self).get_ordering()
        return None, 'asc'



class TreeAdmin(admin.ModelAdmin):
    "Django Admin class for treebeard"
    change_list_template = 'admin/tree_change_list.html'
    form = MoveNodeForm<commit_msg>sorting fix for NS trees , actually for models that have ordering, Im not listening to that to show the TreeAdmin<commit_after>"Django admin support for treebeard"

from django.contrib import admin, messages
from django.contrib.admin.views.main import ChangeList
from django.conf.urls.defaults import url, patterns
from django.http import HttpResponseBadRequest, HttpResponse

from treebeard.forms import MoveNodeForm
from treebeard.templatetags.admin_tree import check_empty_dict
from treebeard.exceptions import InvalidPosition, MissingNodeOrderBy, InvalidMoveToDescendant, PathOverflow

class TreeChangeList(ChangeList):
    def get_ordering(self):
        """
        Overriding default's ChangeList.get_ordering so we don't sort the
        results by '-id' as default
        """
        if not check_empty_dict(self.params):
            return super(TreeChangeList, self).get_ordering()
        return None, 'asc'



class TreeAdmin(admin.ModelAdmin):
    "Django Admin class for treebeard"
    change_list_template = 'admin/tree_change_list.html'
    form = MoveNodeForm
{'fraction_non_alphanumeric': 0.06507004066877542, 'fraction_numerical': 0.0, 'mean_word_length': 4.258907363420428, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3469504', 'n_tokens_mistral': 610, 'n_tokens_neox': 592, 'n_words': 185}