See AWS.setup.rst for the Amazon Web Services setup guide.
Both Django and AngurlarJS used for url routing.
Angular and Django both use {{ and }} as variable delimiters, and thus the angular variable delimiters are renamed {$ and $}.
routes in SEED/urls/py
Amazon AWS S3 Expires headers should be set on the AngularJS partials if using S3 with the management command: set_s3_expires_headers_for_angularjs_partials
usage: python manage.py set_s3_expires_headers_for_angularjs_partials --verbosity=3
The default user invite reply-to email can be overridden in the BE/settings/common.py file. The SERVER_EMAIL settings var is the reply-to email sent along with new account emails.
# BE/settings/common.py
PASSWORD_RESET_EMAIL = 'reset@buildingenergy.com'
SERVER_EMAIL = 'no-reply@buildingenergy.com'For compatibility in partials with Django template tags (i.e. {{ and }}), we renamed AngularJS variable delimiters or curly braces to {$ and $}.
window.BE.apps.seed = angular.module('BE.seed', ['ngRoute', "ngCookies"], function ($interpolateProvider) {
$interpolateProvider.startSymbol("{$");
$interpolateProvider.endSymbol("$}");
}
);
For ease of making angular $http requests, we automatically add the CSFR token to all $http requests as recommended by http://django-angular.readthedocs.org/en/latest/integration.html#xmlhttprequest
window.BE.apps.seed.run(function ($http, $cookies) {
$http.defaults.headers.common['X-CSRFToken'] = $cookies['csrftoken'];
});
routes in static/seed/js/seed.js (the normal angularjs app.js)
window.BE.apps.seed.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: static_url + '/seed/partials/home.html'
})
.when('/projects', {
controller: 'project_list_controller',
templateUrl: static_url + '/seed/partials/projects.html'
})
.when('/buildings', {
templateUrl: static_url + '/seed/partials/buildings.html'
})
.when('/admin', {
controller: 'seed_admin_controller',
templateUrl: static_url + '/seed/partials/admin.html'
})
.otherwise({ redirectTo: '/' });
}]);
html partials in static/seed/partials/
on production and staging servers on AWS, or for the partial html templates loaded on S3, or a CDN, the external resource should be added to the white list in static/seed/js/seed/js
// white list for s3
window.BE.apps.seed.config(function( $sceDelegateProvider ) {
$sceDelegateProvider.resourceUrlWhitelist([
// localhost
'self',
// AWS s3
'https://be-*.amazonaws.com/**'
]);
});
JS tests can be run with Jasmine at the url app/angular_js_tests/
python manage.py test will run the python unit tests, we also use coverage
to check the ammount of SLOC covered under tests. The coverage config is
in .coveragerc
$ coverage run manage.py test --settings=BE.settings.ci
$ coverage report --fail-under=83flake8 will run the PEP8 compliance tests. Its config is in tox.ini
$ flake8jshint will run the JS compliance tests. The jshint config is in .jshintrc
$ jshint seed/static/seed/jsThe following two commands will run uwsgi and celeryd.
bin/start_uwsgi.sh
bin/start_celery.sh
In dev mode, you can start the Django dev server and celery:
./manage.py runserver
./manage.py celeryd -c 4 --loglevel=INFO -E --maxtasksperchild=1000
monitor background tasks flower --port=5555 --broker=redis://localhost:6379/1
assuming your redis broker is running on localhost and on port 6379, DB 1. Then goto localhost:5555 to check celery.
If running on AWS, the bin/start_flower.sh will start flower on port 8080 and be available for google credentialed buildingenergy.com accounts.
git clone git@github.com:buildingenergy/seed.git- install Postgres 9.3 and redis for cache and message broker
- use a virtualenv if desired
- create a
local_untracked.pyin theBE/settingsfolder and add CACHE and DB config (examplelocal_untracked.py.dist) export DJANGO_SETTINGS_MODULE=BE.settings.devpip install -r requirements.txt./manage syncdb./manage migrate./manage createsuperuser./manage runserver./manage celeryd- navaigate to
http://127.0.0.1:8000/app/#/profile/adminin your browser to add users to organizations- each user must belong to an organization!
- main app runs at
127.0.0.1:8000/app
see license
