The source code belonging to Alpha SOFIA. It is a system built with Ruby on Rails with Turbolinks and a little VueJS, used to manage orders in our own bar "Flux". Users authenticate via OAuth API (currently "Alpha AMBER") to see how much credit they got left, or to be able to register new orders and/or payments.
Use this repository to build upon, use as-is, learn from it, prove a point or whatever 😏
On Linux-like systems
- Ruby (see
.ruby-version
) - Bundler (
gem install bundler
) - NodeJS (see
.nvmrc
) - Yarn
- Postgresql 9.5+
- Running versions of
- Alpha AMBER API
- Alpha AMBER UI (for logging in)
- Clone this repository
- Run the following commands:
bundle install
(might take a couple of minutes)yarn
bundle exec rails db:setup
bundle exec rails s -p 5000
(port specified so it doesn't use the same as AMBER API)- Go to http://localhost:5000 and you should see SOFIA running
- Copy
.env.example
to.env
withcp .env.example .env
and edit the values where necessary - (When you want to use the invoice module) Follow https://github.com/zakird/wkhtmltopdf_binary_gem#installation-and-usage
Before you can start the application you will need the master.key
. Ask a fellow developer for it, or pull it from the server via ssh.
When the master.key
is present, you can use bundle exec rails credentials:edit
to open the default editor on your machine to read and edit the credentials. Be informed: these are production credentials so be careful.
Read more about Rails credentials on EngineYard.com.
Tip: you can also use one of the following commands to use an editor of your choice:
$ EDITOR="atom --wait" bundle exec rails credentials:edit
$ EDITOR="subl --wait" bundle exec rails credentials:edit
$ EDITOR="code --wait" bundle exec rails credentials:edit
In OAuth AMBER (github.com/csvalpha/amber-api), execute the following command (in rails console
):
app = Doorkeeper::Application.create(name: 'SOFIA - Streepsysteem der C.S.V. Alpha', redirect_uri: 'http://localhost:5000/users/auth/amber_oauth2/callback', scopes: 'public sofia')
app.uid
app.plaintext_secret
Next, copy the uid and plaintext secret to the .env
in SOFIA (as amber_client_id
and amber_client_secret
).
Users can have roles in SOFIA, namely Treasurer ("SB-penningmeester") and/or Main Bartender ("Hoofdtapper"). A user can also log in without a role. These roles are derived from the groups the user is in. These groups are saved in the AMBER API.
Roles are created in the following way during the seeding:
Role.create(role_type: :treasurer, group_uid: 3)
Role.create(role_type: :main_bartender, group_uid: 3)
Role.create(role_type: :main_bartender, group_uid: 2)
Deploying procedure is the same as for the AMBER project. See DEPLOY.md for that.
When contributing, please consult with the repository owners in advance to ensure a high chance of PR-success. PR-success means you're PR is merged and you'll be mentioned in the contributors list 🎉.
When submitting a PR, it'll need to be approved, but once approved (and green) you're responsible yourself for clicking the merge button and enjoying the intense feeling of satisfaction!