Skip to content

Commit 8d795e5

Browse files
committed
Merge pull request #48 from akbargumbira/master
Merging develop to master (version 0.1.1)
2 parents f0c4781 + 610e480 commit 8d795e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+11741
-5
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Created by .gitignore support plugin (hsz.mobi)
2+
.idea
3+
*.pyc
4+
dist
5+
distribute*
6+
MANIFEST
7+
django_user_map.egg-info/

.travis.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
language: python
2+
3+
python:
4+
- 2.7
5+
6+
install:
7+
- sudo apt-get update -qq
8+
- sudo apt-get install -y pylint pep8 libproj-dev libgeos-dev
9+
- pip install -r requirements.txt
10+
- pip install coverage
11+
12+
before_script:
13+
- psql -c 'create database test_db;' -U postgres
14+
- psql -c 'CREATE EXTENSION postgis;' -U postgres -d test_db
15+
16+
script:
17+
- pep8 . --exclude=migrations
18+
- coverage run --source=user_map setup.py test
19+
20+
after_success:
21+
- pip install coveralls
22+
- coveralls
23+
24+
email:
25+
- tim@kartoza.com
26+
- akbargumbira@gmail.com

LICENSE.txt

Lines changed: 503 additions & 0 deletions
Large diffs are not rendered by default.

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include README.md
2+
include LICENSE.txt
3+
include requirements.txt
4+
recursive-include user_map/static *
5+
recursive-include user_map/templates *

README.md

Lines changed: 174 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,177 @@
1-
inasafe-user-map
2-
================
1+
Django User Map
2+
=================
33

