From 8c0ededb165c44397ccbd028f34399865207e56c Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 9 Dec 2015 22:02:27 +0000 Subject: [PATCH] Init project, mostly from template --- build | 6 +++ django_client_reverse/__init__.py | 0 django_client_reverse/tests.py | 11 +++++ django_client_reverse/urls.py | 5 ++ django_client_reverse/views.py | 10 ++++ manage.py | 10 ++++ requirements.txt | 3 ++ setup.py | 81 +++++++++++++++++++++++++++++++ testsettings.py | 24 +++++++++ 9 files changed, 150 insertions(+) create mode 100644 build create mode 100644 django_client_reverse/__init__.py create mode 100644 django_client_reverse/tests.py create mode 100644 django_client_reverse/urls.py create mode 100644 django_client_reverse/views.py create mode 100755 manage.py create mode 100644 requirements.txt create mode 100644 setup.py create mode 100644 testsettings.py diff --git a/build b/build new file mode 100644 index 0000000..7fd9bd0 --- /dev/null +++ b/build @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +pyvenv-3.4 env +env/bin/pip install -r requirements.txt --upgrade diff --git a/django_client_reverse/__init__.py b/django_client_reverse/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django_client_reverse/tests.py b/django_client_reverse/tests.py new file mode 100644 index 0000000..a19d405 --- /dev/null +++ b/django_client_reverse/tests.py @@ -0,0 +1,11 @@ +from rest_framework.test import APITestCase +from django.core.urlresolvers import reverse + + +class ReverserTestCase(APITestCase): + def setUp(self): + super().setUp() + + def test_thing(self): + response = self.client.get(reverse('reverser')) + print(response) diff --git a/django_client_reverse/urls.py b/django_client_reverse/urls.py new file mode 100644 index 0000000..8271555 --- /dev/null +++ b/django_client_reverse/urls.py @@ -0,0 +1,5 @@ +from django.conf.urls import include, url +from .views import Reverser +urlpatterns = [ + url(r'^$', Reverser.as_view(), name="reverser") +] diff --git a/django_client_reverse/views.py b/django_client_reverse/views.py new file mode 100644 index 0000000..e1f3032 --- /dev/null +++ b/django_client_reverse/views.py @@ -0,0 +1,10 @@ +from rest_framework.views import APIView +from rest_framework.response import Response +from rest_framework.renderers import JSONRenderer + + +class Reverser(APIView): + renderer_classes = (JSONRenderer,) + + def get(self, request, format=None): + return Response("Response") diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..819d703 --- /dev/null +++ b/manage.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testsettings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..cb90890 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +Django==1.8.7 +djangorestframework==3.3.1 +dj-database-url==0.3.0 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..6876d06 --- /dev/null +++ b/setup.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from __future__ import print_function +from setuptools import setup +import re +import os +import sys + + +name = 'django-client-reverse' +package = 'django_client_reverse' +description = 'Django module to access URL reversing client-side' +url = 'https://github.com/RealOrangeOne/' +author = 'TheOrangeOne' +author_email = 'git@theorangeone.net' +license = 'BSD' +install_requires = [ + "Django>=1.8", + "djangorestframework>=3.3.0", +] + +long_description = description + +def get_version(package): + """ + Return package version as listed in `__version__` in `init.py`. + """ + init_py = open(os.path.join(package, '__init__.py')).read() + return re.search("^__version__ = ['\"]([^'\"]+)['\"]", init_py, re.MULTILINE).group(1) + + +def get_packages(package): + """ + Return root package and all sub-packages. + """ + return [dirpath + for dirpath, dirnames, filenames in os.walk(package) + if os.path.exists(os.path.join(dirpath, '__init__.py'))] + + +def get_package_data(package): + """ + Return all files under the root package, that are not in a + package themselves. + """ + walk = [(dirpath.replace(package + os.sep, '', 1), filenames) + for dirpath, dirnames, filenames in os.walk(package) + if not os.path.exists(os.path.join(dirpath, '__init__.py'))] + + filepaths = [] + for base, filenames in walk: + filepaths.extend([os.path.join(base, filename) + for filename in filenames]) + return {package: filepaths} + + +if sys.argv[-1] == 'publish': + os.system("python setup.py sdist upload") + args = {'version': get_version(package)} + print("You probably want to also tag the version now:") + print(" git tag -a %(version)s -m 'version %(version)s'" % args) + print(" git push --tags") + sys.exit() + + +setup( + name=name, + version=get_version(package), + url=url, + license=license, + description=description, + long_description=long_description, + author=author, + author_email=author_email, + packages=get_packages(package), + package_data=get_package_data(package), + install_requires=install_requires, + classifiers=[ + ] +) diff --git a/testsettings.py b/testsettings.py new file mode 100644 index 0000000..0777c65 --- /dev/null +++ b/testsettings.py @@ -0,0 +1,24 @@ +import os + +import dj_database_url +DATABASES = {'default': dj_database_url.config(default="sqlite://memory")} + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.sessions', + 'django.contrib.contenttypes', + 'django_client_reverse' +) + +MIDDLEWARE_CLASSES = ( + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +) + +SECRET_KEY = 'abcde12345' + +ROOT_URLCONF = 'django_client_reverse.urls'