Permalink
Browse files

Merge pull request #2 from django-extensions/master

Latest
  • Loading branch information...
2 parents 93fc3a5 + 7f2d542 commit bae0c10cfc36771bc80720323a44a3b8dadcb821 @pombredanne committed Nov 17, 2012
Showing with 817 additions and 543 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 MANIFEST.in
  3. +1 −1 README.rst
  4. +1 −1 django_extensions/__init__.py
  5. +18 −13 django_extensions/admin/widgets.py
  6. +11 −9 django_extensions/db/fields/__init__.py
  7. +4 −1 django_extensions/db/fields/json.py
  8. +7 −2 django_extensions/db/models.py
  9. +5 −2 django_extensions/management/commands/clean_pyc.py
  10. +76 −64 django_extensions/management/commands/dumpscript.py
  11. +46 −8 django_extensions/management/commands/mail_debug.py
  12. +8 −3 django_extensions/management/commands/notes.py
  13. +50 −8 django_extensions/management/commands/runserver_plus.py
  14. +25 −54 django_extensions/management/commands/shell_plus.py
  15. +73 −7 django_extensions/management/commands/sync_media_s3.py
  16. +25 −7 django_extensions/management/commands/validate_templates.py
  17. +6 −0 django_extensions/management/notebook_extension.py
  18. +56 −0 django_extensions/management/shells.py
  19. +30 −0 django_extensions/management/utils.py
  20. 0 django_extensions/{media → static}/django_extensions/css/jquery.autocomplete.css
  21. BIN django_extensions/{media → static}/django_extensions/img/indicator.gif
  22. +24 −21 django_extensions/{media → static}/django_extensions/js/jquery.ajaxQueue.js
  23. +65 −62 django_extensions/{media → static}/django_extensions/js/jquery.autocomplete.js
  24. +2 −2 django_extensions/{media → static}/django_extensions/js/jquery.bgiframe.min.js
  25. 0 django_extensions/{media → static}/django_extensions/js/jquery.js
  26. +3 −3 django_extensions/templates/django_extensions/widgets/foreignkey_searchinput.html
  27. +9 −3 django_extensions/templatetags/truncate_letters.py
  28. +1 −1 django_extensions/tests/__init__.py
  29. +89 −0 django_extensions/tests/fields.py
  30. +27 −0 django_extensions/tests/test_dumpscript.py
  31. +0 −57 django_extensions/tests/test_print_settings.py
  32. +82 −0 django_extensions/utils/validatingtemplatetags.py
  33. +2 −2 docs/conf.py
  34. +28 −0 docs/dumpscript.rst
  35. +9 −5 docs/graph_models.rst
  36. +2 −2 docs/installation_instructions.rst
  37. +29 −0 docs/shell_plus.rst
  38. 0 example_project/example_project/__init__.py
  39. +0 −149 example_project/example_project/settings.py
  40. +0 −17 example_project/example_project/urls.py
  41. +0 −28 example_project/example_project/wsgi.py
  42. +0 −10 example_project/manage.py
  43. +1 −0 run_tests.py
