Biosensor is a django based web app built as an open source project under a MIT license
- SSH into the server:
ssh biosensor.dk
- Change directory:
cd /var/www/biosensor
- Change user to pernye:
sudo su pernye
(if you are not already pernye) - Check out the production branch:
git checkout production
(if not already on that branch) - Pull the latest changes from GitHub:
git pull origin production
- Build the static assets using Gulp:
npm start build
- Migrate the database (if something changed in the model):
- Activate the virtual env
. .venv/bin/activate
- Migrate the database
./manage.py migrate
- Restart the apache2 webserver
sudo service apache2 restart
You need to have these installed on your development machine and on the server
- python3
- postgres (used for staging and production)
- sqlite (used for development only)
- node
- virtualenv
cd
into the project root dir
virtualenv -p python3 .venv
initialise python 3 virtual environment
. .venv/bin/activate
start the virtual environment
pip install -r requirements.txt
install required python modules (in production)
pip install -r requirements_dev.txt
install required python modules (as developer)
npm install
install required node modules
export DJANGO_SETTINGS_MODULE=biosensor.settings
tell django where to find the configuration file
./manage.py migrate
initialise the postgress database
./manage.py createsuperuser
create admin user
./manage.py runserver
start the app
You can now sign into the Django admin interface by going to /admin
. Go to "Sites" and update the example site with your own domain name.
Be sure to set the following environment variables when setting up the app for staging or production:
export DJANGO_ENV={development|staging|production}
set up the app to run in development, staging or production mode
export SECRET_KEY=[random string of characters]
a secret key used to provide cryptographic signing
export DATABASE_URL=postgres://username:password@server:port/databasename
database connection information
In order for email notifications to be sent out, the following environment variables need to be set:
SMTP_SERVER
the host to use for sending email
SMTP_LOGIN
password to use for the SMTP server defined in SMTP_SERVER
SMTP_PASSWORD
username to use for the SMTP server defined in SMTP_SERVER
SMTP_PORT
port to use for the SMTP server defined in SMTP_SERVER
- Django python based web app framework
- Node javascript runtime
- NPM javascript package manager
- Gulp build system
- Sass css preprocessor
- Bootstrap 4 css framework
cd
into the project root dir and run
. .venv/bin/activate && ./manage.py runserver
If you make changes to one of the models, make sure to also migrate the database to reflect your changes.
cd
into the project root dir and run
. .venv/bin/activate
./manage.py makemigrations
create new migrations based on the changes you have made to your models.
./manage.py migrate
apply migrations to update the database
We recommend setting up continous deployment using github webhooks so any changes pushed to master and/or production branch are automatically reflected on the server.
We use Wagtail to serve all content pages, including the welcome text on the front page. You can access Wagtail at /cms
and then go through the following steps to start setting up the necessary content pages:
- First go Settings->Sites and delete the example site that has already been set up.
- Create a new site named Biosensor as well as the Host and Port that you will be hosting Biosensor from (usually
localhost
and8000
during development). Pick the page that has already been created as the root page for the site. - Next go to the root page by clicking "Explorer" in the menu. First rename the root page to something more sensible, e.g. "Root page".
- Then create a child page of the root page and name it "Front" (make sure that the slug of this page is “front”, by going to the "Promote" tab - this will ensure that it gets displayed on the front page as the welcome text).
- You can now go on and create more child pages of the root page to set up the pages needed in the main menu.
The menu is hard-coded within the div with the navbar-nav
class in base.html
Change the file ID e.g. IvUU8joBb1Q
between embed/
and ?
here on this line
The MIT License (MIT)
Copyright © 2016
Biotech Academy
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.