olivierlefloch/django-short-urls — pull request #10 by vmeyet (2013-08-22 17:28:45+00:00)
Title: REC-154 logic change for short_path_redirection

## to test

- go to lab3
- `git clone git@github.com:olivierlefloch/django-short-urls.git`
- `cd django-short-urls`
- `git co vmeyet/REC-154/add_tracking_to_workforus__COMPANY__share`
- `cp django_short_url/local_settings.tpl.py django_short_url/local_settings.py`
- `vim django_short_url/local_settings.py`

then add your mongo connection settings:

```
MONGOENGINE = {
'db': 'work4labs',
'host': 'localhost',
'port': 27017,
'username': 'work4labs',
'password': 'work4labs'
}
```
- `./manage.py test`, everything should be ok
- `./manage.py shell`

create a user/api_key
```
In [1]: import django_short_urls.models

In [2]: from django_short_urls.models import User

In [3]: User(login='login', api_key='toto', email='login@work4labs.com').save()
Out[3]:
```

- `./manage.py runserver 10080` in one terminal
- launch different commands with curl or better [httpie](https://github.com/jkbr/httpie)

Output:

```
15:43 lab3 ~/work4us (REC-162 ✔) http -f POST localhost:10080/api/v1/new api_key=toto login=login long_url=http://www.google.com prefix=Dark
HTTP/1.0 200 OK
Content-Type: application/json
Date: Thu, 22 Aug 2013 14:44:01 GMT
Server: WSGIServer/0.1 Python/2.7.5

{
"creator": "vmeyet",
"error": false,
"long_url": "http://www.google.com",
"message": null,
"prefix": "Dark",
"short_path": "8",
"short_url": "http://localhost:10080/Dark/8",
"status_code": 200
}

15:47 lab3 ~/work4us (REC-162 ✔) http -f POST localhost:10080/api/v1/new api_key=toto login=login long_url=http://www.google.fr\?q=match prefix=Dark
HTTP/1.0 200 OK
Content-Type: application/json
Date: Thu, 22 Aug 2013 15:47:50 GMT
Server: WSGIServer/0.1 Python/2.7.5

{
"creator": "vmeyet",
"error": false,
"long_url": "http://www.google.fr?q=match",
"message": null,
"prefix": "Dark",
"short_path": "9",
"short_url": "http://localhost:10080/Dark/9",
"status_code": 200
}

15:47 lab3 ~/work4us (REC-162 ✔) http http://localhost:10080/Dark/8
HTTP/1.0 302 FOUND
Content-Type: text/html; charset=utf-8
Date: Thu, 22 Aug 2013 14:44:17 GMT
Location: http://www.google.com
Server: WSGIServer/0.1 Python/2.7.5

15:47 lab3 ~/work4us (REC-162 ✔) http http://localhost:10080/Dark/8/recruiter
HTTP/1.0 302 FOUND
Content-Type: text/html; charset=utf-8
Date: Thu, 22 Aug 2013 15:47:58 GMT
Location: http://www.google.com?short_redirect=recruiter
Server: WSGIServer/0.1 Python/2.7.5

15:47 lab3 ~/work4us (REC-162 ✔) http http://localhost:10080/Dark/9/recruiter
HTTP/1.0 302 FOUND
Content-Type: text/html; charset=utf-8
Date: Thu, 22 Aug 2013 15:48:07 GMT
Location: http://www.google.fr?q=match&short_redirect=recruiter
Server: WSGIServer/0.1 Python/2.7.5

15:48 lab3 ~/work4us (REC-162 ✔) http http://localhost:10080/Dark/9/search
HTTP/1.0 302 FOUND
Content-Type: text/html; charset=utf-8
Date: Thu, 22 Aug 2013 15:48:20 GMT
Location: http://www.google.fr?q=match&short_redirect=search
Server: WSGIServer/0.1 Python/2.7.5

15:48 lab3 ~/work4us (REC-162 ✔) http http://localhost:10080/Dark/9/toto
HTTP/1.0 404 NOT FOUND
Content-Type: text/html
Date: Thu, 22 Aug 2013 15:48:26 GMT
Server: WSGIServer/0.1 Python/2.7.5
```