Skip to content
/ p2k16 Public

Bitraf's self-server system for doors, memberships and tools.

License

Notifications You must be signed in to change notification settings

bitraf/p2k16

Repository files navigation

Getting started

Before you start, make sure to install:

  • python virtualenv, e.g. pip3 install virtualenv
  • docker
  • nvm
  • postgres client
sudo apt install postgresql-client-common
sudo apt install postgresql-client
sudo apt install libpq-dev
  • java
sudo apt install default-jre

We have a collection of tools available under bin/. Some are utilities, other are wrappers around other tools to make sure that you have the correct versions.

IMPORTANT - Before running any commands, you have to source our setup script:

# . .settings.sh

Creating the database:

# cd docker/p2k16
# docker-compose up -d
# cd -
# psql -U postgres -f database-setup.sql

The root user in the database is postgres, it's password is also postgres.

Running the application:

# p2k16-run-web

This will fail unless you have the required applications installed. You may need to adjust requirements.txt manually if installation complains about version numbers. Running p2k16-update-requirements may also help (but not guaranteed).

If run successfully, the application should be accessible at http://localhost:5000/.

You can log into p2k16 with the user 'super', password 'super', or 'foo', password 'foo' for a user with fewer circles.

To make an account paying, you can manually insert a payment like this, for a given account-id (2 in the example below, replace it with you userid):

insert into stripe_payment(created_at, created_by, updated_at, updated_by, stripe_id, start_date, end_date, amount, payment_date)
values(now(), 2, now(), 2, 'fake-stripe-id-2', now(), now() + interval '10 years', 500.00, now());

Development

Dependencies

  • The P2K16 gui is built with Flask
  • We assume PostgreSQL as database
  • SQLAlchemy is used as ORM.

Auto generated files

The .js files in /src/p2k16/web/static are all autogenerated by python code with matching names. door-data-service.js is generated by door_blueprint.py.

Creating SQL migrations

We use Flyway (https://flywaydb.org) to manage the schema. Flyway is a upgrade-only, sql-only tool (at least in our setup) to manage SQL databases. We're smart and are using PostgreSQL which support transactional changes to the schema.

After checking out the code and creating the database, run flyway migrate to migrate the database.

If you want to change the schema, create a new file under migrations/ called V001.NNN__clever_comment.sql. If more than one person is creating a schema at the same time you will get a conflict when the code is merged.

TODOs (fix at any time)

  • Add word completion to Add Badge text field.
  • Empty text field after clicking Add badge on user profile.
  • Show success message after adding badge on user profile.
  • Fix duplicate-check for badge names.
  • Add word cloud or similar for badges on Bitraf front page, to increase front page utility and engagement.
  • Add delete badge-button for self-made badges.
  • Limit line length for badges on user profile.
  • Drop BIGSERIAL on _version tables. Should be BIGINT instead.
  • Prevent updates to certain fields like Account.username. SQLAlchemy's event systems seems like a useful method: http://docs.sqlalchemy.org/en/latest/orm/events.html
  • Tools: maintain state in case of reboot (using retained messages on mqtt-server)

Badge system

Motivation

  • Enforce users have necessary course for dangerous machines
  • Make holding courses more attractive
  • Easier to find who knows what. Show a list/word cloud of the competence of the people who has recently checked in at Bitraf. On the front page, perhaps show a list of all active people's competence.
  • Encourage people to be active members at Bitraf

Examples

Badges is a way to tell something about a user. They have no monetary value, but can have a lot of social value.

Certain badges are restricted so that they can only be given to a person by someone else (aka karma badges), and other badges are restricted so that only certain users can award them (for example course instructors).

Most badges can be awarded multiple times too.

Badge categories:

  • Competence levels (badges required to operate certain tools that require course)

    • laser cutter
    • CNC-operator
    • lathe
  • Skill areas: (for expressing hobbies and competence levels)

    • laser cutting
    • woodworking
    • metalworking
    • soldering
    • KiCAD, Eagle
    • SMT
    • PCB-etching
    • oscilloscope
  • Karma badges

    • Cleaner
    • Dugnader
    • Bitraf project fixer
  • Various badge ideas

    • Badge "Initiator""dugnadsånd"? Badge for fixing something at Bitraf, i.e repairing laser, workshop mentoring, implementing web solutions (like this badge thingie), etc.
    • Profession badge category, i.e Professional Programmer, Professional Electrician, Professional Carpenter.

About

Bitraf's self-server system for doors, memberships and tools.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published