View
@@ -8,3 +8,4 @@ docs/_build
docs/_static
*.egg-info
.tox
+*.bak
View
@@ -1,4 +1,4 @@
recursive-include django_extensions/conf *.tmpl
recursive-include django_extensions/templates *.html
-recursive-include django_extensions/media *
+recursive-include django_extensions/static *
recursive-include docs *
View
@@ -12,7 +12,7 @@ The easiest way to figure out what Django Extensions are all about is to watch t
Getting It
==========
-You can get Django Extentions by using pip or easy_install::
+You can get Django Extensions by using pip or easy_install::
$ pip install django-extensions
or
@@ -1,5 +1,5 @@
-VERSION = (0, 9, 1, 'beta')
+VERSION = (1, 0, 2, 'pre')
# Dynamically calculate the version based on VERSION tuple
if len(VERSION) > 2 and VERSION[2] is not None:
@@ -1,5 +1,7 @@
-from django import forms, VERSION
+import django
+from django import forms
from django.conf import settings
+from django.contrib.admin.sites import site
from django.utils.safestring import mark_safe
from django.utils.text import truncate_words
from django.template.loader import render_to_string
@@ -16,16 +18,16 @@ class ForeignKeySearchInput(ForeignKeyRawIdWidget):
# Set this to the patch of the search view
search_path = '../foreignkey_autocomplete/'
- class Media:
- css = {
- 'all': ('django_extensions/css/jquery.autocomplete.css',)
- }
- js = (
- 'django_extensions/js/jquery.js',
- 'django_extensions/js/jquery.bgiframe.min.js',
- 'django_extensions/js/jquery.ajaxQueue.js',
- 'django_extensions/js/jquery.autocomplete.js',
- )
+ def _media(self):
+ js_files = ['django_extensions/js/jquery.bgiframe.min.js',
+ 'django_extensions/js/jquery.ajaxQueue.js',
+ 'django_extensions/js/jquery.autocomplete.js']
+ if django.get_version() < "1.3":
+ js_files.append('django_extensions/js/jquery.js')
+ return forms.Media(css={'all': ('django_extensions/css/jquery.autocomplete.css',)},
+ js=js_files)
+
+ media = property(_media)
def label_for_value(self, value):
key = self.rel.get_related_field().name
@@ -34,7 +36,10 @@ def label_for_value(self, value):
def __init__(self, rel, search_fields, attrs=None):
self.search_fields = search_fields
- super(ForeignKeySearchInput, self).__init__(rel, attrs)
+ if django.get_version() >= "1.4":
+ super(ForeignKeySearchInput, self).__init__(rel, site, attrs)
+ else:
+ super(ForeignKeySearchInput, self).__init__(rel, attrs)
def render(self, name, value, attrs=None):
if attrs is None:
@@ -73,7 +78,7 @@ def render(self, name, value, attrs=None):
'app_label': app_label,
'label': label,
'name': name,
- 'pre_django_14': (VERSION[:2]<(1,4)),
+ 'pre_django_14': (django.VERSION[:2]<(1,4)),
}
output.append(render_to_string(self.widget_template or (
'django_extensions/widgets/%s/%s/foreignkey_searchinput.html' % (app_label, model_name),
@@ -82,15 +82,11 @@ def create_slug(self, model_instance, add):
slug = self.separator.join(map(slug_for_field, self._populate_from))
next = 2
else:
- # get slug from the current model instance and calculate next
- # step from its number, clean-up
- slug = self._slug_strip(getattr(model_instance, self.attname))
- next = slug.split(self.separator)[-1]
- if next.isdigit() and not self.allow_duplicates:
- slug = self.separator.join(slug.split(self.separator)[:-1])
- next = int(next)
- else:
- next = 2
+ # get slug from the current model instance
+ slug = getattr(model_instance, self.attname)
+ # model_instance is being modified, and overwrite is False,
+ # so instead of doing anything, just return the current slug
+ return slug
# strip slug depending on max_length attribute of the slug field
# and clean-up
@@ -220,6 +216,7 @@ class UUIDField(CharField):
def __init__(self, verbose_name=None, name=None, auto=True, version=1, node=None, clock_seq=None, namespace=None, **kwargs):
kwargs['max_length'] = 36
if auto:
+ self.empty_strings_allowed = False
kwargs['blank'] = True
kwargs.setdefault('editable', False)
self.auto = auto
@@ -269,6 +266,11 @@ def pre_save(self, model_instance, add):
value = unicode(self.create_uuid())
setattr(model_instance, self.attname, value)
return value
+
+ def formfield(self, **kwargs):
+ if self.auto:
+ return None
+ super(UUIDField, self).formfield(**kwargs)
def south_field_triple(self):
"Returns a suitable description of this field for South."
@@ -65,8 +65,11 @@ class JSONField(models.TextField):
__metaclass__ = models.SubfieldBase
def __init__(self, *args, **kwargs):
- if 'default' not in kwargs:
+ default = kwargs.get('default')
+ if not default:
kwargs['default'] = '{}'
+ elif isinstance(default, (list, dict)):
+ kwargs['default'] = dumps(default)
models.TextField.__init__(self, *args, **kwargs)
def to_python(self, value):
@@ -1,12 +1,17 @@
"""
Django Extensions abstract base model classes.
"""
-import datetime
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django_extensions.db.fields import (ModificationDateTimeField,
CreationDateTimeField, AutoSlugField)
+try:
+ from django.utils.timezone import now as datetime_now
+except ImportError:
+ import datetime
+ datetime_now = datetime.datetime.now
+
class TimeStampedModel(models.Model):
""" TimeStampedModel
@@ -71,5 +76,5 @@ class Meta:
def save(self, *args, **kwargs):
if not self.activate_date:
- self.activate_date = datetime.datetime.now()
+ self.activate_date = datetime_now()
super(ActivatorModel, self).save(*args, **kwargs)
@@ -22,14 +22,17 @@ def handle_noargs(self, **options):
if not project_root:
project_root = get_project_root()
exts = options.get("optimize", False) and [".pyc", ".pyo"] or [".pyc"]
- verbose = int(options.get("verbosity", 1)) > 1
+ verbose = int(options.get("verbosity", 1))
+
+ if verbose > 1:
+ print "Project Root: %s" % project_root
for root, dirs, files in os.walk(project_root):
for file in files:
ext = os.path.splitext(file)[1]
if ext in exts:
full_path = _j(root, file)
- if verbose:
+ if verbose > 1:
print full_path
os.remove(full_path)
Oops, something went wrong.

0 comments on commit bae0c10

Please sign in to comment.