Skip to content

Commit

Permalink
Merge pull request #20 from awaisdar001/get-distinc-records
Browse files Browse the repository at this point in the history
Restructure APP
  • Loading branch information
awaisdar001 committed Oct 26, 2020
2 parents 91b0a4a + 339a85b commit 397cf1f
Show file tree
Hide file tree
Showing 45 changed files with 139 additions and 18 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
npm-debug.log
README.md
LICENSE
.babelrc
.eslintignore
.eslintrc.json
.gitignore
.npmignore
commitlint.config.js
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN apt-get update && apt-get install -y python3-setuptools \
RUN pip3 install --upgrade pip
# Install pip requirements
#ADD requirements.txt .
RUN python -m pip install -r trips/requirements.txt
RUN python -m pip install -r requirements.txt



Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.DEFAULT_GOAL := test
NODE_BIN=$(CURDIR)/node_modules/.bin
MANAGE_PY_PATH = python trips/manage.py
MANAGE_PY_PATH = python manage.py

.PHONY: requirements update_db random_trips static help test build pull \
_build stop run restart attach shell destroy

requirements: ## install development environment requirements
pip install -qr trips/requirements.txt --exists-action w
pip install -qr requirements.txt --exists-action w

update_db: ## Install migrations
$(MANAGE_PY_PATH) migrate
Expand All @@ -22,7 +22,7 @@ help: ## display this help message
@grep '^[a-zA-Z]' $(MAKEFILE_LIST) | sort | awk -F ':.*?## ' 'NF==2 {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'

test: ## Run unit tests for Trips app
cd trips; pytest -v
pytest -v

build: destroy _build

Expand Down Expand Up @@ -58,6 +58,7 @@ _move:
rm -rf src/django_trips
cp {setup.py,setup.cfg,README.md,MANIFEST.in,LICENSE} src/
cp -R trips/django_trips src/

publish: _move
python3 -m pip install --user --upgrade twine
cd src/; python3 setup.py sdist bdist_wheel; python3 -m twine upload --skip-existing --repository pypi dist/* --verbose
Expand Down
3 changes: 3 additions & 0 deletions django-trips/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Your project description goes here.
"""
2 changes: 1 addition & 1 deletion trips/trips/asgi.py → django-trips/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'trips.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django-trips.settings')

application = get_asgi_application()
4 changes: 2 additions & 2 deletions trips/trips/settings.py → django-trips/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'trips.urls'
ROOT_URLCONF = 'django-trips.urls'

TEMPLATES = [
{
Expand All @@ -72,7 +72,7 @@
},
]

WSGI_APPLICATION = 'trips.wsgi.application'
WSGI_APPLICATION = 'django-trips.wsgi.application'

# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion trips/trips/wsgi.py → django-trips/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'trips.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django-trips.settings')

application = get_wsgi_application()
7 changes: 7 additions & 0 deletions django_trips/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
Your App description goes here.
"""

__version__ = '0.2.7.6'

default_app_config = 'django_trips.apps.DjangoTripsConfig' # pylint: disable=invalid-name
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions trips/django_trips/api/views.py → django_trips/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ class TripListCreateAPIView(generics.ListCreateAPIView):
Examples:
/api/trips/?
destination=islamabad%2Clahore%2Cfairy+meadows&name=trip
destination=islamabad,lahore,fairy+meadows
&name=trip
&duration_from=1&duration_to=15
&price_from=500&price_to=8000
&date_from=2020-10-21&date_to=2020-11-11
"""

authentication_classes = [SessionAuthentication, BasicAuthentication]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
# - mysql_data:/var/lib/mysql

trips:
command: bash -c 'while true; do python trips/manage.py runserver 0.0.0.0:8000; sleep 2; done'
command: bash -c 'while true; do python manage.py runserver 0.0.0.0:8000; sleep 2; done'
container_name: djangotrips.django
depends_on:
- tripsdb
Expand Down
2 changes: 1 addition & 1 deletion trips/manage.py → manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'trips.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django-trips.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand Down
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
DJANGO_SETTINGS_MODULE=django-trips.settings
python_files = test_*.py
File renamed without changes.
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[metadata]
name = django-trips
version = 0.2.7.5
description = A Django Rest API for fetching and creating trips and their schedules.
long_description = file: README.md
url = https://github.com/awaisdar001/django-trips
Expand Down
105 changes: 103 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,106 @@
from setuptools import setup
import os
import re

from setuptools import setup, setup, find_packages

README = open(os.path.join(os.path.dirname(__file__), 'README.md')).read()


def get_version(*file_paths):
"""
Extract the version string from the file at the given relative path fragments.
"""
filename = os.path.join(os.path.dirname(__file__), *file_paths)
version_file = open(filename).read()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError('Unable to find version string.')


def package_data(pkg, root_list):
"""
Generic function to find package_data for `pkg` under `root`.
"""
data = []
for root in root_list:
for dirname, _, files in os.walk(os.path.join(pkg, root)):
for fname in files:
data.append(os.path.relpath(os.path.join(dirname, fname), pkg))

return {pkg: data}


def is_requirement(line):
"""
Return True if the requirement line is a package requirement.
Returns:
bool: True if the line is not blank, a comment, a URL, or an included file
"""
return not (
line == '' or
line.startswith('-r') or
line.startswith('#') or
line.startswith('-e') or
line.startswith('git+')
)


def load_requirements(*requirements_paths):
"""
Load all requirements from the specified requirements files.
Returns:
list: Requirements file relative path strings
"""
requirements = set()
for path in requirements_paths:
requirements.update(
line.split('#')[0].strip() for line in open(path).readlines()
if is_requirement(line.strip())
)
return list(requirements)


VERSION = get_version('django_trips', '__init__.py')

setup(
long_description_content_type='text/markdown'
name='django - trips',
version=VERSION,
description='A Django Rest API for fetching and creating trips and their schedules.',
long_description=README,
long_description_content_type='text/markdown',
url='https://github.com/awaisdar001/django-trips',
author='Awais Jibran',
author_email='[email protected]',
license='MIT License',
keywords='Django trips',
packages=['django_trips'],
install_requires=['setuptools'],
classifiers=[
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 2.2',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
include_package_data=True,
package_data=package_data("django_trips", ["static"]),
entery_points={
'django_trips': [
'django_trips = django_trips'
]
},

)
Empty file.
3 changes: 0 additions & 3 deletions trips/pytest.ini

This file was deleted.

Empty file removed trips/trips/__init__.py
Empty file.

0 comments on commit 397cf1f

Please sign in to comment.