Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:akbargumbira/django-user-map
Browse files Browse the repository at this point in the history
  • Loading branch information
akbargumbira committed Mar 6, 2016
2 parents 486f82e + fa16f72 commit 786fbfe
Show file tree
Hide file tree
Showing 59 changed files with 1,410 additions and 2,073 deletions.
440 changes: 287 additions & 153 deletions README.md

Large diffs are not rendered by default.

Binary file added docs/img/with_nav.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/without_nav.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 8 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Django==1.7
django-leaflet==0.14.1
psycopg2==2.5.4
factory-boy==2.4.1
django-bootstrap-form==3.1
Django>=1.8
django-leaflet==0.18.0
psycopg2==2.6.1
factory-boy==2.6.0
django-bootstrap-form==3.2
djangorestframework==3.3.2
djangorestframework-gis==0.10.1
Pillow==3.1.1
17 changes: 11 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='django-user-map',
version='0.1.2',
version='1.0.0',
author='Akbar Gumbira',
author_email='[email protected]',
packages=find_packages(),
Expand All @@ -23,11 +23,16 @@
'django web site.'),
long_description=open('README.md').read(),
install_requires=[
"Django==1.7",
"django-leaflet==0.14.1",
"psycopg2==2.5.4",
"factory-boy==2.4.1",
"django-bootstrap-form==3.1",
"Django>=1.8",
"django-leaflet",
"psycopg2",
"django-bootstrap-form",
"djangorestframework",
"djangorestframework-gis",
"Pillow"
],
tests_require=[
"factory-boy>=2.4.1",
],
test_suite='user_map.run_tests.run',
)
25 changes: 7 additions & 18 deletions user_map/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,16 @@
"""Model Admin Class."""

from django.contrib.gis import admin
from leaflet.admin import LeafletGeoAdmin

from user_map.models import User, Role
from leaflet.admin import LeafletGeoAdmin

from user_map.models import UserMap, Role

class UserAdmin(LeafletGeoAdmin):
"""Admin Class for User Model."""
list_display = ('name', 'email', 'role', 'website', 'email_updates',
'last_login', 'is_confirmed', 'is_admin')
list_filter = ['role', 'is_confirmed', 'is_admin']
search_fields = ['name', 'email']
fieldsets = [
('Basic Information', {
'fields': [
'name', 'email', 'website', 'role', 'email_updates']}),
('Location', {'fields': ['location']}),
('Advanced Information', {
'fields': ['is_confirmed', 'is_active', 'is_admin', 'last_login']
}),
]

class UserMapAdmin(LeafletGeoAdmin):
"""Admin Class for User Map Model."""
model = UserMap
can_delete = False

