/dribdat

Open source hackathon platform

Primary LanguagePythonMIT LicenseMIT

Dribdat

Travis Coveralls Mattermost

An open platform for data-driven team collaboration, such as Hackathons.

This project is being developed by Datalets, a small studio in Bern, with support from the Swiss open data and open source community. If you need help or advice in setting up your event, or would like to contribute to the project: get in touch via our team chat and GitHub Issues. For more background and references, see ABOUT.

How does it look?

Dribdat works as a website and project board for running exciting, productive events, and allows organizers and participants to collect their project details in one place, displaying the challenges and projects in Web dashboards, and plugging in community tools such as Discourse, Slack, or Let's Chat - or using the remote API for additional interfaces such as chatbots to enhance the hackathon.

Logged-in users can submit challenges, ideas and projects by linking their document or repository, or entering details directly into a form. You can change or customize these instructions as you see fit.

Data on projects can be entered into the application directly using Markdown formatting, or aggregated simply by putting in a URL to a public project hosted on one of these supported platforms:

The administrative interface shown below allows defining details of the event and managing project data.

The look and feel of the project view can be customized with CSS, and shows challenges and projects, with a rating of how completely they are documented. In the Events screen there are links to a Print view for a summary of all projects on one page, and the ability to Embed results into another website.

And, as we're really into making the most of those time constraints, the homepage and dashboard feature a big animated countdown clock.

Tick tock!

Deployment Quickstart

This project can be deployed to any server capable of serving Python applications, and is set up for fast deployment to the Heroku cloud:

Deploy

You can configure your instance with the following basic environment variables:

  • SERVER_URL - fully qualified domain name where the site is hosted
  • DRIBDAT_ENV - 'dev' to enable debugging, 'prod' to optimise assets etc.
  • DRIBDAT_SECRET - a long scary string for hashing your passwords - in Heroku this is set automatically
  • DATABASE_URL - if you are using the Postgres add-on, this would be postgres://username:password@... - in Heroku this is set automatically
  • CACHE_TYPE - in production, you can use built-in, Redis, Memcache to speed up your site (see settings.py)

If you would like to use external clients, like the chatbot, to remote control Dribdat you need to set:

  • DRIBDAT_APIKEY - for connecting clients to the remote API

OAuth 2.0 support is built in, currently fully supporting Slack, using these variables:

  • DRIBDAT_SLACK_ID - an OAuth Client ID to enable Sign in with Slack
  • DRIBDAT_SLACK_SECRET - ..and client secret.

Set the redirect URL in your app's OAuth Settings to <SERVER_URL>/slack_callback

API

There are a number of API calls that admins can use to easily get to the data in Dribdat in CSV or JSON format. See GitHub issues for development status.

Basic data on an event:

  • /api/event/<EVENT ID>/info.json
  • /api/event/current/info.json

Retrieve data on all projects from an event:

  • /api/event/<EVENT ID>/projects.csv
  • /api/event/<EVENT ID>/projects.json
  • /api/event/current/projects.json

Recent activity in projects (all or specific):

  • /api/project/activity.json
  • /api/<PROJECT ID>/activity.json

Search project contents:

  • /api/project/search.json?q=<text_query>

Push data into projects (WIP):

  • /api/project/push.json

For more details see api.py

Developer guide

Install Python, Virtualenv and Pip or Pipenv to start working with the code.

You may need to install additional libraries (libffi) for the misaka package, which depends on CFFI, e.g. sudo dnf install libffi-devel

Run the following commands from the repository root folder to bootstrap your environment using Pipenv:

pipenv --three
pipenv shell
pipenv install

Or using plain pip:

pip install -r requirements/dev.txt

By default in a dev environment, a SQLite database will be created in the root folder (dev.db). You can also install and configure your choice of DBMS supported by SQLAlchemy.

Run the following to create your app's database tables and perform the initial migration:

python manage.py db init
python manage.py db migrate
python manage.py db upgrade

Finally, run this command to start the server:

FLASK_DEBUG=1 python manage.py run

You will see a pretty welcome screen at http://localhost:5000

The first user that registers becomes an admin, so don't delay!

Shell access

To open the interactive shell, run: python manage.py shell (or, using the Heroku toolchain, heroku run python manage.py shell)

By default, you will have access to the User model, as well as Event, Project, Category, Activity. For example, to promote to admin and reset the password of the first user:

u = User.query.first()
u.is_admin = True
u.set_password('Ins@nEl*/c0mpl3x')
u.save()

Running Tests

To run all tests, run: python manage.py test

Migrations

Whenever a database migration needs to be made. Run the following commands:

python manage.py db migrate

This will generate a new migration script. Then run:

python manage.py db upgrade

To apply the migration. Watch out for any errors in the process.

For a full migration command reference, run python manage.py db --help.

If you get errors like ERROR [alembic.env] Can't locate revision identified by 'aa969b4f9f51', usually the fix is to drop the migration history table, and again db init .. db migrate .. db upgrade. You can do this in your database client, or with a line like this in the case of Heroku:

heroku pg:psql -c "drop table alembic_version" -a my-dribdat-instance

Credits

Developed by Oleg Lavrovsky based on Steven Loria's flask-cookiecutter. With thanks to the Swiss communities for Open Data, Open Networking and Open Source for their many contributions, and to Swisscom via F. Wieser and M.-C. Gasser for conceptual inputs and financial support of the first release of this project.