4-
A django application for our user's map
4+
[![Develop Branch](https://api.travis-ci.org/AIFDR/inasafe-user-map.svg?branch=develop)](https://travis-ci.org/AIFDR/inasafe-user-map)
5+
[![Coverage Status](https://coveralls.io/repos/AIFDR/inasafe-user-map/badge.png?branch=develop)](https://coveralls.io/r/AIFDR/inasafe-user-map?branch=develop)
56

6-
This project replaces the simple flask based user map available here:
7+
A django application for making community user's map. Users can
8+
add themselves on the map by providing some information:
9+
10+
1. Name
11+
2. E-mail - will be used for authentication
12+
3. Password - will be used for authentication
13+
4. Website
14+
5. Role - The choices can be configured through setting.
15+
6. Location on the map
16+
17+
Live site: http://users.inasafe.org
18+
19+
Installation
20+
============
21+
1. Install django-user-map with pip:
22+
```
23+
pip install django-user-map
24+
```
25+
26+
2. Make sure you have all of these items in INSTALLED_APPS of your django
27+
project settings.py:
28+
```
29+
INSTALLED_APPS = (
30+
'django.contrib.admin',
31+
'django.contrib.auth',
32+
'django.contrib.contenttypes',
33+
'django.contrib.sessions',
34+
'django.contrib.messages',
35+
'django.contrib.staticfiles',
36+
'django.contrib.gis',
37+
'user_map',
38+
'leaflet',
39+
'bootstrapform'
40+
)
41+
```
42+
43+
3. Include user-map URLconf in your project urls.py e.g:
44+
```
45+
url(r'^user-map/', include('user_map.urls')),
46+
```
47+
48+
3. Add authentication user model and authentication backend in your django
49+
project settings.py:
50+
```
51+
AUTH_USER_MODEL = 'user_map.User'
52+
AUTHENTICATION_BACKENDS = [
53+
'user_map.auth_backend.UserMapAuthBackend',
54+
'django.contrib.auth.backends.ModelBackend']
55+
```
56+
57+
4. Make sure to add template context processors needed by user-map:
58+
```
59+
TEMPLATE_CONTEXT_PROCESSORS = (
60+
'django.contrib.auth.context_processors.auth',
61+
'django.core.context_processors.request',
62+
'django.contrib.messages.context_processors.messages',
63+
'user_map.context_processors.user_map_settings',
64+
)
65+
```
66+
67+
5. Make sure to add mail server configuration on your project's settings.py
68+
so that this apps can send e-mail for some routines e.g sending confirmation
69+
e-mail after registration. If you are going to use SMTP server using your
70+
Gmail account, the configuration looks like this:
71+
```
72+
EMAIL_USE_TLS = True
73+
EMAIL_HOST = 'smtp.gmail.com'
74+
EMAIL_PORT = 587
75+
EMAIL_HOST_USER = 'YOUR GMAIL ADDRESS'
76+
EMAIL_HOST_PASSWORD = 'YOUR GMAIL PASSWORD'
77+
DEFAULT_FROM_MAIL = 'MAIL ADDRESS AS THE DEFAULT SENDER'
78+
```
79+
80+
6. Run ```python manage.py migrate``` to create the user_map models.
81+
82+
7. Create a superuser so that you can log in to django admin to administer
83+
user:
84+
```python manage.py createsuperuser```
85+
86+
7. Run ```python manage.py runserver``` to start the development server.
87+
88+
8. Visit http://127.0.0.1:8000/user-map/ to open the apps.
89+
90+
9. Visit your admin page (the default is http://127.0.0.1:8000/admin) to
91+
manage user as an admin.
92+
93+
94+
Apps Configurations
95+
==================
96+
97+
Tile Layer
98+
------------
99+
100+
You can configure the basemap of the form that uses LeafletWidget and the
101+
basemap of the homepage by adding 'LEAFLET_CONFIG' in settings.py e.g:
102+
```
103+
LEAFLET_CONFIG = {
104+
'TILES': [
105+
(
106+
'OpenStreetMap', # The title
107+
'http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', # The tile URL
108+
('© <a href="http://www.openstreetmap.org" '
109+
'target="_parent">OpenStreetMap</a> and contributors, under an '
110+
'<a href="http://www.openstreetmap.org/copyright" '
111+
'target="_parent">open license</a>') # The attribution
112+
)]
113+
}
114+
```
115+
116+
Configurable variables
117+
----------------------
118+
119+
You can also configure some variables by adding these items on your
120+
django settings.py:
121+
122+
1. USER_MAP_PROJECT_NAME (string). This variable represents the project name of
123+
the apps. If this is not specified, 'InaSAFE' will be used.
124+
125+
2. USER_MAP_BRAND_LOGO (string). This variable represents the file path to
126+
the brand logo in navigation bar. If not specified,
127+
'user_map/img/logo.png' will be used.
128+
129+
3. USER_MAP_FAVICON_FILE (string). This variable represents the file path to
130+
the favicon on the browser's tab. If not specified,
131+
the default is 'user_map/img/user-icon.png'
132+
133+
4. USER_MAP_USER_ROLES (list of dictionary). Using this variable,
134+
you can specify the user's role and the icon path for the role. If not
135+
specified, this variable will take this as the default:
136+
```
137+
default_user_roles = [
138+
dict(
139+
name='User',
140+
icon='user_map/img/user-icon.png',
141+
shadow_icon='user_map/img/shadow-icon.png'),
142+
dict(
143+
name='Trainer',
144+
icon='user_map/img/trainer-icon.png',
145+
shadow_icon='user_map/img/shadow-icon.png'),
146+
dict(
147+
name='Developer',
148+
icon='user_map/img/developer-icon.png',
149+
shadow_icon='user_map/img/shadow-icon.png')]
150+
```
151+
While you can add as many roles as you want, note that we only create
152+
three css classes for the marker clusterer (it makes clusters of users
153+
based on the role). If you want to have more than three roles,
154+
you need to add these two classes with this pattern:
155+
```
156+
.marker-cluster-role4 {
157+
background-color: rgba(253, 156, 115, 0.6);
158+
}
159+
.marker-cluster-role4 div {
160+
background-color: rgba(241, 128, 23, 0.6);
161+
}
162+
```
163+
164+
165+
Testing
166+
--------
167+
168+
You can run the test suite by using django manage.py from your django project:
169+
```
170+
python manage.py test user_map
171+
```
172+
173+
or you can do it from the root of this django apps by running:
174+
```
175+
python setup.py test
176+
```
7177
8-
https://github.com/timlinux/flask_user_map

create_test_package.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
echo "This script will create a test package in dist/"
3+
echo "Have you updated changelog?"
4+
echo "Have you updated the version in setup.py?"
5+
echo "Have you updated README & Docs?"
6+
read -sn 1 -p "Press any key to continue..."
7+
python setup.py sdist
8+
9+
echo "Check the contents now with tar -tvf dist/inasafe-user-map-<version>.tar.gz"

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Django==1.7
2+
django-leaflet==0.14.1
3+
psycopg2==2.5.4
4+
factory-boy==2.4.1
5+
django-bootstrap-form==3.1

setup.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# coding=utf-8
2+
"""Setup file for distutils / pypi."""
3+
try:
4+
from ez_setup import use_setuptools
5+
use_setuptools()
6+
except ImportError:
7+
pass
8+
9+
from setuptools import setup, find_packages
10+
11+
setup(
12+
name='django-user-map',
13+
version='0.1.1',
14+
author='Akbar Gumbira',
15+
author_email='akbargumbira@gmail.com',
16+
packages=find_packages(),
17+
include_package_data=True,
18+
zip_safe=False,
19+
scripts=[],
20+
url='http://pypi.python.org/pypi/django-user-map/',
21+
license='LICENSE.txt',
22+
description=('A simple app for creating a community user map in your '
23+
'django web site.'),
24+
long_description=open('README.md').read(),
25+
install_requires=[
26+
"Django==1.7",
27+
"django-leaflet==0.14.1",
28+
"psycopg2==2.5.4",
29+
"factory-boy==2.4.1",
30+
"django-bootstrap-form==3.1",
31+
],
32+
test_suite='user_map.run_tests.run',
33+
)

upload-to-pypi.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
echo "Have you updated changelog?"
4+
echo "Have you updated the version in setup.py?"
5+
echo "Have you updated README & Docs?"
6+
read -sn 1 -p "Press any key to continue..."
7+
echo
8+
9+
VERSION=`cat setup.py | grep version | grep -o "[0-9}*\.[0-9]*\.[0-9]*"`
10+
TAG_VERSION=`echo $VERSION| sed 's/\./_/g'`
11+
echo "Version: " $VERSION
12+
echo "Tag Version: " $TAG_VERSION
13+
git tag -s version-$TAG_VERSION -m "Version $VERSION"
14+
git push --tags origin version-$TAG_VERSION
15+
16+
python setup.py sdist upload

user_map/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)