From 37f91cce9762606200fa0888ae1e9ae9a9a4ffec Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Fri, 24 Feb 2012 22:35:30 -0600 Subject: [PATCH] Added SortableForeignKey field to replace `sortable_by` model property. Refactored how the sortable_by properties get populated by looping over the model fields until we get to the SortableForeignKey, then grabbing properties from the field and its related data. --- .gitignore | 0 AUTHORS | 0 COPYRIGHT | 0 MANIFEST.in | 0 README | 0 adminsortable/__init__.py | 2 +- adminsortable/admin.py | 38 +++++++-- adminsortable/fields.py | 9 ++ adminsortable/locale/en/LC_MESSAGES/django.po | 0 adminsortable/locale/nl/LC_MESSAGES/django.mo | Bin adminsortable/locale/nl/LC_MESSAGES/django.po | 0 adminsortable/models.py | 24 ++++++ .../adminsortable/css/admin.sortable.css | 0 .../css/admin.sortable.tabular.inline.css | 0 .../static/adminsortable/js/admin.sortable.js | 0 .../js/admin.sortable.stacked.inlines.js | 0 .../js/admin.sortable.tabular.inlines.js | 0 .../adminsortable/js/jquery.effects.core.js | 0 .../js/jquery.effects.highlight.js | 0 .../static/adminsortable/js/jquery.ui.core.js | 0 .../adminsortable/js/jquery.ui.draggable.js | 0 .../adminsortable/js/jquery.ui.droppable.js | 0 .../adminsortable/js/jquery.ui.mouse.js | 0 .../adminsortable/js/jquery.ui.sortable.js | 0 .../adminsortable/js/jquery.ui.widget.js | 0 .../templates/adminsortable/change_form.html | 0 .../templates/adminsortable/change_list.html | 0 .../change_list_with_sort_link.html | 0 .../adminsortable/edit_inline/stacked.html | 0 .../adminsortable/edit_inline/tabular.html | 0 .../shared/javascript_includes.html | 0 .../adminsortable/shared/list_items.html | 0 .../adminsortable/shared/nested_objects.html | 0 .../adminsortable/shared/object_rep.html | 0 .../adminsortable/shared/objects.html | 0 adminsortable/templatetags/__init__.py | 0 .../templatetags/adminsortable_tags.py | 0 .../templatetags/django_template_additions.py | 0 sample_project/README | 0 sample_project/__init__.py | 0 sample_project/adminsortable.sqlite | Bin 63488 -> 54272 bytes sample_project/app/__init__.py | 0 sample_project/app/admin.py | 3 +- sample_project/app/fixtures/initial_data.json | 56 +++++++++++++ sample_project/app/fixtures/test_data.json | 0 sample_project/app/migrations/0001_initial.py | 77 ------------------ .../app/migrations/0002_add_note.py | 59 -------------- .../app/migrations/0003_add_sample.py | 68 ---------------- sample_project/app/migrations/__init__.py | 0 sample_project/app/models.py | 27 ++---- sample_project/app/tests.py | 11 ++- sample_project/appmedia/BeautifulSoup.py | 0 sample_project/appmedia/__init__.py | 0 sample_project/appmedia/api.py | 0 .../appmedia/management/__init__.py | 0 .../appmedia/management/commands/__init__.py | 0 .../management/commands/buildmedia.py | 0 .../management/commands/symlinkmedia.py | 0 sample_project/appmedia/middleware.py | 0 sample_project/appmedia/models.py | 0 sample_project/appmedia/urls.py | 0 sample_project/appmedia/views.py | 0 sample_project/manage.py | 0 sample_project/settings.py | 0 .../adminsortable/css/admin.sortable.css | 0 .../css/admin.sortable.tabular.inline.css | 0 .../static/adminsortable/js/admin.sortable.js | 0 .../js/admin.sortable.stacked.inlines.js | 0 .../js/admin.sortable.tabular.inlines.js | 0 .../adminsortable/js/jquery.effects.core.js | 0 .../js/jquery.effects.highlight.js | 0 .../static/adminsortable/js/jquery.ui.core.js | 0 .../adminsortable/js/jquery.ui.draggable.js | 0 .../adminsortable/js/jquery.ui.droppable.js | 0 .../adminsortable/js/jquery.ui.mouse.js | 0 .../adminsortable/js/jquery.ui.sortable.js | 0 .../adminsortable/js/jquery.ui.widget.js | 0 sample_project/templates/index.html | 0 sample_project/urls.py | 0 setup.py | 0 80 files changed, 135 insertions(+), 239 deletions(-) mode change 100755 => 100644 .gitignore mode change 100755 => 100644 AUTHORS mode change 100755 => 100644 COPYRIGHT mode change 100755 => 100644 MANIFEST.in mode change 100755 => 100644 README mode change 100755 => 100644 adminsortable/__init__.py mode change 100755 => 100644 adminsortable/admin.py create mode 100644 adminsortable/fields.py mode change 100755 => 100644 adminsortable/locale/en/LC_MESSAGES/django.po mode change 100755 => 100644 adminsortable/locale/nl/LC_MESSAGES/django.mo mode change 100755 => 100644 adminsortable/locale/nl/LC_MESSAGES/django.po mode change 100755 => 100644 adminsortable/models.py mode change 100755 => 100644 adminsortable/static/adminsortable/css/admin.sortable.css mode change 100755 => 100644 adminsortable/static/adminsortable/css/admin.sortable.tabular.inline.css mode change 100755 => 100644 adminsortable/static/adminsortable/js/admin.sortable.js mode change 100755 => 100644 adminsortable/static/adminsortable/js/admin.sortable.stacked.inlines.js mode change 100755 => 100644 adminsortable/static/adminsortable/js/admin.sortable.tabular.inlines.js mode change 100755 => 100644 adminsortable/static/adminsortable/js/jquery.effects.core.js mode change 100755 => 100644 adminsortable/static/adminsortable/js/jquery.effects.highlight.js mode change 100755 => 100644 adminsortable/static/adminsortable/js/jquery.ui.core.js mode change 100755 => 100644 adminsortable/static/adminsortable/js/jquery.ui.draggable.js mode change 100755 => 100644 adminsortable/static/adminsortable/js/jquery.ui.droppable.js mode change 100755 => 100644 adminsortable/static/adminsortable/js/jquery.ui.mouse.js mode change 100755 => 100644 adminsortable/static/adminsortable/js/jquery.ui.sortable.js mode change 100755 => 100644 adminsortable/static/adminsortable/js/jquery.ui.widget.js mode change 100755 => 100644 adminsortable/templates/adminsortable/change_form.html mode change 100755 => 100644 adminsortable/templates/adminsortable/change_list.html mode change 100755 => 100644 adminsortable/templates/adminsortable/change_list_with_sort_link.html mode change 100755 => 100644 adminsortable/templates/adminsortable/edit_inline/stacked.html mode change 100755 => 100644 adminsortable/templates/adminsortable/edit_inline/tabular.html mode change 100755 => 100644 adminsortable/templates/adminsortable/shared/javascript_includes.html mode change 100755 => 100644 adminsortable/templates/adminsortable/shared/list_items.html mode change 100755 => 100644 adminsortable/templates/adminsortable/shared/nested_objects.html mode change 100755 => 100644 adminsortable/templates/adminsortable/shared/object_rep.html mode change 100755 => 100644 adminsortable/templates/adminsortable/shared/objects.html mode change 100755 => 100644 adminsortable/templatetags/__init__.py mode change 100755 => 100644 adminsortable/templatetags/adminsortable_tags.py mode change 100755 => 100644 adminsortable/templatetags/django_template_additions.py mode change 100755 => 100644 sample_project/README mode change 100755 => 100644 sample_project/__init__.py mode change 100755 => 100644 sample_project/adminsortable.sqlite mode change 100755 => 100644 sample_project/app/__init__.py mode change 100755 => 100644 sample_project/app/admin.py create mode 100644 sample_project/app/fixtures/initial_data.json mode change 100755 => 100644 sample_project/app/fixtures/test_data.json delete mode 100755 sample_project/app/migrations/0001_initial.py delete mode 100755 sample_project/app/migrations/0002_add_note.py delete mode 100755 sample_project/app/migrations/0003_add_sample.py delete mode 100755 sample_project/app/migrations/__init__.py mode change 100755 => 100644 sample_project/app/models.py mode change 100755 => 100644 sample_project/app/tests.py mode change 100755 => 100644 sample_project/appmedia/BeautifulSoup.py mode change 100755 => 100644 sample_project/appmedia/__init__.py mode change 100755 => 100644 sample_project/appmedia/api.py mode change 100755 => 100644 sample_project/appmedia/management/__init__.py mode change 100755 => 100644 sample_project/appmedia/management/commands/__init__.py mode change 100755 => 100644 sample_project/appmedia/management/commands/buildmedia.py mode change 100755 => 100644 sample_project/appmedia/management/commands/symlinkmedia.py mode change 100755 => 100644 sample_project/appmedia/middleware.py mode change 100755 => 100644 sample_project/appmedia/models.py mode change 100755 => 100644 sample_project/appmedia/urls.py mode change 100755 => 100644 sample_project/appmedia/views.py mode change 100755 => 100644 sample_project/manage.py mode change 100755 => 100644 sample_project/settings.py mode change 100755 => 100644 sample_project/static/adminsortable/css/admin.sortable.css mode change 100755 => 100644 sample_project/static/adminsortable/css/admin.sortable.tabular.inline.css mode change 100755 => 100644 sample_project/static/adminsortable/js/admin.sortable.js mode change 100755 => 100644 sample_project/static/adminsortable/js/admin.sortable.stacked.inlines.js mode change 100755 => 100644 sample_project/static/adminsortable/js/admin.sortable.tabular.inlines.js mode change 100755 => 100644 sample_project/static/adminsortable/js/jquery.effects.core.js mode change 100755 => 100644 sample_project/static/adminsortable/js/jquery.effects.highlight.js mode change 100755 => 100644 sample_project/static/adminsortable/js/jquery.ui.core.js mode change 100755 => 100644 sample_project/static/adminsortable/js/jquery.ui.draggable.js mode change 100755 => 100644 sample_project/static/adminsortable/js/jquery.ui.droppable.js mode change 100755 => 100644 sample_project/static/adminsortable/js/jquery.ui.mouse.js mode change 100755 => 100644 sample_project/static/adminsortable/js/jquery.ui.sortable.js mode change 100755 => 100644 sample_project/static/adminsortable/js/jquery.ui.widget.js mode change 100755 => 100644 sample_project/templates/index.html mode change 100755 => 100644 sample_project/urls.py mode change 100755 => 100644 setup.py diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/AUTHORS b/AUTHORS old mode 100755 new mode 100644 diff --git a/COPYRIGHT b/COPYRIGHT old mode 100755 new mode 100644 diff --git a/MANIFEST.in b/MANIFEST.in old mode 100755 new mode 100644 diff --git a/README b/README old mode 100755 new mode 100644 diff --git a/adminsortable/__init__.py b/adminsortable/__init__.py old mode 100755 new mode 100644 index 44f81a6..3a4fe3d --- a/adminsortable/__init__.py +++ b/adminsortable/__init__.py @@ -1,4 +1,4 @@ -VERSION = (1, 2, "f", 0) # following PEP 386 +VERSION = (1, 3, "f", 0) # following PEP 386 DEV_N = None diff --git a/adminsortable/admin.py b/adminsortable/admin.py old mode 100755 new mode 100644 index 8097647..459042a --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -9,6 +9,7 @@ from django.shortcuts import render from django.template.defaultfilters import capfirst from django.views.decorators.csrf import csrf_exempt +from adminsortable.fields import SortableForeignKey from adminsortable.models import Sortable STATIC_URL = settings.STATIC_URL @@ -20,8 +21,17 @@ class SortableAdmin(ModelAdmin): class Meta: abstract = True + def _get_sortable_foreign_key(self): + sortable_foreign_key = None + for field in self.model._meta.fields: + if isinstance(field, SortableForeignKey): + sortable_foreign_key = field + break + return sortable_foreign_key + def __init__(self, *args, **kwargs): super(SortableAdmin, self).__init__(*args, **kwargs) + self.has_sortable_tabular_inlines = False self.has_sortable_stacked_inlines = False for klass in self.inlines: @@ -55,11 +65,16 @@ class SortableAdmin(ModelAdmin): #Determine if we need to regroup objects relative to a foreign key specified on the # model class that is extending Sortable. - sortable_by = getattr(self.model, 'sortable_by', None) - if sortable_by: + #Legacy support for 'sortable_by' defined as a model property + sortable_by_property = getattr(self.model, 'sortable_by', None) + + #`sortable_by` defined as a SortableForeignKey + sortable_by_fk = self._get_sortable_foreign_key() + + if sortable_by_property: #backwards compatibility for < 1.1.1, where sortable_by was a classmethod instead of a property try: - sortable_by_class, sortable_by_expression = sortable_by() + sortable_by_class, sortable_by_expression = sortable_by_property() except TypeError, ValueError: sortable_by_class = self.model.sortable_by sortable_by_expression = sortable_by_class.__name__.lower() @@ -67,15 +82,24 @@ class SortableAdmin(ModelAdmin): sortable_by_class_display_name = sortable_by_class._meta.verbose_name_plural sortable_by_class_is_sortable = sortable_by_class.is_sortable() + elif sortable_by_fk: + #get sortable by properties from the SortableForeignKey field - supported in 1.3+ + sortable_by_class_display_name = sortable_by_fk.rel.to._meta.verbose_name_plural + sortable_by_class = sortable_by_fk.rel.to + sortable_by_expression = sortable_by_fk.name.lower() + sortable_by_class_is_sortable = sortable_by_class.is_sortable() + + else: + #model is not sortable by another model + sortable_by_class = sortable_by_expression = sortable_by_class_display_name =\ + sortable_by_class_is_sortable = None + + if sortable_by_property or sortable_by_fk: # Order the objects by the property they are sortable by, then by the order, otherwise the regroup # template tag will not show the objects correctly as # shown in https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#regroup objects = objects.order_by(sortable_by_expression, 'order') - else: - sortable_by_class = sortable_by_expression = sortable_by_class_display_name =\ - sortable_by_class_is_sortable = None - try: verbose_name_plural = opts.verbose_name_plural.__unicode__() except AttributeError: diff --git a/adminsortable/fields.py b/adminsortable/fields.py new file mode 100644 index 0000000..b2b3578 --- /dev/null +++ b/adminsortable/fields.py @@ -0,0 +1,9 @@ +from django.db.models.fields.related import ForeignKey + + +class SortableForeignKey(ForeignKey): + """ + Field simply acts as a flag to determine the class to sort by. + This field replaces previous functionality where `sortable_by` was definied as a model property + that specified another model class. + """ diff --git a/adminsortable/locale/en/LC_MESSAGES/django.po b/adminsortable/locale/en/LC_MESSAGES/django.po old mode 100755 new mode 100644 diff --git a/adminsortable/locale/nl/LC_MESSAGES/django.mo b/adminsortable/locale/nl/LC_MESSAGES/django.mo old mode 100755 new mode 100644 diff --git a/adminsortable/locale/nl/LC_MESSAGES/django.po b/adminsortable/locale/nl/LC_MESSAGES/django.po old mode 100755 new mode 100644 diff --git a/adminsortable/models.py b/adminsortable/models.py old mode 100755 new mode 100644 index af299de..8a94b3d --- a/adminsortable/models.py +++ b/adminsortable/models.py @@ -1,6 +1,16 @@ from django.contrib.contenttypes.models import ContentType from django.db import models +from adminsortable.fields import SortableForeignKey + + +class MultipleSortableForeignKeyException(Exception): + def __init__(self, value): + self.value = value + + def __str__(self): + return repr(self.value) + class Sortable(models.Model): """ @@ -18,7 +28,10 @@ class Sortable(models.Model): Override `sortable_by` method to make your model be sortable by a foreign key field. Set `sortable_by` to the class specified in the foreign key relationship. """ + order = models.PositiveIntegerField(editable=False, default=1, db_index=True) + + #legacy support sortable_by = None class Meta: @@ -37,6 +50,17 @@ class Sortable(models.Model): def model_type_id(cls): return ContentType.objects.get_for_model(cls).id + def __init__(self, *args, **kwargs): + super(Sortable, self).__init__(*args, **kwargs) + + #Validate that model only contains at most one SortableForeignKey + sortable_foreign_keys = [] + for field in self._meta.fields: + if isinstance(field, SortableForeignKey): + sortable_foreign_keys.append(field) + if len(sortable_foreign_keys) > 1: + raise MultipleSortableForeignKeyException(u'%s may only have one SortableForeignKey' % self) + def save(self, *args, **kwargs): if not self.id: try: diff --git a/adminsortable/static/adminsortable/css/admin.sortable.css b/adminsortable/static/adminsortable/css/admin.sortable.css old mode 100755 new mode 100644 diff --git a/adminsortable/static/adminsortable/css/admin.sortable.tabular.inline.css b/adminsortable/static/adminsortable/css/admin.sortable.tabular.inline.css old mode 100755 new mode 100644 diff --git a/adminsortable/static/adminsortable/js/admin.sortable.js b/adminsortable/static/adminsortable/js/admin.sortable.js old mode 100755 new mode 100644 diff --git a/adminsortable/static/adminsortable/js/admin.sortable.stacked.inlines.js b/adminsortable/static/adminsortable/js/admin.sortable.stacked.inlines.js old mode 100755 new mode 100644 diff --git a/adminsortable/static/adminsortable/js/admin.sortable.tabular.inlines.js b/adminsortable/static/adminsortable/js/admin.sortable.tabular.inlines.js old mode 100755 new mode 100644 diff --git a/adminsortable/static/adminsortable/js/jquery.effects.core.js b/adminsortable/static/adminsortable/js/jquery.effects.core.js old mode 100755 new mode 100644 diff --git a/adminsortable/static/adminsortable/js/jquery.effects.highlight.js b/adminsortable/static/adminsortable/js/jquery.effects.highlight.js old mode 100755 new mode 100644 diff --git a/adminsortable/static/adminsortable/js/jquery.ui.core.js b/adminsortable/static/adminsortable/js/jquery.ui.core.js old mode 100755 new mode 100644 diff --git a/adminsortable/static/adminsortable/js/jquery.ui.draggable.js b/adminsortable/static/adminsortable/js/jquery.ui.draggable.js old mode 100755 new mode 100644 diff --git a/adminsortable/static/adminsortable/js/jquery.ui.droppable.js b/adminsortable/static/adminsortable/js/jquery.ui.droppable.js old mode 100755 new mode 100644 diff --git a/adminsortable/static/adminsortable/js/jquery.ui.mouse.js b/adminsortable/static/adminsortable/js/jquery.ui.mouse.js old mode 100755 new mode 100644 diff --git a/adminsortable/static/adminsortable/js/jquery.ui.sortable.js b/adminsortable/static/adminsortable/js/jquery.ui.sortable.js old mode 100755 new mode 100644 diff --git a/adminsortable/static/adminsortable/js/jquery.ui.widget.js b/adminsortable/static/adminsortable/js/jquery.ui.widget.js old mode 100755 new mode 100644 diff --git a/adminsortable/templates/adminsortable/change_form.html b/adminsortable/templates/adminsortable/change_form.html old mode 100755 new mode 100644 diff --git a/adminsortable/templates/adminsortable/change_list.html b/adminsortable/templates/adminsortable/change_list.html old mode 100755 new mode 100644 diff --git a/adminsortable/templates/adminsortable/change_list_with_sort_link.html b/adminsortable/templates/adminsortable/change_list_with_sort_link.html old mode 100755 new mode 100644 diff --git a/adminsortable/templates/adminsortable/edit_inline/stacked.html b/adminsortable/templates/adminsortable/edit_inline/stacked.html old mode 100755 new mode 100644 diff --git a/adminsortable/templates/adminsortable/edit_inline/tabular.html b/adminsortable/templates/adminsortable/edit_inline/tabular.html old mode 100755 new mode 100644 diff --git a/adminsortable/templates/adminsortable/shared/javascript_includes.html b/adminsortable/templates/adminsortable/shared/javascript_includes.html old mode 100755 new mode 100644 diff --git a/adminsortable/templates/adminsortable/shared/list_items.html b/adminsortable/templates/adminsortable/shared/list_items.html old mode 100755 new mode 100644 diff --git a/adminsortable/templates/adminsortable/shared/nested_objects.html b/adminsortable/templates/adminsortable/shared/nested_objects.html old mode 100755 new mode 100644 diff --git a/adminsortable/templates/adminsortable/shared/object_rep.html b/adminsortable/templates/adminsortable/shared/object_rep.html old mode 100755 new mode 100644 diff --git a/adminsortable/templates/adminsortable/shared/objects.html b/adminsortable/templates/adminsortable/shared/objects.html old mode 100755 new mode 100644 diff --git a/adminsortable/templatetags/__init__.py b/adminsortable/templatetags/__init__.py old mode 100755 new mode 100644 diff --git a/adminsortable/templatetags/adminsortable_tags.py b/adminsortable/templatetags/adminsortable_tags.py old mode 100755 new mode 100644 diff --git a/adminsortable/templatetags/django_template_additions.py b/adminsortable/templatetags/django_template_additions.py old mode 100755 new mode 100644 diff --git a/sample_project/README b/sample_project/README old mode 100755 new mode 100644 diff --git a/sample_project/__init__.py b/sample_project/__init__.py old mode 100755 new mode 100644 diff --git a/sample_project/adminsortable.sqlite b/sample_project/adminsortable.sqlite old mode 100755 new mode 100644 index 7df8bd7716b5bfd11ade2e5e2b53ee69a2933774..87a2b3a68ee1b1febd42e71a5cf6236079ed0b62 GIT binary patch delta 1798 zcmb7EU2GIp6rOv}w6kot?NZuqyY22yx4Wea?RIu{XMYe#7N`M%(v%W`L~%MZTR_v+ zQi;SUoz@2vBLPlgG*Pe!tx;a=MiLN1TV5m*;gw(`GzJYKC>UcTpm%oLq@)kTdAON# zzI*<@bI%$49R@#x!|pP!pL_E2A8C@0v=`PEFtq^F7T5w0;V<|D?!eD51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+QF(MIn;*M8`hih(c47STrTpyB6=fF22h0chY+?4+Xuj5H zn7)2Ft0uNV|3Ou+-Wi#H;t8&*4u5WuL^!GtcW=ebMmidzN-mm<7_qFJizSp)BBvyx z@V4t{BA19{Vu|d29t{dKyuwpmakGIoJRVijN=nUSqnTV(OGk3KR6HF4Z*{4(Zloi| zzHWFmAAIlFyAsuZToCYQ@$>NIeq01x1RfOvy~Iwx10~FZJX-kyo|Sao$ZUjriRr$B zP8G`z`f$1=G3W0%k$E*@d4r*0UUsAZ1<;A>jwCfSy`jI zu5;<_uw(u24KM?CKQ00;0&iOc?DfAY_P_4>|J%0T-G;dc5CrV?KU4qd?|(5Vh)H}F zmzs#Xkhuu#j6gAWj=2K~SeAUuR+HGLv8#BcHJ@$Hxf{nYZ>istAC+P2Qa>{|J!qNz zF|g*G2Bs`&u+sFejMg^(vk@<`E+zWkDqIl2_t!7rc^tt={IdAG_~T+X`Z^jB{z!OH zScdFsAEmWHNFvnQg_=zVrb?9fBUK}VvL24AF<44N{>Vk{6-|mDrKMI8ZBSRkQH`v= zl@!5Bb7c{_Zl&vkN<6G;m0UKP{8TV_mso@4DODrybWr2qEHxZaU=2@3jmouBFAR#9 z%x2;Fh}dCDL25mr1jABAqFOCc3x8N z2k)#fVXdrfOA1nOjUw^Y8Q}WVI@K5>K60Pr%?a@2sZxVzx#0!c&8#z+-#;BpIST%_hLnj%Z8pZ f$VPM|rKS}_Q*&A_B`f=Sazb2?9B^V diff --git a/sample_project/app/__init__.py b/sample_project/app/__init__.py old mode 100755 new mode 100644 diff --git a/sample_project/app/admin.py b/sample_project/app/admin.py old mode 100755 new mode 100644 index f365aab..a1eb445 --- a/sample_project/app/admin.py +++ b/sample_project/app/admin.py @@ -1,7 +1,7 @@ from django.contrib import admin from adminsortable.admin import SortableAdmin, SortableTabularInline, SortableStackedInline -from app.models import Category, Project, Credit, Note, Sample +from app.models import Category, Project, Credit, Note admin.site.register(Category, SortableAdmin) @@ -20,4 +20,3 @@ class ProjectAdmin(SortableAdmin): list_display = ['__unicode__', 'category'] admin.site.register(Project, ProjectAdmin) -admin.site.register(Sample, SortableAdmin) diff --git a/sample_project/app/fixtures/initial_data.json b/sample_project/app/fixtures/initial_data.json new file mode 100644 index 0000000..03bb2e0 --- /dev/null +++ b/sample_project/app/fixtures/initial_data.json @@ -0,0 +1,56 @@ +[ + { + "pk": 1, + "model": "app.category", + "fields": { + "order": 1, + "title": "Test 1" + } + }, + { + "pk": 2, + "model": "app.category", + "fields": { + "order": 2, + "title": "Test 2" + } + }, + { + "pk": 3, + "model": "app.category", + "fields": { + "order": 3, + "title": "Test 3" + } + }, + { + "pk": 1, + "model": "app.project", + "fields": { + "category": 1, + "description": "Test", + "order": 1, + "title": "Test Project 1" + } + }, + { + "pk": 2, + "model": "app.project", + "fields": { + "category": 1, + "description": "Test", + "order": 2, + "title": "Test Project 2" + } + }, + { + "pk": 3, + "model": "app.project", + "fields": { + "category": 2, + "description": "Test", + "order": 3, + "title": "Test Project 3" + } + } +] diff --git a/sample_project/app/fixtures/test_data.json b/sample_project/app/fixtures/test_data.json old mode 100755 new mode 100644 diff --git a/sample_project/app/migrations/0001_initial.py b/sample_project/app/migrations/0001_initial.py deleted file mode 100755 index 099672b..0000000 --- a/sample_project/app/migrations/0001_initial.py +++ /dev/null @@ -1,77 +0,0 @@ -# encoding: utf-8 -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - -class Migration(SchemaMigration): - - def forwards(self, orm): - - # Adding model 'Category' - db.create_table('app_category', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('order', self.gf('django.db.models.fields.PositiveIntegerField')(default=1, db_index=True)), - ('title', self.gf('django.db.models.fields.CharField')(max_length=50)), - )) - db.send_create_signal('app', ['Category']) - - # Adding model 'Project' - db.create_table('app_project', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('order', self.gf('django.db.models.fields.PositiveIntegerField')(default=1, db_index=True)), - ('title', self.gf('django.db.models.fields.CharField')(max_length=50)), - ('category', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['app.Category'])), - ('description', self.gf('django.db.models.fields.TextField')()), - )) - db.send_create_signal('app', ['Project']) - - # Adding model 'Credit' - db.create_table('app_credit', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('order', self.gf('django.db.models.fields.PositiveIntegerField')(default=1, db_index=True)), - ('project', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['app.Project'])), - ('first_name', self.gf('django.db.models.fields.CharField')(max_length=30)), - ('last_name', self.gf('django.db.models.fields.CharField')(max_length=30)), - )) - db.send_create_signal('app', ['Credit']) - - - def backwards(self, orm): - - # Deleting model 'Category' - db.delete_table('app_category') - - # Deleting model 'Project' - db.delete_table('app_project') - - # Deleting model 'Credit' - db.delete_table('app_credit') - - - models = { - 'app.category': { - 'Meta': {'ordering': "['order', 'id']", 'object_name': 'Category'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - 'app.credit': { - 'Meta': {'ordering': "['order', 'id']", 'object_name': 'Credit'}, - 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}), - 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}), - 'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['app.Project']"}) - }, - 'app.project': { - 'Meta': {'ordering': "['order', 'id']", 'object_name': 'Project'}, - 'category': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['app.Category']"}), - 'description': ('django.db.models.fields.TextField', [], {}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - } - } - - complete_apps = ['app'] diff --git a/sample_project/app/migrations/0002_add_note.py b/sample_project/app/migrations/0002_add_note.py deleted file mode 100755 index 8952798..0000000 --- a/sample_project/app/migrations/0002_add_note.py +++ /dev/null @@ -1,59 +0,0 @@ -# encoding: utf-8 -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - -class Migration(SchemaMigration): - - def forwards(self, orm): - - # Adding model 'Note' - db.create_table('app_note', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('order', self.gf('django.db.models.fields.PositiveIntegerField')(default=1, db_index=True)), - ('project', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['app.Project'])), - ('text', self.gf('django.db.models.fields.CharField')(max_length=100)), - )) - db.send_create_signal('app', ['Note']) - - - def backwards(self, orm): - - # Deleting model 'Note' - db.delete_table('app_note') - - - models = { - 'app.category': { - 'Meta': {'ordering': "['order', 'id']", 'object_name': 'Category'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - 'app.credit': { - 'Meta': {'ordering': "['order', 'id']", 'object_name': 'Credit'}, - 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}), - 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}), - 'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['app.Project']"}) - }, - 'app.note': { - 'Meta': {'ordering': "['order', 'id']", 'object_name': 'Note'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}), - 'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['app.Project']"}), - 'text': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - 'app.project': { - 'Meta': {'ordering': "['order', 'id']", 'object_name': 'Project'}, - 'category': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['app.Category']"}), - 'description': ('django.db.models.fields.TextField', [], {}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - } - } - - complete_apps = ['app'] diff --git a/sample_project/app/migrations/0003_add_sample.py b/sample_project/app/migrations/0003_add_sample.py deleted file mode 100755 index 474c29e..0000000 --- a/sample_project/app/migrations/0003_add_sample.py +++ /dev/null @@ -1,68 +0,0 @@ -# encoding: utf-8 -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - -class Migration(SchemaMigration): - - def forwards(self, orm): - - # Adding model 'Sample' - db.create_table('app_sample', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('order', self.gf('django.db.models.fields.PositiveIntegerField')(default=1, db_index=True)), - ('title', self.gf('django.db.models.fields.CharField')(max_length=50)), - ('category', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['app.Category'])), - ('description', self.gf('django.db.models.fields.TextField')()), - )) - db.send_create_signal('app', ['Sample']) - - - def backwards(self, orm): - - # Deleting model 'Sample' - db.delete_table('app_sample') - - - models = { - 'app.category': { - 'Meta': {'ordering': "['order']", 'object_name': 'Category'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - 'app.credit': { - 'Meta': {'ordering': "['order']", 'object_name': 'Credit'}, - 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}), - 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}), - 'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['app.Project']"}) - }, - 'app.note': { - 'Meta': {'ordering': "['order']", 'object_name': 'Note'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}), - 'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['app.Project']"}), - 'text': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - 'app.project': { - 'Meta': {'ordering': "['order']", 'object_name': 'Project'}, - 'category': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['app.Category']"}), - 'description': ('django.db.models.fields.TextField', [], {}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - 'app.sample': { - 'Meta': {'ordering': "['order']", 'object_name': 'Sample'}, - 'category': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['app.Category']"}), - 'description': ('django.db.models.fields.TextField', [], {}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - } - } - - complete_apps = ['app'] diff --git a/sample_project/app/migrations/__init__.py b/sample_project/app/migrations/__init__.py deleted file mode 100755 index e69de29..0000000 diff --git a/sample_project/app/models.py b/sample_project/app/models.py old mode 100755 new mode 100644 index 9b58536..489f257 --- a/sample_project/app/models.py +++ b/sample_project/app/models.py @@ -1,5 +1,6 @@ from django.db import models +from adminsortable.fields import SortableForeignKey from adminsortable.models import Sortable @@ -25,34 +26,16 @@ class Category(SimpleModel, Sortable): #a model that is sortable relative to a foreign key that is also sortable +#uses SortableForeignKey field. Works with versions 1.3+ class Project(SimpleModel, Sortable): class Meta(Sortable.Meta): pass - #deprecated: shown for backward compatibility only. Reference class "Sample" for proper - # designation of `sortable_by` as a property - @classmethod - def sortable_by(cls): - return Category, 'category' - - category = models.ForeignKey(Category) + category = SortableForeignKey(Category) description = models.TextField() -#a model that is sortable relative to a foreign key that is also sortable -class Sample(SimpleModel, Sortable): - class Meta(Sortable.Meta): - ordering = Sortable.Meta.ordering + ['category'] - - category = models.ForeignKey(Category) - description = models.TextField() - - #field to define which foreign key the model is sortable by. - #works with versions > 1.1.1 - sortable_by = Category - - -#registered as a tabular inline on project +#registered as a tabular inline on `Project` class Credit(Sortable): class Meta(Sortable.Meta): pass @@ -65,7 +48,7 @@ class Credit(Sortable): return '%s %s' % (self.first_name, self.last_name) -#registered as a stacked inline on project +#registered as a stacked inline on `Project` class Note(Sortable): class Meta(Sortable.Meta): pass diff --git a/sample_project/app/tests.py b/sample_project/app/tests.py old mode 100755 new mode 100644 index a086099..c209125 --- a/sample_project/app/tests.py +++ b/sample_project/app/tests.py @@ -7,8 +7,14 @@ from django.db import models from django.test import TestCase from django.test.client import Client, RequestFactory -from models import Sortable -from app.models import Category +from adminsortable.fields import SortableForeignKey +from adminsortable.models import Sortable, MultipleSortableForeignKeyException +from app.models import Category, Credit, Note + + +class BadSortableModel(models.Model): + note = SortableForeignKey(Note) + credit = SortableForeignKey(Credit) class TestSortableModel(Sortable): @@ -19,7 +25,6 @@ class TestSortableModel(Sortable): class SortableTestCase(TestCase): - def setUp(self): self.client = Client() self.factory = RequestFactory() diff --git a/sample_project/appmedia/BeautifulSoup.py b/sample_project/appmedia/BeautifulSoup.py old mode 100755 new mode 100644 diff --git a/sample_project/appmedia/__init__.py b/sample_project/appmedia/__init__.py old mode 100755 new mode 100644 diff --git a/sample_project/appmedia/api.py b/sample_project/appmedia/api.py old mode 100755 new mode 100644 diff --git a/sample_project/appmedia/management/__init__.py b/sample_project/appmedia/management/__init__.py old mode 100755 new mode 100644 diff --git a/sample_project/appmedia/management/commands/__init__.py b/sample_project/appmedia/management/commands/__init__.py old mode 100755 new mode 100644 diff --git a/sample_project/appmedia/management/commands/buildmedia.py b/sample_project/appmedia/management/commands/buildmedia.py old mode 100755 new mode 100644 diff --git a/sample_project/appmedia/management/commands/symlinkmedia.py b/sample_project/appmedia/management/commands/symlinkmedia.py old mode 100755 new mode 100644 diff --git a/sample_project/appmedia/middleware.py b/sample_project/appmedia/middleware.py old mode 100755 new mode 100644 diff --git a/sample_project/appmedia/models.py b/sample_project/appmedia/models.py old mode 100755 new mode 100644 diff --git a/sample_project/appmedia/urls.py b/sample_project/appmedia/urls.py old mode 100755 new mode 100644 diff --git a/sample_project/appmedia/views.py b/sample_project/appmedia/views.py old mode 100755 new mode 100644 diff --git a/sample_project/manage.py b/sample_project/manage.py old mode 100755 new mode 100644 diff --git a/sample_project/settings.py b/sample_project/settings.py old mode 100755 new mode 100644 diff --git a/sample_project/static/adminsortable/css/admin.sortable.css b/sample_project/static/adminsortable/css/admin.sortable.css old mode 100755 new mode 100644 diff --git a/sample_project/static/adminsortable/css/admin.sortable.tabular.inline.css b/sample_project/static/adminsortable/css/admin.sortable.tabular.inline.css old mode 100755 new mode 100644 diff --git a/sample_project/static/adminsortable/js/admin.sortable.js b/sample_project/static/adminsortable/js/admin.sortable.js old mode 100755 new mode 100644 diff --git a/sample_project/static/adminsortable/js/admin.sortable.stacked.inlines.js b/sample_project/static/adminsortable/js/admin.sortable.stacked.inlines.js old mode 100755 new mode 100644 diff --git a/sample_project/static/adminsortable/js/admin.sortable.tabular.inlines.js b/sample_project/static/adminsortable/js/admin.sortable.tabular.inlines.js old mode 100755 new mode 100644 diff --git a/sample_project/static/adminsortable/js/jquery.effects.core.js b/sample_project/static/adminsortable/js/jquery.effects.core.js old mode 100755 new mode 100644 diff --git a/sample_project/static/adminsortable/js/jquery.effects.highlight.js b/sample_project/static/adminsortable/js/jquery.effects.highlight.js old mode 100755 new mode 100644 diff --git a/sample_project/static/adminsortable/js/jquery.ui.core.js b/sample_project/static/adminsortable/js/jquery.ui.core.js old mode 100755 new mode 100644 diff --git a/sample_project/static/adminsortable/js/jquery.ui.draggable.js b/sample_project/static/adminsortable/js/jquery.ui.draggable.js old mode 100755 new mode 100644 diff --git a/sample_project/static/adminsortable/js/jquery.ui.droppable.js b/sample_project/static/adminsortable/js/jquery.ui.droppable.js old mode 100755 new mode 100644 diff --git a/sample_project/static/adminsortable/js/jquery.ui.mouse.js b/sample_project/static/adminsortable/js/jquery.ui.mouse.js old mode 100755 new mode 100644 diff --git a/sample_project/static/adminsortable/js/jquery.ui.sortable.js b/sample_project/static/adminsortable/js/jquery.ui.sortable.js old mode 100755 new mode 100644 diff --git a/sample_project/static/adminsortable/js/jquery.ui.widget.js b/sample_project/static/adminsortable/js/jquery.ui.widget.js old mode 100755 new mode 100644 diff --git a/sample_project/templates/index.html b/sample_project/templates/index.html old mode 100755 new mode 100644 diff --git a/sample_project/urls.py b/sample_project/urls.py old mode 100755 new mode 100644 diff --git a/setup.py b/setup.py old mode 100755 new mode 100644