Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 2a0c24b56e38bb174d7fe8d7d10a0529d783d564 @saxix committed with Sep 2, 2012
Showing with 2,933 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +17 −0 .travis.yml
  3. +1 −0 AUTHORS
  4. +20 −0 LICENSE
  5. +25 −0 README.rst
  6. +52 −0 adminactions/__init__.py
  7. +4 −0 adminactions/actions.py
  8. +47 −0 adminactions/any.py
  9. +232 −0 adminactions/csv2/__init__.py
  10. +300 −0 adminactions/csv2/utils.py
  11. +123 −0 adminactions/export.py
  12. 0 adminactions/forms.py
  13. +91 −0 adminactions/graph.py
  14. +123 −0 adminactions/mass_update.py
  15. +18 −0 adminactions/models.py
  16. 0 adminactions/static/adminactions/js/export.js
  17. +33 −0 adminactions/static/adminactions/js/massupdate.js
  18. +87 −0 adminactions/templates/adminactions/any_model.html
  19. +398 −0 adminactions/templates/adminactions/export_csv.html
  20. +90 −0 adminactions/templates/adminactions/mass_update.html
  21. +3 −0 adminactions/templatetags/__init__.py
  22. +31 −0 adminactions/templatetags/massupdate.py
  23. +23 −0 adminactions/tools.py
  24. +231 −0 docs/conf.py
  25. +88 −0 docs/source/_ext/applyxrefs.py
  26. +248 −0 docs/source/_ext/djangodocs.py
  27. +41 −0 docs/source/_ext/ext.py
  28. +171 −0 docs/source/_ext/literals_to_xrefs.py
  29. BIN docs/source/_static/cell_filter.png
  30. BIN docs/source/_static/cell_filter_operators.png
  31. BIN docs/source/_static/columns.png
  32. BIN docs/source/_static/export_csv.png
  33. BIN docs/source/_static/info_1.png
  34. BIN docs/source/_static/info_2.png
  35. BIN docs/source/_static/info_5.png
  36. BIN docs/source/_static/mass_update.png
  37. +231 −0 docs/source/conf.py
  38. +13 −0 docs/source/globals.rst
  39. +43 −0 docs/source/index.rst
  40. +46 −0 docs/source/install.rst
  41. +20 −0 docs/source/screenshots.rst
  42. 0 requirements.txt
  43. +79 −0 setup.py
