Skip to content

Commit

Permalink
Merge pull request #3 from amymok/2-django
Browse files Browse the repository at this point in the history
Change the project to a Django Project
  • Loading branch information
amymok authored Jun 7, 2017
2 parents afc7cfa + 6f3030d commit 4dcb393
Show file tree
Hide file tree
Showing 21 changed files with 434 additions and 30 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.env
*.pyc
*.pyc
db.sqlite3
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This project does not use `CHANGELOG.md` to track release changes.

See the project repository release history at:

https://github.com/cfpb/ccdb5-api/releases
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Public domain

The project is in the public domain within the United States, and
copyright and related rights in the work worldwide are waived through
the [CC0 1.0 Universal public domain dedication][CC0].

All contributions to this project will be released under the CC0
dedication. By submitting a pull request, you are agreeing to comply
with this waiver of copyright interest.

[CC0]: http://creativecommons.org/publicdomain/zero/1.0/
121 changes: 121 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
Creative Commons Legal Code

CC0 1.0 Universal

CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.

Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.

For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.

1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:

i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.

2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.

3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.

4. Limitations and Disclaimers.

a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
61 changes: 36 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
# ccdb5-api
Experimenting building python modules that query elasticsearch
ccdb5-api
================

This repository assumes that you have an instance of elasticsearch running with complaint data set up and running.
An API that provides an interface to search complaint data.

## Features

* Search complaint data
* Suggest complaint data based on input
* Get complaint based on ID

## Requirements

## Installation
Requirements are retrieved and/or build automatically via pip (see below).

### As a Standalone
* django - Web framework
* djangorestframework - Rest API framework
* elasticsearch - low level client for Elasticsearch
* requests - http requests to get different data format
* urllib3 - http client library to help format http URL

## API Docs

TBD

## Setup & Running
This repository assumes that you have an instance of elasticsearch running with complaint data set up and running.

#### Environment Variables
### Environment Variables
This project uses environment variables and uses autoenv to automatically define environment variables and launch the virtualenv upon cding to the project folder.

You will need to install Autoenv if you haven't:
Expand All @@ -34,29 +53,21 @@ brew info autoenv

You can then copy the `.env_SAMPLE` file to `.env`, then update any environment variables accordingly.

#### Dependencies
Then you can install all dependencies in the `requirements.txt`
```shell
pip install -r requirements.txt
```
### Dependencies
This project uses `requirements.txt` files for defining dependencies, so you
can get up and running with `pip`:

#### Testing
Right now you can run `complaint_search.py` to make sure everything runs successfully
```
python complaint_search.py
```shell
$ pip install -r requirements.txt # modules required for execution
```

### As a Package
If you are installing this project as a package, you can pip install the following:
With that, you just need a few additional commands to get up and running:
```shell
pip install -e git+https://github.com/cfpb/ccdb5-api.git@master#egg=ccdb5-api
$ python manage.py runserver
```

This also assume that you have all the environment variables in your system, if not, please incorporate the environement variables in `.env` in your own project to make `complaint_search` works for you.
## Running Tests

Once you pip installed this as a package you can use functions like so in your project:
```python
import complaint_search

complaint_search.search()
```
```shell
$ python manage.py test
```
62 changes: 62 additions & 0 deletions TERMS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
As a work of the United States Government, this package (excluding any
exceptions listed below) is in the public domain within the United States.
Additionally, we waive copyright and related rights in the work worldwide
through the [CC0 1.0 Universal public domain dedication][CC0].

Software source code previously released under an open source license and then
modified by CFPB staff or its contractors is considered a "joint work"
(see 17 USC § 101); it is partially copyrighted, partially public domain,
and as a whole is protected by the copyrights of the non-government authors and
must be released according to the terms of the original open-source license.
Segments written by CFPB staff, and by contractors who are developing software
on behalf of CFPB are also in the public domain, and copyright and related
rights for that work are waived through the CC0 1.0 Universal dedication.

For further details, please see the CFPB [Source Code Policy][policy].


## CC0 1.0 Universal Summary

This is a human-readable summary of the [Legal Code (read the full text)][CC0].

### No Copyright

The person who associated a work with this deed has dedicated the work to
the public domain by waiving all of his or her rights to the work worldwide
under copyright law, including all related and neighboring rights, to the
extent allowed by law.

You can copy, modify, distribute and perform the work, even for commercial
purposes, all without asking permission. See Other Information below.

### Other Information

In no way are the patent or trademark rights of any person affected by CC0,
nor are the rights that other persons may have in the work or in how the
work is used, such as publicity or privacy rights.

Unless expressly stated otherwise, the person who associated a work with
this deed makes no warranties about the work, and disclaims liability for
all uses of the work, to the fullest extent permitted by applicable law.
When using or citing the work, you should not imply endorsement by the
author or the affirmer.

[policy]: https://github.com/cfpb/source-code-policy/
[CC0]: http://creativecommons.org/publicdomain/zero/1.0/legalcode


## Exceptions

- [box-sizing Polyfill](http://github.com/Schepp/box-sizing-polyfill) by
Christian Schepp Schaefer is licensed under LGPL 3.0.
- [HTML5 Shiv](https://github.com/aFarkas/html5shiv) by Alexander Farkas,
et al., is licensed under MIT/GPL2.
- [jQuery](http://jquery.com/) by The jQuery Foundation is licensed under the
MIT License.
- [Modernizr](https://github.com/Modernizr/Modernizr) by Faruk Ateş, et al.,
is licensed under MIT License.
- [Normalize](http://necolas.github.io/normalize.css/) by Nicolas Gallagher,
co-created with Jonathan Neal, is licensed under the MIT License.
- [PDFreactor v6.3](http://www.pdfreactor.com/) by realObjects.
- [Slick](http://kenwheeler.github.io/slick/) by Ken Wheeler is licensed under
the MIT License.
Empty file added ccdb5_api/__init__.py
Empty file.
105 changes: 105 additions & 0 deletions ccdb5_api/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
"""
Django settings for ccdb5_api project.
Generated by 'django-admin startproject' using Django 1.8.18.
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
from django.utils.crypto import get_random_string

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 = os.environ.get('DJANGO_SECRET_KEY', get_random_string(50))

# 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',
'complaint_search',
)

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 = 'ccdb5_api.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 = 'ccdb5_api.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/'
Loading

0 comments on commit 4dcb393

Please sign in to comment.