Skip to content

Commit

Permalink
Update README.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
Saeed Marzban committed May 15, 2018
1 parent 20a999e commit 6f8259a
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ Molo Global Site
:target: https://coveralls.io/github/praekeltfoundation/molo.globalsite?branch=develop
:alt: Code Coverage

Provides code to help with creating a global site and redirecting the users to the country of their choice using the Molo code base.
Provides code to help with identifying visitors’ locations and redirecting them to the relevant country site or the global site using the Molo code base.

Getting Started
==================

Installation::
Installation molo.globalsite package::

pip install molo.globalsite


In your app settings::
In your app settings add::

INSTALLED_APPS = (
'molo.globalsite',
Expand All @@ -26,9 +28,39 @@ In your app settings::
MIDDLEWARE = (
'molo.globalsite.middleware.CountrySiteRedirectMiddleware'
)
# Global Site URL
GLOBAL_SITE_URL = environ.get('GLOBAL_SITE_URL', '')
# A path to geoip database.
GEOIP_PATH = join(dirname(dirname(abspath(__file__))), 'geoip_db')

You can download the geoip database country database from `MaxMind`_ or copy it from molo/globalsite/geoip_db.

.. _MaxMind: http://dev.maxmind.com/geoip/legacy/geolite/#Downloads

In your app urls.py::
Add Global site URL in your app urls.py::

urlpatterns += patterns('',
url(r'^globalsite/', include('molo.globalsite.urls', namespace='molo.globalsite', app_name='molo.globalsite')),
)

Add the HTML block in your country site base template to enable users to change their country site::

{% block country %}
{% trans "Country" %}: {{request.site}}
<a href="{% url 'molo.globalsite:change_country' %}">{% trans "Change your country" %}</a>
{% endblock %}


How users are redirected?
=========================

The middleware redirects the user by checking the session. If the country site url is in the 'GLOBALSITE_COUNTRY_SELECTION' it will redirect the user to the country site, otherwise if the geolocation is activated it will uses user's IP address to detect their location and redirect the user to h a. if detached location is not available in the supported country sites or the geolocation is not activated it will serve the country site selection page.

GlobalSite Settings
===================


How to add country sites
========================

0 comments on commit 6f8259a

Please sign in to comment.