@@ -0,0 +1,4 @@
+*.log
+*.pot
+*.pyc
+local_settings.py
@@ -0,0 +1,17 @@
+language: python
+python:
+ - "2.6"
+ - "2.7"
+script: nosetests
+env:
+ - DJANGO_VERSION=1.3.1
+ - DJANGO_VERSION=1.4
+install:
+# - pip install pep8 --use-mirrors
+ - pip install -q Django==$DJANGO_VERSION
+ - python setup.py -q install
+ - pip install -r requirements.txt --use-mirrors
+
+script: django-admin.py test geo --settings=geo.test_settings
+before_script:
+# - "pep8 --exclude=migrations --ignore=E501,E225 src"
@@ -0,0 +1 @@
+Stefano Apostolico <s.apostolico@gmail.com>
20 LICENSE
@@ -0,0 +1,20 @@
+* Copyright (c) 2010, Stefano Apostolico (s.apostolico@gmail.com)
+* Dual licensed under the MIT or GPL Version 2 licenses.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
@@ -0,0 +1,25 @@
+================
+django-actions
+================
+
+.. image:: https://secure.travis-ci.org/saxix/django-actions.png?branch=master
+ :target: http://travis-ci.org/saxix/django-actions/
+
+Originally included in django-iadmin, django-actions are a collections of
+usefuls actions to use with django.contrib.admin.ModelAdmin and/or django.contrib.admin.AdminSite
+
+Actions
+================
+
+* Export as CSV
+* Export as fixture
+* Mass update records
+* Graph queryset
+
+
+Project links
+-------------
+
+* Project home page: https://github.com/saxix/django-actions
+* Documentation: http://pypi.python.org/pypi/django-actions/
+* Download: http://pypi.python.org/pypi/django-actions/
@@ -0,0 +1,52 @@
+NAME = 'django-adminactions'
+VERSION = __version__ = (0, 0, 1, 'alpha', 0)
+__author__ = 'sax'
+
+import subprocess
+import datetime
+import os
+
+
+def get_version(version=None):
+ """Derives a PEP386-compliant version number from VERSION."""
+ if version is None:
+ version = VERSION
+ assert len(version) == 5
+ assert version[3] in ('alpha', 'beta', 'rc', 'final')
+
+ parts = 2 if version[2] == 0 else 3
+ main = '.'.join(str(x) for x in version[:parts])
+
+ sub = ''
+ if version[3] == 'alpha' and version[4] == 0:
+ git_changeset = get_git_changeset()
+ if git_changeset:
+ sub = '.dev%s' % git_changeset
+
+ elif version[3] != 'final':
+ mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'}
+ sub = mapping[version[3]] + str(version[4])
+
+ return main + sub
+
+
+def get_git_changeset():
+ """Returns a numeric identifier of the latest git changeset.
+
+The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format.
+This value isn't guaranteed to be unique, but collisions are very unlikely,
+so it's sufficient for generating the development version numbers.
+"""
+ repo_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+ git_log = subprocess.Popen('git log --pretty=format:%ct --quiet -1 HEAD',
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ shell=True, cwd=repo_dir, universal_newlines=True)
+ timestamp = git_log.communicate()[0]
+ try:
+ timestamp = datetime.datetime.utcfromtimestamp(int(timestamp))
+ except ValueError:
+ return None
+ return timestamp.strftime('%Y%m%d%H%M%S')
+
+
+
@@ -0,0 +1,4 @@
+from .mass_update import mass_update
+from .export import export_as_json, export_as_csv
+from .graph import graph_queryset
+#from .any import *
@@ -0,0 +1,47 @@
+import json
+from django import forms
+from django.contrib.admin import helpers
+from django.forms.models import modelform_factory
+from django.shortcuts import render_to_response
+from django.template.context import RequestContext
+from django.utils.encoding import force_unicode
+from django.utils.safestring import mark_safe
+from adminactions.models import GenericActionForm
+
+
+class AnyForm(GenericActionForm):
+ _number = forms.BooleanField(label='Number',
+ help_text="Number of records to create")
+
+
+def create_random_records(modeladmin, request, queryset):
+ MForm = modelform_factory(modeladmin.model, form=AnyForm)
+ initial = {}
+ if 'apply' in request.POST:
+ pass
+
+ form = MForm(initial=initial)
+ adminForm = helpers.AdminForm(form, modeladmin.get_fieldsets(request), {}, [], model_admin=modeladmin)
+ media = modeladmin.media + adminForm.media
+
+ tpl = 'adminactions/any_model.html'
+ ctx = {'adminform': adminForm,
+ 'form': form,
+ 'title': u"Create random %s records" % force_unicode(modeladmin.opts.verbose_name_plural),
+# 'grouped': grouped,
+# 'fieldvalues': json.dumps(grouped, default=dthandler),
+ 'change': True,
+ 'is_popup': False,
+ 'save_as': False,
+ 'has_delete_permission': False,
+ 'has_add_permission': False,
+ 'has_change_permission': True,
+ 'opts': modeladmin.model._meta,
+ 'app_label': modeladmin.model._meta.app_label,
+ 'action': 'create_random_records',
+ 'media': mark_safe(media),
+ 'selection': queryset}
+
+ return render_to_response(tpl, RequestContext(request, ctx))
+
+create_random_records.short_description = "Create random records"
Oops, something went wrong.

0 comments on commit 2a0c24b

Please sign in to comment.