Skip to content

glizzan/kybern

Repository files navigation

Kybern

Kybern is a prototype website built using Concord, a framework for implementing user-controlled permissions and governance structures. It showcases the functionality of Concord (and also allows developers to test that they've successfully built mechanisms for extensbility into Concord). The alpha prototype is live at Kybern.org. The site is currently neither secure or reliable, so please do not store important or private information on it.

This project is maintained by the Glizzan organization and surrounding community. To join, please email [email protected] to ask for an invite to our Zulip discussion space. Please note: this project uses the Contributor Covenant as our Code of Conduct, and by participating you agree to abide by its terms.

Kybern has been released under a custom license, the Concord Cooperative License. This license is more restrictive than a free software / open source software license. If you believe that your intended use might not fall under the terms of that license, please contact us to discuss alternatives

Installation

  1. Create a fork of this repository
  2. Go to the directory which contains your clone of the Concord repo. If you followed the installation instructions in the Concord repo, this directory is called 'Glizzan'.
  3. Clone your fork: git clone <your name>/kybern
  4. Change into the directory you just cloned: cd kybern
  5. Install postgres and set up the database (see instructions below) or swap the backend in settings.py by uncommenting the sqlite3 backend and commenting out the postgres backend.
  6. Create Python3 virtual environment: python3 -m venv testenv
  7. Activate the virtual environment: source testenv/bin/activate
  8. Check pip for upgrades: pip install --upgrade pip
  9. Install requirements: pip install -r requirements.txt
  10. Go to glizzan-concord and run the following command to create a package to install in Kybern: bash ./create_dist.sh
  11. Return to the kybern directory and install the newly created package: pip install ../glizzan-concord/dist/concord-0.0.1.tar.gz
  12. Change into subdirectory: cd kybern
  13. Run existing migrations: python manage.py migrate
  14. Start the server: python manage.py runserver

You should now be able to view the site.

Email & Registering Users

You will need to register on the site and then log in before you can use most of the functionality. Registration involves an email confirmation step, so before registering on the site you will need to set up a local email server. To do this, open a separate terminal window and type:

python -m smtpd -n -c DebuggingServer localhost:1025

Now when you register on the site, an email will be sent to the local server, and will be viewable in that separate tab. Go ahead and register via the browser, using an access code from accounts/forms.py.

The email sent to the local server should include an activation link. Cut and paste this activation link into your browser to active your user. You should see a response in the browser telling you that you are know able to log in - go ahead and do so. You should be all set!

Working with Javascript

By default, our Javascript is saved as staticfiles and loaded using the static template utility. When making changes to the Javascript, you'll want to re-build the files with the command npm run build. You'll then need to collect the new files with python manage.py collectstatic.

This can be tedious when working intensively with the Javascript files, so there's another option: webpack_loader. To switch from staticfiles to webpack_loader, go to settings.py and change the variable LOAD_JS_WITH_WEBPACK to true. This will temporarily break the site as we need our Javascript files served from somewhere. Open up a new terminal window, cd into the frontend directory, and type npm run serve to serve the files. The site should work again, and should automatically update when you change or add Vue components, routes, etc.

Tests

There are two main test suites in Kybern.

To run the Python-based integration tests, use the standard Django test command, python manage.py test. This suite takes a lot of time to run so there are a few utilities. At the top of the main tests.py file is a place for you to indicate whether a class of tests should be skipped. You can also use the run_headless option in settings.py to quickly toggle between running headlessly or not (when tests are run headless, no browser is actually opened on your desktop).

There are also a smaller number of jest tests to test our Javascript components. We're working on better coverage! These are quick and can be run with npm run test:unit.

Asynchronous Tasks

The site uses Django Q to handle asynchronous tasks. All you should need to do is start the cluster by running python manage.py qcluster in a separate terminal.

Updating Concord and re-installing in Kybern

If you update Concord and need to reinstall it in Kybern, the following command, when run from the top level of the Concord directory, should update the package, uninstall and reinstall in Kybern. It assumes the directory structure specified in the two installation readmes in the Concord and Kybern repos.

bash ./create_dist.sh; cd ../kybern; source venv/bin/activate; pip uninstall -y concord; pip install ../glizzan-concord/dist/concord-0.0.1.tar.gz; deactivate; cd ../glizzan-concord/

Remember that if you make a db change in Concord, you'll need to run makemigrations in Concord, reinstall the package in kybern, and then run migrate in Kybern.

Installing postgres and setting up the database

  1. download postgres
  2. to start postgres, type sudo -u postgres -i
  3. to start psql, type psql
  4. type CREATE DATABASE kybern_db; CREATE USER kybern_db_superuser WITH PASSWORD 'elephant'; GRANT ALL PRIVILEGES ON DATABASE kybern_db TO kybern_db_superuser; ALTER USER kybern_db_superuser CREATEDB; ALTER ROLE kybern_db_superuser SET client_encoding TO 'utf8'; ALTER ROLE kybern_db_superuser SET default_transaction_isolation TO 'read committed'; ALTER ROLE kybern_db_superuser SET timezone TO 'UTC';
  5. to leave psql, type \q
  6. to leave postgres, type exit

As long as you're just developing locally, you can keep the default password 'elephant' but make sure to change it for anything production-like.

Note for installing postgres on Mac OSX: If you're using Postgres.app, you'll need to modify your python PATH so that the instillation file can find your pg_config file in order to install all of the requirements.

For example, add this line to your .rc configuration file:

PATH=$PATH:/Applications/Postgres.app/Contents/Versions/<current_version>/bin