Skip to content

rapirent/smart_campus

Repository files navigation

Smart Campus

Build Status Coverage Status

Prerequistie

  • Python 3
  • PostgreSQL
  • PostGIS

Table of Content

  1. Install Software & Configure Environemnt
  2. Setup Setting Files
  3. Run Server
  4. Setup default data
  5. Testing

1. Install Software & Configure Environemnt

Software Installation

Environment Setup

  1. Create virtual enviroment

    $ virtualenv -p `which python3` venv
  2. Start up virtual environment

    $ source venv/bin/activate

    To exit virtual environment

    $ deactivate
  3. Install python dependencies

    • dev
    $ pip install -r requirements/dev.txt
  4. Set system locale to utf8

    export LC_ALL='en_US.utf8'

2. Setup settings files

Development

Define your own local_settings.py under smart_campus/smart_campus/settings/
This file will be and should be ignored by git.

The follwoing variables MUST be set up in the setting file.

  • SECRET_KEY
  • DATABASES

e.g.

# smart_campus/smart_campus/settings/local_settings.py

from .base import *


SECRET_KEY = 'This is the secret key'

DATABASES = {
    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        'NAME': 'db_name',
        'USER': 'db_user',
        'PASSWORD': 'db_pwd',
        'HOST': 'localhost',
        'PORT': '5432',
    },
}

Production

The following envrionment variables MUST be setup.

  • SECRET_KEY
  • POSTGRESQL_NAME
  • POSTGRESQL_USER
  • POSTGRESQL_PASSWORD
  • POSTGRESQL_HOST
  • POSTGRESQL_PORT
  • DJANGO_SETTINGS_MODULE

e.g.

$ export SECRET_KEY='Some hard to guess value'
$ export POSTGRESQL_NAME='db_name'
$ export POSTGRESQL_USER='user_name'
$ export POSTGRESQL_PASSWORD='user_pwd'
$ export POSTGRESQL_HOST='db_host'
$ export POSTGRESQL_PORT='db_port'
$ export DJANGO_SETTINGS_MODULE="smart_campus.settings.production"

Setup Mail Server (Needed to be done in each setting files)

Setup the mail user & password (using gmail in default) in settings/settings.py

  • EMAIL_HOST_USER
  • EMAIL_HOST_PASSWORD

Note that you will have to enable 'insecure access' in your gmail account.

3. Runserver

Development

python manage.py runserver --settings=smart_campus.settings.local_settings

Production

Nginx, uwsgi setup

Run uwsgi

Start
$ uwsgi --ini server-settings/smart_campus.ini
Stop
$ sudo killall -s INT uwsgi
View log
$ sudo tail -f /var/log/smartcampus/smartcampus.log

4. Setup default data

$ cd smart_campus
$ pwd
# smart_campus

Initial Default Roles

$ python3 manage.py initroles

Create Super User

$ python3 manage.py initroles

Insert Default Beacon Data

$ python3 manage.py load_beacon_data [file.xls]

5. Testing

Run Test

$ pytest

Note that test should be run in root directory instead of smart_campus.

LICENS

About

成功大學智慧校園導覽 App

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •