├── .gitignore ├── .travis.yml ├── AUTHORS.rst ├── CONTRIBUTING.rst ├── HISTORY.rst ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.desired.rst ├── README.rst ├── django_rest_admin ├── __init__.py ├── apps.py ├── auth_views.py ├── jsonschema.py ├── models.py ├── register.py ├── rest_admin.py ├── urls.py └── views.py ├── docs ├── Makefile ├── authors.rst ├── conf.py ├── contributing.rst ├── history.rst ├── index.rst ├── installation.rst ├── make.bat ├── readme.rst └── usage.rst ├── example_app ├── .gitignore ├── example │ ├── contacts │ │ ├── __init__.py │ │ ├── admin.py │ │ ├── migrations │ │ │ ├── 0001_initial.py │ │ │ ├── 0002_auto_20151223_1529.py │ │ │ └── __init__.py │ │ ├── models.py │ │ ├── rest_admin.py │ │ ├── tests.py │ │ └── views.py │ ├── example │ │ ├── __init__.py │ │ ├── settings.py │ │ ├── urls.py │ │ └── wsgi.py │ └── manage.py └── requirements.txt ├── requirements-test.txt ├── requirements.txt ├── runtests.py ├── setup.cfg ├── setup.py ├── tests ├── __init__.py └── test_models.py └── tox.ini /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | __pycache__ 3 | 4 | # VENV 5 | venv 6 | 7 | # C extensions 8 | *.so 9 | 10 | # Packages 11 | *.egg 12 | *.egg-info 13 | dist 14 | build 15 | eggs 16 | parts 17 | bin 18 | var 19 | sdist 20 | develop-eggs 21 | .installed.cfg 22 | lib 23 | lib64 24 | 25 | # Installer logs 26 | pip-log.txt 27 | 28 | # Unit test / coverage reports 29 | .coverage 30 | .tox 31 | nosetests.xml 32 | htmlcov 33 | 34 | # Translations 35 | *.mo 36 | 37 | # Mr Developer 38 | .mr.developer.cfg 39 | .project 40 | .pydevproject 41 | 42 | # Complexity 43 | output/*.html 44 | output/*/index.html 45 | 46 | # Sphinx 47 | docs/_build 48 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Config file for automatic testing at travis-ci.org 2 | 3 | language: python 4 | 5 | python: 6 | - "3.4" 7 | - "3.3" 8 | - "2.7" 9 | 10 | before_install: 11 | - pip install codecov 12 | 13 | # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors 14 | install: pip install -r requirements-test.txt 15 | 16 | # command to run tests using coverage, e.g. python setup.py test 17 | script: coverage run --source django_rest_admin runtests.py 18 | 19 | after_success: 20 | - codecov 21 | -------------------------------------------------------------------------------- /AUTHORS.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | Credits 3 | ======= 4 | 5 | Development Lead 6 | ---------------- 7 | 8 | * Mauro Bianchi 9 | 10 | Contributors 11 | ------------ 12 | 13 | None yet. Why not be the first? 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Contributing 3 | ============ 4 | 5 | Contributions are welcome, and they are greatly appreciated! Every 6 | little bit helps, and credit will always be given. 7 | 8 | You can contribute in many ways: 9 | 10 | Types of Contributions 11 | ---------------------- 12 | 13 | Report Bugs 14 | ~~~~~~~~~~~ 15 | 16 | Report bugs at https://github.com/bianchimro/django-rest-admin/issues. 17 | 18 | If you are reporting a bug, please include: 19 | 20 | * Your operating system name and version. 21 | * Any details about your local setup that might be helpful in troubleshooting. 22 | * Detailed steps to reproduce the bug. 23 | 24 | Fix Bugs 25 | ~~~~~~~~ 26 | 27 | Look through the GitHub issues for bugs. Anything tagged with "bug" 28 | is open to whoever wants to implement it. 29 | 30 | Implement Features 31 | ~~~~~~~~~~~~~~~~~~ 32 | 33 | Look through the GitHub issues for features. Anything tagged with "feature" 34 | is open to whoever wants to implement it. 35 | 36 | Write Documentation 37 | ~~~~~~~~~~~~~~~~~~~ 38 | 39 | django-rest-admin could always use more documentation, whether as part of the 40 | official django-rest-admin docs, in docstrings, or even on the web in blog posts, 41 | articles, and such. 42 | 43 | Submit Feedback 44 | ~~~~~~~~~~~~~~~ 45 | 46 | The best way to send feedback is to file an issue at https://github.com/bianchimro/django-rest-admin/issues. 47 | 48 | If you are proposing a feature: 49 | 50 | * Explain in detail how it would work. 51 | * Keep the scope as narrow as possible, to make it easier to implement. 52 | * Remember that this is a volunteer-driven project, and that contributions 53 | are welcome :) 54 | 55 | Get Started! 56 | ------------ 57 | 58 | Ready to contribute? Here's how to set up `django-rest-admin` for local development. 59 | 60 | 1. Fork the `django-rest-admin` repo on GitHub. 61 | 2. Clone your fork locally:: 62 | 63 | $ git clone git@github.com:your_name_here/django-rest-admin.git 64 | 65 | 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: 66 | 67 | $ mkvirtualenv django-rest-admin 68 | $ cd django-rest-admin/ 69 | $ python setup.py develop 70 | 71 | 4. Create a branch for local development:: 72 | 73 | $ git checkout -b name-of-your-bugfix-or-feature 74 | 75 | Now you can make your changes locally. 76 | 77 | 5. When you're done making changes, check that your changes pass flake8 and the 78 | tests, including testing other Python versions with tox:: 79 | 80 | $ flake8 django_rest_admin tests 81 | $ python setup.py test 82 | $ tox 83 | 84 | To get flake8 and tox, just pip install them into your virtualenv. 85 | 86 | 6. Commit your changes and push your branch to GitHub:: 87 | 88 | $ git add . 89 | $ git commit -m "Your detailed description of your changes." 90 | $ git push origin name-of-your-bugfix-or-feature 91 | 92 | 7. Submit a pull request through the GitHub website. 93 | 94 | Pull Request Guidelines 95 | ----------------------- 96 | 97 | Before you submit a pull request, check that it meets these guidelines: 98 | 99 | 1. The pull request should include tests. 100 | 2. If the pull request adds functionality, the docs should be updated. Put 101 | your new functionality into a function with a docstring, and add the 102 | feature to the list in README.rst. 103 | 3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check 104 | https://travis-ci.org/bianchimro/django-rest-admin/pull_requests 105 | and make sure that the tests pass for all supported Python versions. 106 | 107 | Tips 108 | ---- 109 | 110 | To run a subset of tests:: 111 | 112 | $ python -m unittest tests.test_django_rest_admin 113 | -------------------------------------------------------------------------------- /HISTORY.rst: -------------------------------------------------------------------------------- 1 | .. :changelog: 2 | 3 | History 4 | ------- 5 | 6 | 0.1.0 (2015-10-02) 7 | ++++++++++++++++++ 8 | 9 | * First release on PyPI. 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Mauro Bianchi 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | * 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. 9 | 10 | * 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. 11 | 12 | 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. -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS.rst 2 | include CONTRIBUTING.rst 3 | include HISTORY.rst 4 | include LICENSE 5 | include README.rst 6 | recursive-include django_rest_admin *.html *.png *.gif *js *.css *jpg *jpeg *svg *py 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean-pyc clean-build docs 2 | 3 | help: 4 | @echo "clean-build - remove build artifacts" 5 | @echo "clean-pyc - remove Python file artifacts" 6 | @echo "lint - check style with flake8" 7 | @echo "test - run tests quickly with the default Python" 8 | @echo "test-all - run tests on every Python version with tox" 9 | @echo "coverage - check code coverage quickly with the default Python" 10 | @echo "docs - generate Sphinx HTML documentation, including API docs" 11 | @echo "release - package and upload a release" 12 | @echo "sdist - package" 13 | 14 | clean: clean-build clean-pyc 15 | 16 | clean-build: 17 | rm -fr build/ 18 | rm -fr dist/ 19 | rm -fr *.egg-info 20 | 21 | clean-pyc: 22 | find . -name '*.pyc' -exec rm -f {} + 23 | find . -name '*.pyo' -exec rm -f {} + 24 | find . -name '*~' -exec rm -f {} + 25 | 26 | lint: 27 | flake8 django_rest_admin tests 28 | 29 | test: 30 | python runtests.py tests 31 | 32 | test-all: 33 | tox 34 | 35 | coverage: 36 | coverage run --source django_rest_admin runtests.py tests 37 | coverage report -m 38 | coverage html 39 | open htmlcov/index.html 40 | 41 | docs: 42 | rm -f docs/django-rest-admin.rst 43 | rm -f docs/modules.rst 44 | sphinx-apidoc -o docs/ django_rest_admin 45 | $(MAKE) -C docs clean 46 | $(MAKE) -C docs html 47 | open docs/_build/html/index.html 48 | 49 | release: clean 50 | python setup.py sdist upload 51 | python setup.py bdist_wheel upload 52 | 53 | sdist: clean 54 | python setup.py sdist 55 | ls -l dist 56 | -------------------------------------------------------------------------------- /README.desired.rst: -------------------------------------------------------------------------------- 1 | ============================= 2 | django-rest-admin 3 | ============================= 4 | 5 | .. image:: https://badge.fury.io/py/django-rest-admin.png 6 | :target: https://badge.fury.io/py/django-rest-admin 7 | 8 | .. image:: https://travis-ci.org/inmagik/django-rest-admin.png?branch=master 9 | :target: https://travis-ci.org/inmagik/django-rest-admin 10 | 11 | REST endpoints for administering django models. 12 | 13 | Documentation 14 | ------------- 15 | 16 | The full documentation is at https://django-rest-admin.readthedocs.org. 17 | 18 | Quickstart 19 | ---------- 20 | 21 | Install django-rest-admin:: 22 | 23 | pip install django-rest-admin 24 | 25 | Then use it in a project: 26 | 27 | Attach rest_admin urls in your main `urls.py` file:: 28 | 29 | urlpatterns = [ 30 | url(r'^admin/', include(admin.site.urls)), 31 | url(r'^rest_admin/', include('django_rest_admin.urls')), 32 | ] 33 | 34 | 35 | You can then register a model in a file named `rest_admin.py` just like:: 36 | 37 | from django_rest_admin.register import rest_admin 38 | from .models import Person 39 | 40 | rest_admin.register(Person) 41 | 42 | Features 43 | -------- 44 | 45 | * TODO 46 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ============================= 2 | django-rest-admin 3 | ============================= 4 | 5 | THIS PROJECT IS IN AN EARLY STAGE, DO NOT USE IN PRODUCTION, IT LACKS MOST OF THE BASIC FEATURES - MOST NOTABLY SECURITY FEATURES. 6 | 7 | django-rest-admin is a django reusable app that aims at providing an easy way to create rest endpoints for managing model instances, pretty much like the admin does. 8 | 9 | * automatic urls configuration 10 | * simple registration of models via autodiscovering 11 | * metadata about models and endpoints 12 | 13 | This app is based on django-rest-framework. 14 | 15 | 16 | Quickstart 17 | ---------- 18 | 19 | Install django-rest-admin:: 20 | 21 | python setup.py install 22 | 23 | 24 | Then use it in a project: 25 | 26 | Attach rest_admin urls in your main `urls.py` file:: 27 | 28 | urlpatterns = [ 29 | url(r'^admin/', include(admin.site.urls)), 30 | url(r'^rest_admin/', include('django_rest_admin.urls')), 31 | ] 32 | 33 | 34 | You can then register a model in a file named `rest_admin.py` just like:: 35 | 36 | from django_rest_admin.register import rest_admin 37 | from .models import Person 38 | 39 | rest_admin.register(Person) 40 | 41 | 42 | Now navigate to the url you used for hooking up rest_admin: 43 | 44 | http://localhost:8000/rest_admin/ 45 | 46 | This is the base for your endpoints. 47 | 48 | 49 | How it works 50 | ------------ 51 | When you register a model, builds a REST-style CRUD interface by: 52 | 53 | * creating a django-rest-framework `ModelViewSet` class and passing in a `ModelSerializer` 54 | * mounting the viewset urls 55 | 56 | Additionally, `rest_admin` creates a `meta` endpoint that exposes all configuration for registered models, that should include: 57 | 58 | * base REST endpoint for that model 59 | * model fields definition 60 | * json-schema of the model 61 | 62 | Given this metadata is possible to build a client application acting as an admin. 63 | 64 | Features 65 | -------- 66 | 67 | * model registration à la admin (basic and non customizable for now) 68 | * automatic rest endpoint generation 69 | 70 | 71 | Ideas 72 | ----- 73 | 74 | * Use the same approach to generate read-only endpoints. This would be useful for applications that only need to display or search data without modifying it. 75 | -------------------------------------------------------------------------------- /django_rest_admin/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = '0.1.0' 2 | default_app_config = 'django_rest_admin.apps.RestAdminAppConfig' 3 | 4 | 5 | -------------------------------------------------------------------------------- /django_rest_admin/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | from django.conf import settings 3 | 4 | import sys 5 | import imp 6 | import importlib 7 | import os 8 | 9 | 10 | 11 | class RestAdminAppConfig(AppConfig): 12 | 13 | name = 'django_rest_admin' 14 | verbose_name = 'Rest Admin' 15 | loaded = False 16 | 17 | def ready(self): 18 | autodiscover() 19 | 20 | 21 | def autodiscover(): 22 | """ 23 | Automatic discovering of rest_admin.py file inside apps. 24 | similar to what Django admin does. 25 | """ 26 | from .register import rest_admin 27 | 28 | if not RestAdminAppConfig.loaded: 29 | for app in settings.INSTALLED_APPS: 30 | # For each app, we need to look for an rest_admin.py inside that app's 31 | # package. We can't use os.path here -- recall that modules may be 32 | # imported different ways (think zip files) -- so we need to get 33 | # the app's __path__ and look for rest_admin.py on that path. 34 | 35 | # Step 1: find out the app's __path__ Import errors here will (and 36 | # should) bubble up, but a missing __path__ (which is legal, but weird) 37 | # fails silently -- apps that do weird things with __path__ might 38 | # need to roll their own rest_admin registration. 39 | try: 40 | app_path = importlib.import_module(app).__path__ 41 | except AttributeError: 42 | continue 43 | 44 | # Step 2: use imp.find_module to find the app's rest_admin.py. For some 45 | # reason imp.find_module raises ImportError if the app can't be found 46 | # but doesn't actually try to import the module. So skip this app if 47 | # its rest_admin.py doesn't exist 48 | try: 49 | imp.find_module('rest_admin', app_path) 50 | except ImportError: 51 | continue 52 | 53 | # Step 3: import the app's admin file. If this has errors we want them 54 | # to bubble up. 55 | importlib.import_module("%s.rest_admin" % app) 56 | 57 | # autodiscover was successful, reset loading flag. 58 | RestAdminAppConfig.loaded = True 59 | -------------------------------------------------------------------------------- /django_rest_admin/auth_views.py: -------------------------------------------------------------------------------- 1 | 2 | from rest_framework import status 3 | from rest_framework.views import APIView 4 | from rest_framework.response import Response 5 | from rest_framework.permissions import IsAuthenticated, AllowAny 6 | from rest_framework.authtoken.models import Token 7 | from django.contrib.auth import authenticate, login 8 | from rest_framework.authtoken import views 9 | 10 | class LoginView(APIView): 11 | 12 | """ 13 | 14 | """ 15 | permission_classes = (AllowAny,) 16 | 17 | def post(self, request, *args, **kwargs): 18 | if 'username' in request.data and 'password' in request.data: 19 | user = authenticate(username=request.data['username'], password=request.data['password']) 20 | if user is not None: 21 | if user.is_active: 22 | login(request, user) 23 | # Redirect to a success page. 24 | else: 25 | # Return a 'disabled account' error message 26 | pass 27 | else: 28 | # Return an 'invalid login' error message. 29 | return Response({"error": "Cannot login with provided credentials"}, 30 | status=status.HTTP_403_FORBIDDEN) 31 | 32 | else: 33 | return Response({"error": "missing fields for login"}, 34 | status=status.HTTP_400_BAD_REQUEST) 35 | 36 | 37 | 38 | 39 | class LogoutView(APIView): 40 | 41 | """ 42 | Calls Django logout method and delete the Token object 43 | assigned to the current User object. 44 | Accepts/Returns nothing. 45 | """ 46 | permission_classes = (AllowAny,) 47 | 48 | def post(self, request): 49 | try: 50 | request.user.auth_token.delete() 51 | except: 52 | pass 53 | 54 | logout(request) 55 | 56 | return Response({"success": "Successfully logged out."}, 57 | status=status.HTTP_200_OK) 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /django_rest_admin/jsonschema.py: -------------------------------------------------------------------------------- 1 | #TODO find a better submodule name 2 | from django.forms import widgets, fields 3 | from django.db import models 4 | 5 | def pretty_name(name): 6 | """Converts 'first_name' to 'First name'""" 7 | if not name: 8 | return u'' 9 | return name.replace('_', ' ').capitalize() 10 | 11 | 12 | class DjangoModelToJSONSchema(object): 13 | def convert_modelfield(self, name, field, json_schema): 14 | target_def = { 15 | 'title': pretty_name(name), 16 | 'description': getattr(field, 'help_text', None), 17 | 'x-schema-form' : {} 18 | } 19 | 20 | if isinstance(field, models.CharField): 21 | target_def['type'] = 'string' 22 | target_def['maxlength'] = field.max_length 23 | elif isinstance(field, models.TextField): 24 | target_def['type'] = 'string' 25 | target_def['x-schema-form'] = {"type": "textarea"} 26 | if isinstance(field, models.DateField): 27 | target_def['type'] = 'string' 28 | target_def['format'] = 'date' 29 | elif isinstance(field, models.DateTimeField): 30 | target_def['type'] = 'string' 31 | target_def['format'] = 'datetime' 32 | elif isinstance(field, (models.DecimalField, models.FloatField)): 33 | target_def['type'] = 'number' 34 | elif isinstance(field, models.IntegerField): 35 | target_def['type'] = 'integer' 36 | elif isinstance(field, models.EmailField): 37 | target_def['type'] = 'string' 38 | target_def['format'] = 'email' 39 | elif isinstance(field, (models.NullBooleanField, models.BooleanField)): 40 | target_def['type'] = 'boolean' 41 | if isinstance(field, models.URLField): 42 | target_def['type'] = 'string' 43 | target_def['format'] = 'uri' 44 | else: 45 | target_def['type'] = 'string' 46 | 47 | 48 | if hasattr(field, 'choices') and field.choices: 49 | target_def['enum'] = [choice[0] for choice in field.choices] 50 | 51 | return target_def 52 | 53 | 54 | 55 | def convert_model(self, model, json_schema=None): 56 | if json_schema is None: 57 | json_schema = { 58 | #'title':dockit_schema._meta 59 | #'description' 60 | 'type':'object', 61 | 'properties':{}, #TODO SortedDict 62 | 'required' : [] 63 | } 64 | #CONSIDER: base_fields when given a class, fields for when given an instance 65 | fields = model._meta.get_fields(include_hidden=False) 66 | for field in fields: 67 | if isinstance(field, (models.fields.related.ManyToManyField, models.fields.reverse_related.ManyToManyRel)): 68 | continue 69 | 70 | if hasattr(field, 'primary_key') and field.primary_key: 71 | continue 72 | name = field.name 73 | if not field.null: 74 | json_schema['required'].append(name) 75 | json_schema['properties'][name] = self.convert_modelfield(name, field, json_schema) 76 | 77 | return json_schema 78 | -------------------------------------------------------------------------------- /django_rest_admin/models.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /django_rest_admin/register.py: -------------------------------------------------------------------------------- 1 | from collections import OrderedDict 2 | from django.conf import settings 3 | import warnings 4 | from django.core.urlresolvers import reverse 5 | from rest_framework import viewsets, serializers, permissions, authentication 6 | 7 | #import logging 8 | #logger = logging.getLogger(__name__) 9 | 10 | #TODO:MOVE AWAY 11 | class RestAdminConfig(object): 12 | serializer_class = serializers.ModelSerializer 13 | viewset_class = viewsets.ModelViewSet 14 | 15 | class RestAdminRegister(object): 16 | """ 17 | Holds registry for rest_admin. 18 | """ 19 | 20 | def __init__(self): 21 | """ 22 | #TODO: this will be lists.. 23 | """ 24 | self.models = OrderedDict() 25 | self.viewsets = OrderedDict() 26 | self.urls = {} 27 | 28 | 29 | def register(self, model, rest_admin_class=RestAdminConfig): 30 | """ 31 | rest_admin_class is not used now 32 | it will be used to provide options (like a custom ModelAdmin class in django admin) 33 | """ 34 | self.models[model._meta.object_name.lower()] = (model, rest_admin_class) 35 | 36 | 37 | def register_with_router(self, router): 38 | for v in self.models: 39 | model, rest_admin_class = self.models[v] 40 | 41 | serializer_attrs = { 42 | 'Meta' : type('Meta', (), { 'model' : model }) 43 | } 44 | serializer = type(v+'Serializer', (rest_admin_class.serializer_class,), serializer_attrs) 45 | 46 | viewset_attrs = { 47 | 'serializer_class' : serializer, 48 | 'queryset' : model.objects.all(), 49 | #'permission_classes' : [ permissions.IsAdminUser, ], 50 | #'authentication_classes' : [ authentication.TokenAuthentication, authentication.SessionAuthentication, ], 51 | } 52 | viewset = type(v+'ViewSet', (rest_admin_class.viewset_class,), viewset_attrs) 53 | router.register(r'%s'%v, viewset) 54 | 55 | return router 56 | 57 | 58 | def deregister(self, app_name, model): 59 | """ 60 | """ 61 | raise NotImplementedError 62 | 63 | 64 | # Intended to be a singleton 65 | rest_admin = RestAdminRegister() 66 | -------------------------------------------------------------------------------- /django_rest_admin/rest_admin.py: -------------------------------------------------------------------------------- 1 | from django_rest_admin.register import rest_admin 2 | from django.contrib.auth import get_user_model 3 | from django.contrib.auth.models import Group 4 | 5 | rest_admin.register(get_user_model()) 6 | rest_admin.register(Group) 7 | -------------------------------------------------------------------------------- /django_rest_admin/urls.py: -------------------------------------------------------------------------------- 1 | """ 2 | * standard urls 3 | * authentication endpoints 4 | * metadata endpoints 5 | * urls coming from registered models 6 | """ 7 | 8 | from django.conf.urls import include, url 9 | from django.conf import settings 10 | from .views import RestAdminMetaView 11 | from .register import rest_admin 12 | from rest_framework import routers 13 | from rest_framework.authtoken.views import obtain_auth_token 14 | from django.contrib.auth import views as auth_views 15 | 16 | #TODO: login/logout views disabled by settings 17 | 18 | urlpatterns = [ 19 | # probably would be better to provide our own endpoints. 20 | url(r'^session-login/', auth_views.login), 21 | url(r'^session-logout/', auth_views.logout), 22 | url(r'^token-login/', obtain_auth_token), 23 | url(r'^meta/$', RestAdminMetaView.as_view(), name='rest_admin_meta') 24 | ] 25 | 26 | router = rest_admin.register_with_router(routers.SimpleRouter()) 27 | urlpatterns += router.urls 28 | -------------------------------------------------------------------------------- /django_rest_admin/views.py: -------------------------------------------------------------------------------- 1 | from django.http import HttpResponseRedirect 2 | from django.shortcuts import render 3 | from rest_framework.views import APIView 4 | from rest_framework.response import Response 5 | from rest_framework import permissions 6 | from rest_framework import authentication 7 | from django_rest_admin.register import rest_admin 8 | from .jsonschema import DjangoModelToJSONSchema 9 | from django.forms import ModelForm 10 | 11 | def get_field_meta(field): 12 | """ 13 | returns a dictionary with some metadata from field of a model 14 | """ 15 | out = { 'name' : field.name, 'is_relation' : field.is_relation, 'class_name' : field.__class__.__name__} 16 | if field.is_relation: 17 | out['related_model'] = "%s.%s" % (field.related_model._meta.app_label, field.related_model.__name__) 18 | 19 | else: 20 | out['default'] = field.get_default() 21 | 22 | try: 23 | out['null'] = field.null 24 | except: 25 | pass 26 | 27 | return out 28 | 29 | 30 | class RestAdminMetaView(APIView): 31 | 32 | #authentication_classes = [ authentication.TokenAuthentication, authentication.SessionAuthentication, ] 33 | #permission_classes = [ permissions.IsAdminUser, ] 34 | 35 | def get(self, request): 36 | out = { } 37 | for v in rest_admin.models: 38 | model = rest_admin.models[v][0] 39 | abs_url = request.build_absolute_uri("../"+v) 40 | 41 | 42 | 43 | fields = model._meta.get_fields(include_hidden=False) 44 | out_fields = [] 45 | for field in fields: 46 | f = get_field_meta(field) 47 | out_fields.append(f) 48 | 49 | #getting json schema. all fields for now. #TODO: configure fields 50 | form_attrs = { 51 | 'Meta' : type('Meta', (), { 'model' : model, 'fields' : '__all__' }) 52 | } 53 | form_cls = type(v+'Form',(ModelForm,), form_attrs) 54 | json_schema = DjangoModelToJSONSchema().convert_model(model) 55 | 56 | out[v] = {'fields' : out_fields, 'endpoint' : abs_url, 'json_schema' : json_schema } 57 | 58 | 59 | return Response(out) 60 | 61 | 62 | def redirect_admin(request): 63 | return HttpResponseRedirect('/static/rest_admin/src/index.html') 64 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # User-friendly check for sphinx-build 11 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 12 | $(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/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 21 | 22 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 23 | 24 | help: 25 | @echo "Please use \`make ' where is one of" 26 | @echo " html to make standalone HTML files" 27 | @echo " dirhtml to make HTML files named index.html in directories" 28 | @echo " singlehtml to make a single large HTML file" 29 | @echo " pickle to make pickle files" 30 | @echo " json to make JSON files" 31 | @echo " htmlhelp to make HTML files and a HTML help project" 32 | @echo " qthelp to make HTML files and a qthelp project" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | 49 | clean: 50 | rm -rf $(BUILDDIR)/* 51 | 52 | html: 53 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 54 | @echo 55 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 56 | 57 | dirhtml: 58 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 59 | @echo 60 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 61 | 62 | singlehtml: 63 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 64 | @echo 65 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 66 | 67 | pickle: 68 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 69 | @echo 70 | @echo "Build finished; now you can process the pickle files." 71 | 72 | json: 73 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 74 | @echo 75 | @echo "Build finished; now you can process the JSON files." 76 | 77 | htmlhelp: 78 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 79 | @echo 80 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 81 | ".hhp project file in $(BUILDDIR)/htmlhelp." 82 | 83 | qthelp: 84 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 85 | @echo 86 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 87 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 88 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/complexity.qhcp" 89 | @echo "To view the help file:" 90 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/complexity.qhc" 91 | 92 | devhelp: 93 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 94 | @echo 95 | @echo "Build finished." 96 | @echo "To view the help file:" 97 | @echo "# mkdir -p $$HOME/.local/share/devhelp/complexity" 98 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/complexity" 99 | @echo "# devhelp" 100 | 101 | epub: 102 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 103 | @echo 104 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 105 | 106 | latex: 107 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 108 | @echo 109 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 110 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 111 | "(use \`make latexpdf' here to do that automatically)." 112 | 113 | latexpdf: 114 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 115 | @echo "Running LaTeX files through pdflatex..." 116 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 117 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 118 | 119 | latexpdfja: 120 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 121 | @echo "Running LaTeX files through platex and dvipdfmx..." 122 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 123 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 124 | 125 | text: 126 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 127 | @echo 128 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 129 | 130 | man: 131 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 132 | @echo 133 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 134 | 135 | texinfo: 136 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 137 | @echo 138 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 139 | @echo "Run \`make' in that directory to run these through makeinfo" \ 140 | "(use \`make info' here to do that automatically)." 141 | 142 | info: 143 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 144 | @echo "Running Texinfo files through makeinfo..." 145 | make -C $(BUILDDIR)/texinfo info 146 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 147 | 148 | gettext: 149 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 150 | @echo 151 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 152 | 153 | changes: 154 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 155 | @echo 156 | @echo "The overview file is in $(BUILDDIR)/changes." 157 | 158 | linkcheck: 159 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 160 | @echo 161 | @echo "Link check complete; look for any errors in the above output " \ 162 | "or in $(BUILDDIR)/linkcheck/output.txt." 163 | 164 | doctest: 165 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 166 | @echo "Testing of doctests in the sources finished, look at the " \ 167 | "results in $(BUILDDIR)/doctest/output.txt." 168 | 169 | xml: 170 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 171 | @echo 172 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 173 | 174 | pseudoxml: 175 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 176 | @echo 177 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 178 | -------------------------------------------------------------------------------- /docs/authors.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../AUTHORS.rst 2 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # complexity documentation build configuration file, created by 4 | # sphinx-quickstart on Tue Jul 9 22:26:36 2013. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | #sys.path.insert(0, os.path.abspath('.')) 20 | 21 | cwd = os.getcwd() 22 | parent = os.path.dirname(cwd) 23 | sys.path.append(parent) 24 | 25 | import django_rest_admin 26 | 27 | # -- General configuration ----------------------------------------------------- 28 | 29 | # If your documentation needs a minimal Sphinx version, state it here. 30 | #needs_sphinx = '1.0' 31 | 32 | # Add any Sphinx extension module names here, as strings. They can be extensions 33 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 34 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] 35 | 36 | # Add any paths that contain templates here, relative to this directory. 37 | templates_path = ['_templates'] 38 | 39 | # The suffix of source filenames. 40 | source_suffix = '.rst' 41 | 42 | # The encoding of source files. 43 | #source_encoding = 'utf-8-sig' 44 | 45 | # The master toctree document. 46 | master_doc = 'index' 47 | 48 | # General information about the project. 49 | project = u'django-rest-admin' 50 | copyright = u'2015, Mauro Bianchi' 51 | 52 | # The version info for the project you're documenting, acts as replacement for 53 | # |version| and |release|, also used in various other places throughout the 54 | # built documents. 55 | # 56 | # The short X.Y version. 57 | version = django_rest_admin.__version__ 58 | # The full version, including alpha/beta/rc tags. 59 | release = django_rest_admin.__version__ 60 | 61 | # The language for content autogenerated by Sphinx. Refer to documentation 62 | # for a list of supported languages. 63 | #language = None 64 | 65 | # There are two options for replacing |today|: either, you set today to some 66 | # non-false value, then it is used: 67 | #today = '' 68 | # Else, today_fmt is used as the format for a strftime call. 69 | #today_fmt = '%B %d, %Y' 70 | 71 | # List of patterns, relative to source directory, that match files and 72 | # directories to ignore when looking for source files. 73 | exclude_patterns = ['_build'] 74 | 75 | # The reST default role (used for this markup: `text`) to use for all documents. 76 | #default_role = None 77 | 78 | # If true, '()' will be appended to :func: etc. cross-reference text. 79 | #add_function_parentheses = True 80 | 81 | # If true, the current module name will be prepended to all description 82 | # unit titles (such as .. function::). 83 | #add_module_names = True 84 | 85 | # If true, sectionauthor and moduleauthor directives will be shown in the 86 | # output. They are ignored by default. 87 | #show_authors = False 88 | 89 | # The name of the Pygments (syntax highlighting) style to use. 90 | pygments_style = 'sphinx' 91 | 92 | # A list of ignored prefixes for module index sorting. 93 | #modindex_common_prefix = [] 94 | 95 | # If true, keep warnings as "system message" paragraphs in the built documents. 96 | #keep_warnings = False 97 | 98 | 99 | # -- Options for HTML output --------------------------------------------------- 100 | 101 | # The theme to use for HTML and HTML Help pages. See the documentation for 102 | # a list of builtin themes. 103 | html_theme = 'default' 104 | 105 | # Theme options are theme-specific and customize the look and feel of a theme 106 | # further. For a list of options available for each theme, see the 107 | # documentation. 108 | #html_theme_options = {} 109 | 110 | # Add any paths that contain custom themes here, relative to this directory. 111 | #html_theme_path = [] 112 | 113 | # The name for this set of Sphinx documents. If None, it defaults to 114 | # " v documentation". 115 | #html_title = None 116 | 117 | # A shorter title for the navigation bar. Default is the same as html_title. 118 | #html_short_title = None 119 | 120 | # The name of an image file (relative to this directory) to place at the top 121 | # of the sidebar. 122 | #html_logo = None 123 | 124 | # The name of an image file (within the static path) to use as favicon of the 125 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 126 | # pixels large. 127 | #html_favicon = None 128 | 129 | # Add any paths that contain custom static files (such as style sheets) here, 130 | # relative to this directory. They are copied after the builtin static files, 131 | # so a file named "default.css" will overwrite the builtin "default.css". 132 | html_static_path = ['_static'] 133 | 134 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 135 | # using the given strftime format. 136 | #html_last_updated_fmt = '%b %d, %Y' 137 | 138 | # If true, SmartyPants will be used to convert quotes and dashes to 139 | # typographically correct entities. 140 | #html_use_smartypants = True 141 | 142 | # Custom sidebar templates, maps document names to template names. 143 | #html_sidebars = {} 144 | 145 | # Additional templates that should be rendered to pages, maps page names to 146 | # template names. 147 | #html_additional_pages = {} 148 | 149 | # If false, no module index is generated. 150 | #html_domain_indices = True 151 | 152 | # If false, no index is generated. 153 | #html_use_index = True 154 | 155 | # If true, the index is split into individual pages for each letter. 156 | #html_split_index = False 157 | 158 | # If true, links to the reST sources are added to the pages. 159 | #html_show_sourcelink = True 160 | 161 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 162 | #html_show_sphinx = True 163 | 164 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 165 | #html_show_copyright = True 166 | 167 | # If true, an OpenSearch description file will be output, and all pages will 168 | # contain a tag referring to it. The value of this option must be the 169 | # base URL from which the finished HTML is served. 170 | #html_use_opensearch = '' 171 | 172 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 173 | #html_file_suffix = None 174 | 175 | # Output file base name for HTML help builder. 176 | htmlhelp_basename = 'django-rest-admindoc' 177 | 178 | 179 | # -- Options for LaTeX output -------------------------------------------------- 180 | 181 | latex_elements = { 182 | # The paper size ('letterpaper' or 'a4paper'). 183 | #'papersize': 'letterpaper', 184 | 185 | # The font size ('10pt', '11pt' or '12pt'). 186 | #'pointsize': '10pt', 187 | 188 | # Additional stuff for the LaTeX preamble. 189 | #'preamble': '', 190 | } 191 | 192 | # Grouping the document tree into LaTeX files. List of tuples 193 | # (source start file, target name, title, author, documentclass [howto/manual]). 194 | latex_documents = [ 195 | ('index', 'django-rest-admin.tex', u'django-rest-admin Documentation', 196 | u'Mauro Bianchi', 'manual'), 197 | ] 198 | 199 | # The name of an image file (relative to this directory) to place at the top of 200 | # the title page. 201 | #latex_logo = None 202 | 203 | # For "manual" documents, if this is true, then toplevel headings are parts, 204 | # not chapters. 205 | #latex_use_parts = False 206 | 207 | # If true, show page references after internal links. 208 | #latex_show_pagerefs = False 209 | 210 | # If true, show URL addresses after external links. 211 | #latex_show_urls = False 212 | 213 | # Documents to append as an appendix to all manuals. 214 | #latex_appendices = [] 215 | 216 | # If false, no module index is generated. 217 | #latex_domain_indices = True 218 | 219 | 220 | # -- Options for manual page output -------------------------------------------- 221 | 222 | # One entry per manual page. List of tuples 223 | # (source start file, name, description, authors, manual section). 224 | man_pages = [ 225 | ('index', 'django-rest-admin', u'django-rest-admin Documentation', 226 | [u'Mauro Bianchi'], 1) 227 | ] 228 | 229 | # If true, show URL addresses after external links. 230 | #man_show_urls = False 231 | 232 | 233 | # -- Options for Texinfo output ------------------------------------------------ 234 | 235 | # Grouping the document tree into Texinfo files. List of tuples 236 | # (source start file, target name, title, author, 237 | # dir menu entry, description, category) 238 | texinfo_documents = [ 239 | ('index', 'django-rest-admin', u'django-rest-admin Documentation', 240 | u'Mauro Bianchi', 'django-rest-admin', 'One line description of project.', 241 | 'Miscellaneous'), 242 | ] 243 | 244 | # Documents to append as an appendix to all manuals. 245 | #texinfo_appendices = [] 246 | 247 | # If false, no module index is generated. 248 | #texinfo_domain_indices = True 249 | 250 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 251 | #texinfo_show_urls = 'footnote' 252 | 253 | # If true, do not generate a @detailmenu in the "Top" node's menu. 254 | #texinfo_no_detailmenu = False 255 | -------------------------------------------------------------------------------- /docs/contributing.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../CONTRIBUTING.rst 2 | -------------------------------------------------------------------------------- /docs/history.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../HISTORY.rst 2 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. complexity documentation master file, created by 2 | sphinx-quickstart on Tue Jul 9 22:26:36 2013. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to django-rest-admin's documentation! 7 | ================================================================= 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | readme 15 | installation 16 | usage 17 | contributing 18 | authors 19 | history 20 | -------------------------------------------------------------------------------- /docs/installation.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Installation 3 | ============ 4 | 5 | At the command line:: 6 | 7 | $ easy_install django-rest-admin 8 | 9 | Or, if you have virtualenvwrapper installed:: 10 | 11 | $ mkvirtualenv django-rest-admin 12 | $ pip install django-rest-admin 13 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | goto end 41 | ) 42 | 43 | if "%1" == "clean" ( 44 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 45 | del /q /s %BUILDDIR%\* 46 | goto end 47 | ) 48 | 49 | 50 | %SPHINXBUILD% 2> nul 51 | if errorlevel 9009 ( 52 | echo. 53 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 54 | echo.installed, then set the SPHINXBUILD environment variable to point 55 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 56 | echo.may add the Sphinx directory to PATH. 57 | echo. 58 | echo.If you don't have Sphinx installed, grab it from 59 | echo.http://sphinx-doc.org/ 60 | exit /b 1 61 | ) 62 | 63 | if "%1" == "html" ( 64 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 68 | goto end 69 | ) 70 | 71 | if "%1" == "dirhtml" ( 72 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 76 | goto end 77 | ) 78 | 79 | if "%1" == "singlehtml" ( 80 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 84 | goto end 85 | ) 86 | 87 | if "%1" == "pickle" ( 88 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can process the pickle files. 92 | goto end 93 | ) 94 | 95 | if "%1" == "json" ( 96 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 97 | if errorlevel 1 exit /b 1 98 | echo. 99 | echo.Build finished; now you can process the JSON files. 100 | goto end 101 | ) 102 | 103 | if "%1" == "htmlhelp" ( 104 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 105 | if errorlevel 1 exit /b 1 106 | echo. 107 | echo.Build finished; now you can run HTML Help Workshop with the ^ 108 | .hhp project file in %BUILDDIR%/htmlhelp. 109 | goto end 110 | ) 111 | 112 | if "%1" == "qthelp" ( 113 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 114 | if errorlevel 1 exit /b 1 115 | echo. 116 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 117 | .qhcp project file in %BUILDDIR%/qthelp, like this: 118 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\complexity.qhcp 119 | echo.To view the help file: 120 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\complexity.ghc 121 | goto end 122 | ) 123 | 124 | if "%1" == "devhelp" ( 125 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished. 129 | goto end 130 | ) 131 | 132 | if "%1" == "epub" ( 133 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 137 | goto end 138 | ) 139 | 140 | if "%1" == "latex" ( 141 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 145 | goto end 146 | ) 147 | 148 | if "%1" == "latexpdf" ( 149 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 150 | cd %BUILDDIR%/latex 151 | make all-pdf 152 | cd %BUILDDIR%/.. 153 | echo. 154 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 155 | goto end 156 | ) 157 | 158 | if "%1" == "latexpdfja" ( 159 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 160 | cd %BUILDDIR%/latex 161 | make all-pdf-ja 162 | cd %BUILDDIR%/.. 163 | echo. 164 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 165 | goto end 166 | ) 167 | 168 | if "%1" == "text" ( 169 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 170 | if errorlevel 1 exit /b 1 171 | echo. 172 | echo.Build finished. The text files are in %BUILDDIR%/text. 173 | goto end 174 | ) 175 | 176 | if "%1" == "man" ( 177 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 178 | if errorlevel 1 exit /b 1 179 | echo. 180 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 181 | goto end 182 | ) 183 | 184 | if "%1" == "texinfo" ( 185 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 186 | if errorlevel 1 exit /b 1 187 | echo. 188 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 189 | goto end 190 | ) 191 | 192 | if "%1" == "gettext" ( 193 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 194 | if errorlevel 1 exit /b 1 195 | echo. 196 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 197 | goto end 198 | ) 199 | 200 | if "%1" == "changes" ( 201 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 202 | if errorlevel 1 exit /b 1 203 | echo. 204 | echo.The overview file is in %BUILDDIR%/changes. 205 | goto end 206 | ) 207 | 208 | if "%1" == "linkcheck" ( 209 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 210 | if errorlevel 1 exit /b 1 211 | echo. 212 | echo.Link check complete; look for any errors in the above output ^ 213 | or in %BUILDDIR%/linkcheck/output.txt. 214 | goto end 215 | ) 216 | 217 | if "%1" == "doctest" ( 218 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 219 | if errorlevel 1 exit /b 1 220 | echo. 221 | echo.Testing of doctests in the sources finished, look at the ^ 222 | results in %BUILDDIR%/doctest/output.txt. 223 | goto end 224 | ) 225 | 226 | if "%1" == "xml" ( 227 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 228 | if errorlevel 1 exit /b 1 229 | echo. 230 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 231 | goto end 232 | ) 233 | 234 | if "%1" == "pseudoxml" ( 235 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 236 | if errorlevel 1 exit /b 1 237 | echo. 238 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 239 | goto end 240 | ) 241 | 242 | :end 243 | -------------------------------------------------------------------------------- /docs/readme.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | -------------------------------------------------------------------------------- /docs/usage.rst: -------------------------------------------------------------------------------- 1 | ======== 2 | Usage 3 | ======== 4 | 5 | To use django-rest-admin in a project:: 6 | 7 | import django_rest_admin 8 | -------------------------------------------------------------------------------- /example_app/.gitignore: -------------------------------------------------------------------------------- 1 | env/* 2 | *.sqlite 3 | *.sqlite3 4 | -------------------------------------------------------------------------------- /example_app/example/contacts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inmagik/django-rest-admin/61c0d1a993ebcf144352e0ee0f916d9e63c1ccf7/example_app/example/contacts/__init__.py -------------------------------------------------------------------------------- /example_app/example/contacts/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /example_app/example/contacts/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import migrations, models 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ] 11 | 12 | operations = [ 13 | migrations.CreateModel( 14 | name='Person', 15 | fields=[ 16 | ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), 17 | ('name', models.CharField(max_length=12)), 18 | ('surname', models.CharField(max_length=12)), 19 | ], 20 | ), 21 | ] 22 | -------------------------------------------------------------------------------- /example_app/example/contacts/migrations/0002_auto_20151223_1529.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.9 on 2015-12-23 15:29 3 | from __future__ import unicode_literals 4 | 5 | import datetime 6 | from django.db import migrations, models 7 | from django.utils.timezone import utc 8 | 9 | 10 | class Migration(migrations.Migration): 11 | 12 | dependencies = [ 13 | ('contacts', '0001_initial'), 14 | ] 15 | 16 | operations = [ 17 | migrations.CreateModel( 18 | name='Place', 19 | fields=[ 20 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 21 | ('name', models.CharField(max_length=200)), 22 | ('description', models.TextField(blank=True, null=True)), 23 | ], 24 | ), 25 | migrations.AddField( 26 | model_name='person', 27 | name='birthdate', 28 | field=models.DateField(default=datetime.datetime(2015, 12, 23, 15, 29, 41, 452349, tzinfo=utc)), 29 | preserve_default=False, 30 | ), 31 | ] 32 | -------------------------------------------------------------------------------- /example_app/example/contacts/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inmagik/django-rest-admin/61c0d1a993ebcf144352e0ee0f916d9e63c1ccf7/example_app/example/contacts/migrations/__init__.py -------------------------------------------------------------------------------- /example_app/example/contacts/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | class Person(models.Model): 4 | name = models.CharField(max_length=12) 5 | surname = models.CharField(max_length=12) 6 | birthdate = models.DateField() 7 | 8 | class Place(models.Model): 9 | name = models.CharField(max_length=200) 10 | description = models.TextField(null=True, blank=True) -------------------------------------------------------------------------------- /example_app/example/contacts/rest_admin.py: -------------------------------------------------------------------------------- 1 | from django_rest_admin.register import rest_admin 2 | from .models import Person, Place 3 | 4 | rest_admin.register(Person) 5 | rest_admin.register(Place) 6 | 7 | 8 | -------------------------------------------------------------------------------- /example_app/example/contacts/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /example_app/example/contacts/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | -------------------------------------------------------------------------------- /example_app/example/example/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inmagik/django-rest-admin/61c0d1a993ebcf144352e0ee0f916d9e63c1ccf7/example_app/example/example/__init__.py -------------------------------------------------------------------------------- /example_app/example/example/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for example project. 3 | 4 | Generated by 'django-admin startproject' using Django 1.8.6. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.8/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/1.8/ref/settings/ 11 | """ 12 | 13 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 14 | import os 15 | 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '2bw^3he=fec391t^%wkb0(!&kh-xq-yt%_!zr-ekao&bgoc7#5' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = ( 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 41 | 'rest_framework', 42 | 'rest_framework.authtoken', 43 | 'django_rest_admin', 44 | 45 | 'contacts' 46 | ) 47 | 48 | MIDDLEWARE_CLASSES = ( 49 | 'django.contrib.sessions.middleware.SessionMiddleware', 50 | 'django.middleware.common.CommonMiddleware', 51 | 'django.middleware.csrf.CsrfViewMiddleware', 52 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 53 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 54 | 'django.contrib.messages.middleware.MessageMiddleware', 55 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 56 | 'django.middleware.security.SecurityMiddleware', 57 | ) 58 | 59 | ROOT_URLCONF = 'example.urls' 60 | 61 | TEMPLATES = [ 62 | { 63 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 64 | 'DIRS': [], 65 | 'APP_DIRS': True, 66 | 'OPTIONS': { 67 | 'context_processors': [ 68 | 'django.template.context_processors.debug', 69 | 'django.template.context_processors.request', 70 | 'django.contrib.auth.context_processors.auth', 71 | 'django.contrib.messages.context_processors.messages', 72 | ], 73 | }, 74 | }, 75 | ] 76 | 77 | WSGI_APPLICATION = 'example.wsgi.application' 78 | 79 | 80 | # Database 81 | # https://docs.djangoproject.com/en/1.8/ref/settings/#databases 82 | 83 | DATABASES = { 84 | 'default': { 85 | 'ENGINE': 'django.db.backends.sqlite3', 86 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 87 | } 88 | } 89 | 90 | 91 | # Internationalization 92 | # https://docs.djangoproject.com/en/1.8/topics/i18n/ 93 | 94 | LANGUAGE_CODE = 'en-us' 95 | 96 | TIME_ZONE = 'UTC' 97 | 98 | USE_I18N = True 99 | 100 | USE_L10N = True 101 | 102 | USE_TZ = True 103 | 104 | 105 | # Static files (CSS, JavaScript, Images) 106 | # https://docs.djangoproject.com/en/1.8/howto/static-files/ 107 | 108 | STATIC_URL = '/static/' 109 | -------------------------------------------------------------------------------- /example_app/example/example/urls.py: -------------------------------------------------------------------------------- 1 | """example URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/1.8/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Add an import: from blog import urls as blog_urls 14 | 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) 15 | """ 16 | from django.conf.urls import include, url 17 | from django.contrib import admin 18 | 19 | urlpatterns = [ 20 | url(r'^admin/', include(admin.site.urls)), 21 | url(r'^rest_admin/', include('django_rest_admin.urls')), 22 | ] 23 | -------------------------------------------------------------------------------- /example_app/example/example/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for example project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /example_app/example/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings") 7 | 8 | from django.core.management import execute_from_command_line 9 | 10 | execute_from_command_line(sys.argv) 11 | -------------------------------------------------------------------------------- /example_app/requirements.txt: -------------------------------------------------------------------------------- 1 | Django==1.9 2 | django-jsonschema==0.2.0 3 | -e git+https://github.com/inmagik/django-rest-admin.git@ce1e425463dcdf22de14a6812d46ef2ecc99a268#egg=django_rest_admin-master 4 | djangorestframework==3.3.2 5 | wheel==0.24.0 6 | wsgiref==0.1.2 7 | -------------------------------------------------------------------------------- /requirements-test.txt: -------------------------------------------------------------------------------- 1 | django>=1.8.0 2 | coverage 3 | mock>=1.0.1 4 | flake8>=2.1.0 5 | tox>=1.7.0 6 | 7 | # Additional test requirements go here 8 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | django>=1.8.0 2 | wheel==0.24.0 3 | # Additional requirements go here 4 | djangorestframework>=3.3.0 5 | -------------------------------------------------------------------------------- /runtests.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | try: 4 | from django.conf import settings 5 | from django.test.utils import get_runner 6 | 7 | settings.configure( 8 | DEBUG=True, 9 | USE_TZ=True, 10 | DATABASES={ 11 | "default": { 12 | "ENGINE": "django.db.backends.sqlite3", 13 | } 14 | }, 15 | ROOT_URLCONF="django_rest_admin.urls", 16 | INSTALLED_APPS=[ 17 | "django.contrib.auth", 18 | "django.contrib.contenttypes", 19 | "django.contrib.sites", 20 | "django_rest_admin", 21 | ], 22 | SITE_ID=1, 23 | MIDDLEWARE_CLASSES=(), 24 | ) 25 | 26 | try: 27 | import django 28 | setup = django.setup 29 | except AttributeError: 30 | pass 31 | else: 32 | setup() 33 | 34 | except ImportError: 35 | import traceback 36 | traceback.print_exc() 37 | raise ImportError("To fix this error, run: pip install -r requirements-test.txt") 38 | 39 | 40 | def run_tests(*test_args): 41 | if not test_args: 42 | test_args = ['tests'] 43 | 44 | # Run tests 45 | TestRunner = get_runner(settings) 46 | test_runner = TestRunner() 47 | 48 | failures = test_runner.run_tests(test_args) 49 | 50 | if failures: 51 | sys.exit(bool(failures)) 52 | 53 | 54 | if __name__ == '__main__': 55 | run_tests(*sys.argv[1:]) 56 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import sys 6 | 7 | import django_rest_admin 8 | 9 | try: 10 | from setuptools import setup 11 | except ImportError: 12 | from distutils.core import setup 13 | 14 | version = django_rest_admin.__version__ 15 | 16 | if sys.argv[-1] == 'publish': 17 | os.system('python setup.py sdist upload') 18 | os.system('python setup.py bdist_wheel upload') 19 | sys.exit() 20 | 21 | if sys.argv[-1] == 'tag': 22 | print("Tagging the version on github:") 23 | os.system("git tag -a %s -m 'version %s'" % (version, version)) 24 | os.system("git push --tags") 25 | sys.exit() 26 | 27 | readme = open('README.rst').read() 28 | history = open('HISTORY.rst').read().replace('.. :changelog:', '') 29 | 30 | def get_install_requires(): 31 | """ 32 | parse requirements.txt, ignore links, exclude comments 33 | """ 34 | requirements = [] 35 | for line in open('requirements.txt').readlines(): 36 | # skip to next iteration if comment or empty line 37 | if line.startswith('#') or line == '' or line.startswith('http') or line.startswith('git'): 38 | continue 39 | # add line to requirements 40 | requirements.append(line) 41 | return requirements 42 | 43 | setup( 44 | name='django-rest-admin', 45 | version=version, 46 | description="""REST endpoints for administering django models.""", 47 | long_description=readme + '\n\n' + history, 48 | author='Mauro Bianchi', 49 | author_email='bianchimro@gmail.com', 50 | url='https://github.com/inmagik/django-rest-admin', 51 | packages=[ 52 | 'django_rest_admin', 53 | ], 54 | include_package_data=True, 55 | install_requires=get_install_requires(), 56 | license="BSD", 57 | zip_safe=False, 58 | keywords='django-rest-admin', 59 | classifiers=[ 60 | 'Development Status :: 3 - Alpha', 61 | 'Framework :: Django', 62 | 'Intended Audience :: Developers', 63 | 'License :: OSI Approved :: BSD License', 64 | 'Natural Language :: English', 65 | 'Programming Language :: Python :: 2', 66 | 'Programming Language :: Python :: 2.7', 67 | 'Programming Language :: Python :: 3', 68 | 'Programming Language :: Python :: 3.3', 69 | 'Programming Language :: Python :: 3.4', 70 | ], 71 | ) 72 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inmagik/django-rest-admin/61c0d1a993ebcf144352e0ee0f916d9e63c1ccf7/tests/__init__.py -------------------------------------------------------------------------------- /tests/test_models.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | test_django-rest-admin 6 | ------------ 7 | 8 | Tests for `django-rest-admin` models module. 9 | """ 10 | 11 | from django.test import TestCase 12 | 13 | from django_rest_admin import models 14 | 15 | 16 | class TestDjango_rest_admin(TestCase): 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def test_something(self): 22 | pass 23 | 24 | def tearDown(self): 25 | pass 26 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py27, py33, py34 3 | 4 | [testenv] 5 | setenv = 6 | PYTHONPATH = {toxinidir}:{toxinidir}/django_rest_admin 7 | commands = python runtests.py 8 | deps = 9 | -r{toxinidir}/requirements-test.txt 10 | --------------------------------------------------------------------------------