From dacd8f7c4c7047b4a28ce8da108a3da1e01a5d3b Mon Sep 17 00:00:00 2001 From: Mauro Bianchi Date: Thu, 12 Nov 2015 23:32:00 +0100 Subject: [PATCH] first huge commit --- .gitignore | 47 ++++ .travis.yml | 20 ++ AUTHORS.rst | 13 + CONTRIBUTING.rst | 112 ++++++++ HISTORY.rst | 9 + LICENSE | 12 + MANIFEST.in | 6 + Makefile | 55 ++++ README.rst | 38 +++ django_rest_admin/__init__.py | 6 + django_rest_admin/apps.py | 56 ++++ django_rest_admin/models.py | 1 + django_rest_admin/register.py | 63 +++++ .../static/css/django_rest_admin.css | 0 django_rest_admin/static/img/.gitignore | 0 .../static/js/django_rest_admin.js | 0 .../templates/django_rest_admin/base.html | 21 ++ django_rest_admin/urls.py | 26 ++ django_rest_admin/views.py | 41 +++ docs/Makefile | 177 ++++++++++++ docs/authors.rst | 1 + docs/conf.py | 254 ++++++++++++++++++ docs/contributing.rst | 1 + docs/history.rst | 1 + docs/index.rst | 19 ++ docs/installation.rst | 12 + docs/make.bat | 242 +++++++++++++++++ docs/readme.rst | 1 + docs/usage.rst | 7 + example_app/.gitignore | 2 + example_app/example/contacts/__init__.py | 0 example_app/example/contacts/admin.py | 3 + .../contacts/migrations/0001_initial.py | 21 ++ .../example/contacts/migrations/__init__.py | 0 example_app/example/contacts/models.py | 5 + example_app/example/contacts/rest_admin.py | 4 + example_app/example/contacts/tests.py | 3 + example_app/example/contacts/views.py | 3 + example_app/example/db.sqlite3 | Bin 0 -> 38912 bytes example_app/example/example/__init__.py | 0 example_app/example/example/settings.py | 107 ++++++++ example_app/example/example/urls.py | 22 ++ example_app/example/example/wsgi.py | 16 ++ example_app/example/manage.py | 10 + requirements-test.txt | 7 + requirements.txt | 3 + runtests.py | 55 ++++ setup.cfg | 2 + setup.py | 59 ++++ tests/__init__.py | 0 tests/test_models.py | 25 ++ tox.ini | 9 + 52 files changed, 1597 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 AUTHORS.rst create mode 100644 CONTRIBUTING.rst create mode 100644 HISTORY.rst create mode 100644 LICENSE create mode 100644 MANIFEST.in create mode 100644 Makefile create mode 100644 README.rst create mode 100644 django_rest_admin/__init__.py create mode 100644 django_rest_admin/apps.py create mode 100644 django_rest_admin/models.py create mode 100644 django_rest_admin/register.py create mode 100644 django_rest_admin/static/css/django_rest_admin.css create mode 100644 django_rest_admin/static/img/.gitignore create mode 100644 django_rest_admin/static/js/django_rest_admin.js create mode 100644 django_rest_admin/templates/django_rest_admin/base.html create mode 100644 django_rest_admin/urls.py create mode 100644 django_rest_admin/views.py create mode 100644 docs/Makefile create mode 100644 docs/authors.rst create mode 100644 docs/conf.py create mode 100644 docs/contributing.rst create mode 100644 docs/history.rst create mode 100644 docs/index.rst create mode 100644 docs/installation.rst create mode 100644 docs/make.bat create mode 100644 docs/readme.rst create mode 100644 docs/usage.rst create mode 100644 example_app/.gitignore create mode 100644 example_app/example/contacts/__init__.py create mode 100644 example_app/example/contacts/admin.py create mode 100644 example_app/example/contacts/migrations/0001_initial.py create mode 100644 example_app/example/contacts/migrations/__init__.py create mode 100644 example_app/example/contacts/models.py create mode 100644 example_app/example/contacts/rest_admin.py create mode 100644 example_app/example/contacts/tests.py create mode 100644 example_app/example/contacts/views.py create mode 100644 example_app/example/db.sqlite3 create mode 100644 example_app/example/example/__init__.py create mode 100644 example_app/example/example/settings.py create mode 100644 example_app/example/example/urls.py create mode 100644 example_app/example/example/wsgi.py create mode 100755 example_app/example/manage.py create mode 100644 requirements-test.txt create mode 100644 requirements.txt create mode 100644 runtests.py create mode 100644 setup.cfg create mode 100755 setup.py create mode 100644 tests/__init__.py create mode 100644 tests/test_models.py create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..294ed55 --- /dev/null +++ b/.gitignore @@ -0,0 +1,47 @@ +*.py[cod] +__pycache__ + +# VENV +venv + +# C extensions +*.so + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg +lib +lib64 + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox +nosetests.xml +htmlcov + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Complexity +output/*.html +output/*/index.html + +# Sphinx +docs/_build diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f1e4fad --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +# Config file for automatic testing at travis-ci.org + +language: python + +python: + - "3.4" + - "3.3" + - "2.7" + +before_install: + - pip install codecov + +# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors +install: pip install -r requirements-test.txt + +# command to run tests using coverage, e.g. python setup.py test +script: coverage run --source django_rest_admin runtests.py + +after_success: + - codecov diff --git a/AUTHORS.rst b/AUTHORS.rst new file mode 100644 index 0000000..70c5c3f --- /dev/null +++ b/AUTHORS.rst @@ -0,0 +1,13 @@ +======= +Credits +======= + +Development Lead +---------------- + +* Mauro Bianchi + +Contributors +------------ + +None yet. Why not be the first? diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..57ddc99 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,112 @@ +============ +Contributing +============ + +Contributions are welcome, and they are greatly appreciated! Every +little bit helps, and credit will always be given. + +You can contribute in many ways: + +Types of Contributions +---------------------- + +Report Bugs +~~~~~~~~~~~ + +Report bugs at https://github.com/bianchimro/django-rest-admin/issues. + +If you are reporting a bug, please include: + +* Your operating system name and version. +* Any details about your local setup that might be helpful in troubleshooting. +* Detailed steps to reproduce the bug. + +Fix Bugs +~~~~~~~~ + +Look through the GitHub issues for bugs. Anything tagged with "bug" +is open to whoever wants to implement it. + +Implement Features +~~~~~~~~~~~~~~~~~~ + +Look through the GitHub issues for features. Anything tagged with "feature" +is open to whoever wants to implement it. + +Write Documentation +~~~~~~~~~~~~~~~~~~~ + +django-rest-admin could always use more documentation, whether as part of the +official django-rest-admin docs, in docstrings, or even on the web in blog posts, +articles, and such. + +Submit Feedback +~~~~~~~~~~~~~~~ + +The best way to send feedback is to file an issue at https://github.com/bianchimro/django-rest-admin/issues. + +If you are proposing a feature: + +* Explain in detail how it would work. +* Keep the scope as narrow as possible, to make it easier to implement. +* Remember that this is a volunteer-driven project, and that contributions + are welcome :) + +Get Started! +------------ + +Ready to contribute? Here's how to set up `django-rest-admin` for local development. + +1. Fork the `django-rest-admin` repo on GitHub. +2. Clone your fork locally:: + + $ git clone git@github.com:your_name_here/django-rest-admin.git + +3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: + + $ mkvirtualenv django-rest-admin + $ cd django-rest-admin/ + $ python setup.py develop + +4. Create a branch for local development:: + + $ git checkout -b name-of-your-bugfix-or-feature + +Now you can make your changes locally. + +5. When you're done making changes, check that your changes pass flake8 and the +tests, including testing other Python versions with tox:: + + $ flake8 django_rest_admin tests + $ python setup.py test + $ tox + +To get flake8 and tox, just pip install them into your virtualenv. + +6. Commit your changes and push your branch to GitHub:: + + $ git add . + $ git commit -m "Your detailed description of your changes." + $ git push origin name-of-your-bugfix-or-feature + +7. Submit a pull request through the GitHub website. + +Pull Request Guidelines +----------------------- + +Before you submit a pull request, check that it meets these guidelines: + +1. The pull request should include tests. +2. If the pull request adds functionality, the docs should be updated. Put + your new functionality into a function with a docstring, and add the + feature to the list in README.rst. +3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check + https://travis-ci.org/bianchimro/django-rest-admin/pull_requests + and make sure that the tests pass for all supported Python versions. + +Tips +---- + +To run a subset of tests:: + + $ python -m unittest tests.test_django_rest_admin diff --git a/HISTORY.rst b/HISTORY.rst new file mode 100644 index 0000000..64de8c1 --- /dev/null +++ b/HISTORY.rst @@ -0,0 +1,9 @@ +.. :changelog: + +History +------- + +0.1.0 (2015-10-02) +++++++++++++++++++ + +* First release on PyPI. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8854b7a --- /dev/null +++ b/LICENSE @@ -0,0 +1,12 @@ +Copyright (c) 2015, Mauro Bianchi +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +* Neither the name of django-rest-admin nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +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 HOLDER 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. \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..c909631 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include AUTHORS.rst +include CONTRIBUTING.rst +include HISTORY.rst +include LICENSE +include README.rst +recursive-include django_rest_admin *.html *.png *.gif *js *.css *jpg *jpeg *svg *py diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e9aafb3 --- /dev/null +++ b/Makefile @@ -0,0 +1,55 @@ +.PHONY: clean-pyc clean-build docs + +help: + @echo "clean-build - remove build artifacts" + @echo "clean-pyc - remove Python file artifacts" + @echo "lint - check style with flake8" + @echo "test - run tests quickly with the default Python" + @echo "test-all - run tests on every Python version with tox" + @echo "coverage - check code coverage quickly with the default Python" + @echo "docs - generate Sphinx HTML documentation, including API docs" + @echo "release - package and upload a release" + @echo "sdist - package" + +clean: clean-build clean-pyc + +clean-build: + rm -fr build/ + rm -fr dist/ + rm -fr *.egg-info + +clean-pyc: + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + +lint: + flake8 django_rest_admin tests + +test: + python runtests.py tests + +test-all: + tox + +coverage: + coverage run --source django_rest_admin runtests.py tests + coverage report -m + coverage html + open htmlcov/index.html + +docs: + rm -f docs/django-rest-admin.rst + rm -f docs/modules.rst + sphinx-apidoc -o docs/ django_rest_admin + $(MAKE) -C docs clean + $(MAKE) -C docs html + open docs/_build/html/index.html + +release: clean + python setup.py sdist upload + python setup.py bdist_wheel upload + +sdist: clean + python setup.py sdist + ls -l dist diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..090c54a --- /dev/null +++ b/README.rst @@ -0,0 +1,38 @@ +============================= +django-rest-admin +============================= + +.. image:: https://badge.fury.io/py/django-rest-admin.png + :target: https://badge.fury.io/py/django-rest-admin + +.. image:: https://travis-ci.org/bianchimro/django-rest-admin.png?branch=master + :target: https://travis-ci.org/bianchimro/django-rest-admin + +En EADRREST endpoints for administering django models. + +Documentation +------------- + +The full documentation is at https://django-rest-admin.readthedocs.org. + +Quickstart +---------- + +Install django-rest-admin:: + + pip install django-rest-admin + +Then use it in a project:: + + import django_rest_admin + +Features +-------- + +* TODO + +Cookiecutter Tools Used in Making This Package +---------------------------------------------- + +* cookiecutter +* cookiecutter-djangopackage diff --git a/django_rest_admin/__init__.py b/django_rest_admin/__init__.py new file mode 100644 index 0000000..ef80b3d --- /dev/null +++ b/django_rest_admin/__init__.py @@ -0,0 +1,6 @@ +__version__ = '0.1.0' +default_app_config = 'django_rest_admin.apps.RestAdminAppConfig' + +from register import rest_admin + + diff --git a/django_rest_admin/apps.py b/django_rest_admin/apps.py new file mode 100644 index 0000000..717e2cb --- /dev/null +++ b/django_rest_admin/apps.py @@ -0,0 +1,56 @@ +from django.apps import AppConfig +from django.conf import settings + +import sys +import imp +import importlib +import os + + +class RestAdminAppConfig(AppConfig): + + name = 'django_rest_admin' + verbose_name = 'Rest Admin' + loaded = False + + def ready(self): + autodiscover() + + +def autodiscover(): + """ + Automatic discovering of rest_admin.py file inside apps. + similar to what Django admin does. + """ + if not RestAdminAppConfig.loaded: + for app in settings.INSTALLED_APPS: + # For each app, we need to look for an rest_admin.py inside that app's + # package. We can't use os.path here -- recall that modules may be + # imported different ways (think zip files) -- so we need to get + # the app's __path__ and look for rest_admin.py on that path. + + # Step 1: find out the app's __path__ Import errors here will (and + # should) bubble up, but a missing __path__ (which is legal, but weird) + # fails silently -- apps that do weird things with __path__ might + # need to roll their own rest_admin registration. + try: + app_path = importlib.import_module(app).__path__ + except AttributeError: + continue + + # Step 2: use imp.find_module to find the app's rest_admin.py. For some + # reason imp.find_module raises ImportError if the app can't be found + # but doesn't actually try to import the module. So skip this app if + # its rest_admin.py doesn't exist + try: + imp.find_module('rest_admin', app_path) + except ImportError: + continue + + # Step 3: import the app's admin file. If this has errors we want them + # to bubble up. + importlib.import_module("%s.rest_admin" % app) + + # autodiscover was successful, reset loading flag. + RestAdminAppConfig.loaded = True + \ No newline at end of file diff --git a/django_rest_admin/models.py b/django_rest_admin/models.py new file mode 100644 index 0000000..40a96af --- /dev/null +++ b/django_rest_admin/models.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/django_rest_admin/register.py b/django_rest_admin/register.py new file mode 100644 index 0000000..5ab315e --- /dev/null +++ b/django_rest_admin/register.py @@ -0,0 +1,63 @@ +from collections import OrderedDict +from django.conf import settings +import warnings +from django.core.urlresolvers import reverse +from rest_framework import viewsets, serializers, permissions + +#import logging +#logger = logging.getLogger(__name__) + + +class RestAdminRegister(object): + """ + Holds registry for rest_admin. + """ + + def __init__(self): + """ + #TODO: this will be lists.. + """ + self.models = OrderedDict() + self.viewsets = OrderedDict() + self.urls = {} + + + def register(self, model, rest_admin_class=None): + """ + rest_admin_class is not used now + it will be used to provide options (like a custom ModelAdmin class in django admin) + """ + self.models[model._meta.object_name.lower()] = (model, rest_admin_class) + + + def register_with_router(self, router): + for v in self.models: + model = self.models[v][0] + + serializer_attrs = { + 'Meta' : type('Meta', (), { 'model' : model }) + } + serializer = type(v+'Serializer', (serializers.ModelSerializer,), serializer_attrs) + + viewset_attrs = { + 'serializer_class' : serializer, + 'queryset' : model.objects.all(), + 'permission_classes' : [ permissions.IsAdminUser, ] + } + viewset = type(v+'Serializer', (viewsets.ModelViewSet,), viewset_attrs) + router.register(r'^%s'%v, viewset) + + return router + + + def deregister(self, app_name, model): + """ + """ + raise NotImplementedError + + +# Intended to be a singleton +rest_admin = RestAdminRegister() + + + diff --git a/django_rest_admin/static/css/django_rest_admin.css b/django_rest_admin/static/css/django_rest_admin.css new file mode 100644 index 0000000..e69de29 diff --git a/django_rest_admin/static/img/.gitignore b/django_rest_admin/static/img/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/django_rest_admin/static/js/django_rest_admin.js b/django_rest_admin/static/js/django_rest_admin.js new file mode 100644 index 0000000..e69de29 diff --git a/django_rest_admin/templates/django_rest_admin/base.html b/django_rest_admin/templates/django_rest_admin/base.html new file mode 100644 index 0000000..09d26f3 --- /dev/null +++ b/django_rest_admin/templates/django_rest_admin/base.html @@ -0,0 +1,21 @@ + +{% comment %} +As the developer of this package, don't place anything here if you can help it +since this allows developers to have interoperability between your template +structure and their own. + +Example: Developer melding the 2SoD pattern to fit inside with another pattern:: + + {% extends "base.html" %} + {% load static %} + + + {% block extra_js %} + + + {% block javascript %} + + {% endblock javascript %} + + {% endblock extra_js %} +{% endcomment %} diff --git a/django_rest_admin/urls.py b/django_rest_admin/urls.py new file mode 100644 index 0000000..34dda84 --- /dev/null +++ b/django_rest_admin/urls.py @@ -0,0 +1,26 @@ +""" +* standard urls + * authentication endpoints + * metadata endpoints +* urls coming from registered models +""" + +from django.conf.urls import patterns, include, url +from .views import RestAdminMetaView +from .register import rest_admin +from rest_framework import routers + + +urlpatterns = patterns('', + url(r'^meta/$', RestAdminMetaView.as_view(), name='rest_admin_meta'), + #url(r'^login/$', ModelsMetaView.as_view(), name='login'), +) + +router = routers.SimpleRouter() + +slizers = {} +vsets = {} + +router = rest_admin.register_with_router(router) + +urlpatterns += router.urls diff --git a/django_rest_admin/views.py b/django_rest_admin/views.py new file mode 100644 index 0000000..9fdb8a8 --- /dev/null +++ b/django_rest_admin/views.py @@ -0,0 +1,41 @@ +from django.shortcuts import render +from rest_framework.views import APIView +from rest_framework.response import Response +from django_rest_admin import rest_admin +import urllib + +def get_field_meta(field): + """ + returns a dictionary with some metadata from field of a model + """ + out = { 'name' : field.name, 'is_relation' : field.is_relation, 'class_name' : field.__class__.__name__} + if field.is_relation: + out['related_model'] = "%s.%s" % (field.related_model._meta.app_label, field.related_model.__name__) + + else: + out['default'] = field.get_default() + + try: + out['null'] = field.null + except: + pass + + return out + + +class RestAdminMetaView(APIView): + + def get(self, request): + out = { } + for v in rest_admin.models: + model = rest_admin.models[v][0] + abs_url = request.build_absolute_uri("../"+v) + + fields = model._meta.get_fields(include_hidden=False) + out_fields = [] + for field in fields: + f = get_field_meta(field) + out_fields.append(f) + out[v] = {'fields' : out_fields, 'endpoint' : abs_url} + + return Response(out) diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..0e35bee --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,177 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/complexity.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/complexity.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/complexity" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/complexity" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." diff --git a/docs/authors.rst b/docs/authors.rst new file mode 100644 index 0000000..e122f91 --- /dev/null +++ b/docs/authors.rst @@ -0,0 +1 @@ +.. include:: ../AUTHORS.rst diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..b349ecf --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,254 @@ +# -*- coding: utf-8 -*- +# +# complexity documentation build configuration file, created by +# sphinx-quickstart on Tue Jul 9 22:26:36 2013. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +cwd = os.getcwd() +parent = os.path.dirname(cwd) +sys.path.append(parent) + +import django_rest_admin + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'django-rest-admin' +copyright = u'2015, Mauro Bianchi' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = django_rest_admin.__version__ +# The full version, including alpha/beta/rc tags. +release = django_rest_admin.__version__ + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'django-rest-admindoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'django-rest-admin.tex', u'django-rest-admin Documentation', + u'Mauro Bianchi', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'django-rest-admin', u'django-rest-admin Documentation', + [u'Mauro Bianchi'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------------ + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'django-rest-admin', u'django-rest-admin Documentation', + u'Mauro Bianchi', 'django-rest-admin', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False diff --git a/docs/contributing.rst b/docs/contributing.rst new file mode 100644 index 0000000..e582053 --- /dev/null +++ b/docs/contributing.rst @@ -0,0 +1 @@ +.. include:: ../CONTRIBUTING.rst diff --git a/docs/history.rst b/docs/history.rst new file mode 100644 index 0000000..2506499 --- /dev/null +++ b/docs/history.rst @@ -0,0 +1 @@ +.. include:: ../HISTORY.rst diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..d542400 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,19 @@ +.. complexity documentation master file, created by + sphinx-quickstart on Tue Jul 9 22:26:36 2013. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to django-rest-admin's documentation! +================================================================= + +Contents: + +.. toctree:: + :maxdepth: 2 + + readme + installation + usage + contributing + authors + history diff --git a/docs/installation.rst b/docs/installation.rst new file mode 100644 index 0000000..77647a0 --- /dev/null +++ b/docs/installation.rst @@ -0,0 +1,12 @@ +============ +Installation +============ + +At the command line:: + + $ easy_install django-rest-admin + +Or, if you have virtualenvwrapper installed:: + + $ mkvirtualenv django-rest-admin + $ pip install django-rest-admin diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..2df9a8c --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,242 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +set I18NSPHINXOPTS=%SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% + set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. texinfo to make Texinfo files + echo. gettext to make PO message catalogs + echo. changes to make an overview over all changed/added/deprecated items + echo. xml to make Docutils-native XML files + echo. pseudoxml to make pseudoxml-XML files for display purposes + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + + +%SPHINXBUILD% 2> nul +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\complexity.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\complexity.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdf" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf + cd %BUILDDIR%/.. + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdfja" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf-ja + cd %BUILDDIR%/.. + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "texinfo" ( + %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. + goto end +) + +if "%1" == "gettext" ( + %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The message catalogs are in %BUILDDIR%/locale. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +if "%1" == "xml" ( + %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The XML files are in %BUILDDIR%/xml. + goto end +) + +if "%1" == "pseudoxml" ( + %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. + goto end +) + +:end diff --git a/docs/readme.rst b/docs/readme.rst new file mode 100644 index 0000000..72a3355 --- /dev/null +++ b/docs/readme.rst @@ -0,0 +1 @@ +.. include:: ../README.rst diff --git a/docs/usage.rst b/docs/usage.rst new file mode 100644 index 0000000..cb991ae --- /dev/null +++ b/docs/usage.rst @@ -0,0 +1,7 @@ +======== +Usage +======== + +To use django-rest-admin in a project:: + + import django_rest_admin diff --git a/example_app/.gitignore b/example_app/.gitignore new file mode 100644 index 0000000..5fc1fce --- /dev/null +++ b/example_app/.gitignore @@ -0,0 +1,2 @@ +env/* + diff --git a/example_app/example/contacts/__init__.py b/example_app/example/contacts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/example_app/example/contacts/admin.py b/example_app/example/contacts/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/example_app/example/contacts/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/example_app/example/contacts/migrations/0001_initial.py b/example_app/example/contacts/migrations/0001_initial.py new file mode 100644 index 0000000..608aeb7 --- /dev/null +++ b/example_app/example/contacts/migrations/0001_initial.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Person', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('name', models.CharField(max_length=12)), + ('surname', models.CharField(max_length=12)), + ], + ), + ] diff --git a/example_app/example/contacts/migrations/__init__.py b/example_app/example/contacts/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/example_app/example/contacts/models.py b/example_app/example/contacts/models.py new file mode 100644 index 0000000..f0bc03e --- /dev/null +++ b/example_app/example/contacts/models.py @@ -0,0 +1,5 @@ +from django.db import models + +class Person(models.Model): + name = models.CharField(max_length=12) + surname = models.CharField(max_length=12) \ No newline at end of file diff --git a/example_app/example/contacts/rest_admin.py b/example_app/example/contacts/rest_admin.py new file mode 100644 index 0000000..bca22fc --- /dev/null +++ b/example_app/example/contacts/rest_admin.py @@ -0,0 +1,4 @@ +from django_rest_admin import rest_admin +from .models import Person + +rest_admin.register(Person) \ No newline at end of file diff --git a/example_app/example/contacts/tests.py b/example_app/example/contacts/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/example_app/example/contacts/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/example_app/example/contacts/views.py b/example_app/example/contacts/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/example_app/example/contacts/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/example_app/example/db.sqlite3 b/example_app/example/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..9d0595b42af7d7686c2863b42af225f93f8b3a57 GIT binary patch literal 38912 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 L17WS{0MGvbpe8E8 literal 0 HcmV?d00001 diff --git a/example_app/example/example/__init__.py b/example_app/example/example/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/example_app/example/example/settings.py b/example_app/example/example/settings.py new file mode 100644 index 0000000..9c34edc --- /dev/null +++ b/example_app/example/example/settings.py @@ -0,0 +1,107 @@ +""" +Django settings for example project. + +Generated by 'django-admin startproject' using Django 1.8.6. + +For more information on this file, see +https://docs.djangoproject.com/en/1.8/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.8/ref/settings/ +""" + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +import os + +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '2bw^3he=fec391t^%wkb0(!&kh-xq-yt%_!zr-ekao&bgoc7#5' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = ( + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + + 'rest_framework', + 'django_rest_admin', + + 'contacts' +) + +MIDDLEWARE_CLASSES = ( + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django.middleware.security.SecurityMiddleware', +) + +ROOT_URLCONF = 'example.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'example.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.8/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Internationalization +# https://docs.djangoproject.com/en/1.8/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.8/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/example_app/example/example/urls.py b/example_app/example/example/urls.py new file mode 100644 index 0000000..a56a39e --- /dev/null +++ b/example_app/example/example/urls.py @@ -0,0 +1,22 @@ +"""example URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.8/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Add an import: from blog import urls as blog_urls + 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) +""" +from django.conf.urls import include, url +from django.contrib import admin + +urlpatterns = [ + url(r'^admin/', include(admin.site.urls)), + url(r'^rest_admin/', include('django_rest_admin.urls')), +] diff --git a/example_app/example/example/wsgi.py b/example_app/example/example/wsgi.py new file mode 100644 index 0000000..986d3c1 --- /dev/null +++ b/example_app/example/example/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for example project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings") + +application = get_wsgi_application() diff --git a/example_app/example/manage.py b/example_app/example/manage.py new file mode 100755 index 0000000..2605e37 --- /dev/null +++ b/example_app/example/manage.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 0000000..dbd4e66 --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,7 @@ +django>=1.8.0 +coverage +mock>=1.0.1 +flake8>=2.1.0 +tox>=1.7.0 + +# Additional test requirements go here diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..de9eb40 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +django>=1.8.0 +wheel==0.24.0 +# Additional requirements go here diff --git a/runtests.py b/runtests.py new file mode 100644 index 0000000..29cc1b6 --- /dev/null +++ b/runtests.py @@ -0,0 +1,55 @@ +import sys + +try: + from django.conf import settings + from django.test.utils import get_runner + + settings.configure( + DEBUG=True, + USE_TZ=True, + DATABASES={ + "default": { + "ENGINE": "django.db.backends.sqlite3", + } + }, + ROOT_URLCONF="django_rest_admin.urls", + INSTALLED_APPS=[ + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sites", + "django_rest_admin", + ], + SITE_ID=1, + MIDDLEWARE_CLASSES=(), + ) + + try: + import django + setup = django.setup + except AttributeError: + pass + else: + setup() + +except ImportError: + import traceback + traceback.print_exc() + raise ImportError("To fix this error, run: pip install -r requirements-test.txt") + + +def run_tests(*test_args): + if not test_args: + test_args = ['tests'] + + # Run tests + TestRunner = get_runner(settings) + test_runner = TestRunner() + + failures = test_runner.run_tests(test_args) + + if failures: + sys.exit(bool(failures)) + + +if __name__ == '__main__': + run_tests(*sys.argv[1:]) diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..5e40900 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[wheel] +universal = 1 diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..ac245de --- /dev/null +++ b/setup.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import sys + +import django_rest_admin + +try: + from setuptools import setup +except ImportError: + from distutils.core import setup + +version = django_rest_admin.__version__ + +if sys.argv[-1] == 'publish': + os.system('python setup.py sdist upload') + os.system('python setup.py bdist_wheel upload') + sys.exit() + +if sys.argv[-1] == 'tag': + print("Tagging the version on github:") + os.system("git tag -a %s -m 'version %s'" % (version, version)) + os.system("git push --tags") + sys.exit() + +readme = open('README.rst').read() +history = open('HISTORY.rst').read().replace('.. :changelog:', '') + +setup( + name='django-rest-admin', + version=version, + description="""En EADRREST endpoints for administering django models.""", + long_description=readme + '\n\n' + history, + author='Mauro Bianchi', + author_email='bianchimro@gmail.com', + url='https://github.com/bianchimro/django-rest-admin', + packages=[ + 'django_rest_admin', + ], + include_package_data=True, + install_requires=[ + ], + license="BSD", + zip_safe=False, + keywords='django-rest-admin', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Framework :: Django', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: BSD License', + 'Natural Language :: English', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + ], +) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_models.py b/tests/test_models.py new file mode 100644 index 0000000..f726b9d --- /dev/null +++ b/tests/test_models.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +test_django-rest-admin +------------ + +Tests for `django-rest-admin` models module. +""" + +from django.test import TestCase + +from django_rest_admin import models + + +class TestDjango_rest_admin(TestCase): + + def setUp(self): + pass + + def test_something(self): + pass + + def tearDown(self): + pass diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..925dca8 --- /dev/null +++ b/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = py27, py33, py34 + +[testenv] +setenv = + PYTHONPATH = {toxinidir}:{toxinidir}/django_rest_admin +commands = python runtests.py +deps = + -r{toxinidir}/requirements-test.txt