admin.site.register(User, UserAdmin)
admin.site.register(UserMap, UserMapAdmin)
admin.site.register(Role)
133 changes: 91 additions & 42 deletions user_map/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,100 @@
..note: By design, you can override these settings from your project's
settings.py with prefix 'USER_MAP' on the variable e.g
'USER_MAP_USER_ICONS'.
For mailing. as the default, it wil use 'DEFAULT_FROM_MAIL' setting from
the project.
"""
from django.conf import settings

# PROJECT_NAME: The project name for this apps e.g InaSAFE
default_project_name = 'InaSAFE'
PROJECT_NAME = getattr(settings, 'USER_MAP_PROJECT_NAME', default_project_name)

# LOGO/BRAND
default_brand_logo = 'user_map/img/logo.png'
BRAND_LOGO = getattr(settings, 'USER_MAP_BRAND_LOGO', default_brand_logo)
# USER_MODEL: The auth user model is set in project's settings
USER_MODEL = settings.AUTH_USER_MODEL

# USER MAP Settings
default_setting = {
'project_name': 'Django',
'favicon_file': '',
'login_view': 'django.contrib.auth.views.login',
'marker': {
# See leaflet icon valid options here:
# http://leafletjs.com /reference.html#icon-iconurl
'iconUrl': 'static/user_map/img/user-icon.png',
'shadowUrl': 'static/user_map/img/shadow-icon.png',
'iconSize': [19, 32],
'shadowSize': [42, 35],
'iconAnchor': [10, 0],
'shadowAnchor': [12, 0],
},
'leaflet_config': {
'TILES': [(
# The title
'MapQuest',
# Tile's URL
'http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png',
# More valid leaflet option are passed here
# See here: http://leafletjs.com/reference.html#tilelayer
{
'attribution':
'© <a href="http://www.openstreetmap.org" '
'target="_parent">OpenStreetMap'
'</a> and contributors, under an <a '
'href="http://www.openstreetmap.org/copyright" '
'target="_parent">open license</a>. Tiles Courtesy of '
'<a '
'href="http://www.mapquest.com/">MapQuest</a> <img '
'src="http://developer.mapquest.com/content/osm/mq_logo'
'.png"',
'subdomains': '1234'

}
)]
},
'roles': [
{
'id': 1,
'name': 'Django User',
'badge': 'user_map/img/badge-user.png'
},
{
'id': 2,
'name': 'Django Trainer',
'badge': 'user_map/img/badge-trainer.png'
},
{
'id': 3,
'name': 'Django Developer',
'badge': 'user_map/img/badge-developer.png'
}
],
'api_user_fields': [
# e.g 'username', 'first_name', 'last_name'
],
}

user_map_settings = getattr(settings, 'USER_MAP', default_setting)

# PROJECT_NAME: The project name for this apps e.g InaSAFE
PROJECT_NAME = user_map_settings.get(
'project_name', default_setting['project_name'])

# FAVICON_FILE: Favicon for this apps
default_favicon_file = 'user_map/img/user-icon.png'
FAVICON_FILE = getattr(settings, 'USER_MAP_FAVICON_FILE', default_favicon_file)

# USER ROLES: All user roles and their icons
default_user_roles = [
dict(
name='User',
icon='user_map/img/user-icon.png',
shadow_icon='user_map/img/shadow-icon.png'),
dict(
name='Trainer',
icon='user_map/img/trainer-icon.png',
shadow_icon='user_map/img/shadow-icon.png'),
dict(
name='Developer',
icon='user_map/img/developer-icon.png',
shadow_icon='user_map/img/shadow-icon.png')]
USER_ROLES = getattr(settings, 'USER_MAP_USER_ROLES', default_user_roles)

# MAIL SENDER
default_mail_sender = '[email protected]'
DEFAULT_FROM_MAIL = getattr(settings, 'DEFAULT_FROM_MAIL', default_mail_sender)

# LEAFLET CONFIG
default_leaflet_tiles = (
'OpenStreetMap',
'http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',
('© <a href="http://www.openstreetmap.org" target="_parent">OpenStreetMap'
'</a> and contributors, under an <a '
'href="http://www.openstreetmap.org/copyright" target="_parent">open '
'license</a>')
)
LEAFLET_TILES = getattr(settings, 'LEAFLET_TILES', default_leaflet_tiles)
FAVICON_FILE = user_map_settings.get(
'favicon_file', default_setting['favicon_file'])


# LOGIN_VIEW: The view to the login page
LOGIN_VIEW = user_map_settings.get(
'login_view', default_setting['login_view'])

# MARKER
MARKER = user_map_settings.get(
'marker', default_setting['marker'])

LEAFLET_CONFIG = user_map_settings.get(
'leaflet_config', default_setting['leaflet_config'])
LEAFLET_TILES = LEAFLET_CONFIG['TILES']

# ROLES: All user roles and their badges
ROLES = user_map_settings.get('roles', default_setting['roles'])

# API_USER_FIELDS
API_USER_FIELDS = user_map_settings.get(
'api_user_fields', default_setting['api_user_fields'])
44 changes: 0 additions & 44 deletions user_map/auth_backend.py

This file was deleted.

17 changes: 0 additions & 17 deletions user_map/context_processors.py

This file was deleted.

40 changes: 40 additions & 0 deletions user_map/forms/custom_widget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from django.utils.safestring import mark_safe
from django.utils.html import escape, conditional_escape
from django.utils.encoding import force_unicode
from django.forms.widgets import ClearableFileInput, Input, CheckboxInput


class CustomClearableFileInput(ClearableFileInput):
"""A custom ClearableFileInput widget.
..note:: Adapted from django.forms.widgets.ClearableFileInput and also
utilising img-responsive bootstrap class.
"""
def render(self, name, value, attrs=None):
"""Render the custom widget."""
substitutions = {
'input_text': self.input_text,
'clear_template': '',
'clear_checkbox_label': self.clear_checkbox_label,
}
template = '%(input)s'
substitutions['input'] = Input.render(self, name, value, attrs)

if value and hasattr(value, "url"):
template = ('%(initial)s %(clear_template)s<br />%(input_text)s: '
'%(input)s')
substitutions['initial'] = (
'<img class="img-responsive" src="%s" alt="%s"/>' % (
escape(value.url), escape(force_unicode(value))))
if not self.is_required:
checkbox_name = self.clear_checkbox_name(name)
checkbox_id = self.clear_checkbox_id(checkbox_name)
substitutions['clear_checkbox_name'] = conditional_escape(
checkbox_name)
substitutions['clear_checkbox_id'] = conditional_escape(
checkbox_id)
substitutions['clear'] = CheckboxInput().render(
checkbox_name, False, attrs={'id': checkbox_id})
substitutions['clear_template'] = \
self.template_with_clear % substitutions
return mark_safe(template % substitutions)
Loading

0 comments on commit 786fbfe

Please sign in to comment.