Skip to content

Commit

Permalink
Merge branch 'master' into feature/change-capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
xerbalind authored Apr 19, 2023
2 parents 5748154 + f7a09a0 commit 5f03f4c
Show file tree
Hide file tree
Showing 37 changed files with 524 additions and 152 deletions.
14 changes: 13 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2022-10-08 19:18:22 UTC using RuboCop version 1.36.0.
# on 2023-04-19 19:51:02 UTC using RuboCop version 1.50.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 5
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Include.
# Include: **/test/**/*.rb
Rails/ActionControllerTestCase:
Exclude:
- 'test/controllers/event_controller_test.rb'
- 'test/controllers/partners_controller_test.rb'
- 'test/controllers/registrations_controller_test.rb'
- 'test/controllers/users_controller_test.rb'
- 'test/controllers/welcome_controller_test.rb'
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.4
3.0.6
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby 3.0.4
ruby 3.0.6
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.0.4
FROM ruby:3.0.6

ENV RAILS_ENV=production

Expand Down
33 changes: 18 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GIT

GIT
remote: https://github.com/ZeusWPI/rails_style.git
revision: 7101522ddc0f7e4cf13235a6e7a7318f04253443
revision: 33ea5008e49be142ad490c5b572ef4b3f6436f23
specs:
rails_style (0.0.1)
bundler (>= 2.1.4)
Expand Down Expand Up @@ -161,7 +161,7 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.6.2)
json (2.6.3)
jwt (2.3.0)
launchy (2.5.0)
addressable (~> 2.7)
Expand Down Expand Up @@ -232,8 +232,8 @@ GEM
paper_trail (14.0.0)
activerecord (>= 6.0)
request_store (~> 1.4)
parallel (1.22.1)
parser (3.1.2.1)
parallel (1.23.0)
parser (3.2.2.0)
ast (~> 2.4.1)
poltergeist (1.18.1)
capybara (>= 2.1, < 4)
Expand Down Expand Up @@ -300,37 +300,40 @@ GEM
actionview (>= 5)
redis-client (0.14.1)
connection_pool
regexp_parser (2.6.0)
regexp_parser (2.8.0)
request_store (1.5.1)
rack (>= 1.4)
responders (3.1.0)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.2.5)
rubocop (1.36.0)
rubocop (1.50.2)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.2.1)
parser (>= 3.2.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.20.1, < 2.0)
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.21.0)
parser (>= 3.1.1.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.28.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.17.1)
rubocop (~> 1.41)
rubocop-minitest (0.22.2)
rubocop (>= 0.90, < 2.0)
rubocop-rails (2.16.1)
rubocop-rails (2.19.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-rspec (2.13.2)
rubocop-rspec (2.20.0)
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
ruby-graphviz (1.2.5)
rexml
ruby-ole (1.2.12.2)
ruby-progressbar (1.11.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
Expand Down Expand Up @@ -394,7 +397,7 @@ GEM
concurrent-ruby (~> 1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (2.3.0)
unicode-display_width (2.4.2)
validates_timeliness (6.0.0)
activemodel (>= 6.0.0, < 7)
timeliness (>= 0.3.10, < 1)
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@
In short, Gandalf is a project that does everything that makes organising and managing an event a lot easier for FK-clubs of the University of Ghent. The application is written specifically for the UGent FakulteitenKonvent. It allows students to register for events and it also interacts with the FK-Enrolment database and allows members of student unions to subscribe to member-only events from their clubs.

# Getting started
0. Install the prerequisites: ruby 3.0.4, preferably using [asdf](https://asdf-vm.com/), and some system libraries depending on your OS (e.g. imagemagick)

If you have NixOS or Nix installed, you can use the `flake.nix` to avoid the hassle of installing the right dependencies. Scroll down for more info.

0. Install the prerequisites: ruby 3.0.6, preferably using [asdf](https://asdf-vm.com/), and some system libraries depending on your OS (e.g. imagemagick)
1. Install the ruby dependencies: `bin/bundle`
2. Start up the database, sidekiq and rails server by running `bin/dev`
3. Set up some database data using `rails db:setup`
4. Browse to http://localhost:3000

In case you want to start the webserver in your IDE, just run `docker-compose up -d` and start Sidekiq manually (`bundle exec sidekiq`)

## Development using Nix

- Make sure you have [Nix](https://nixos.org/download.html#download-nix) installed.
- Run `nix develop`
- Done! You have everything installed. You can now:
1. Install Ruby dependencies with `gems:refresh`
2. Start EVERYTHING with `server:start`

# Manually adding users to clubs / making users admin

```
Expand Down
17 changes: 17 additions & 0 deletions app/actions/generate_html_barcodes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

require 'barby/barcode/ean_13'
require 'barby/outputter/html_outputter'

class GenerateHtmlBarcodes
def initialize(barcode_data)
@barcode_data = barcode_data
end

def call
barcode = Barby::EAN13.new(@barcode_data)

html_outputter = Barby::HtmlOutputter.new(barcode)
html_outputter.to_html.html_safe # rubocop:disable Rails/OutputSafety
end
end
22 changes: 22 additions & 0 deletions app/actions/generate_ical.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

class GenerateIcal
def initialize(event)
@event = event
end

def call
cal = Icalendar::Calendar.new
cal.event do |e|
e.dtstart = @event.start_date
e.dtend = @event.end_date
e.location = @event.location
e.summary = @event.name
e.description = @event.website
e.organizer = "mailto:#{@event.contact_email}"
e.organizer = Icalendar::Values::CalAddress.new("mailto:#{@event.contact_email}", cn: @event.club.name)
end
cal.publish
cal.to_ical
end
end
8 changes: 5 additions & 3 deletions app/actions/user/fetch_club.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def call
private

def fk_fetch_club
fk_authorized_clubs = Set['chemica', 'dentalia', 'filologica', 'fk', 'gbk', 'geografica', 'geologica', 'gfk', 'hermes', 'hilok', 'khk',
'kmf', 'lila', 'lombrosiana', 'moeder-lies', 'oak', 'politeia', 'slavia', 'vbk', 'vdk', 'vek', 'veto',
fk_authorized_clubs = Set['chemica', 'dentalia', 'dsa', 'filologica', 'fk', 'gbk', 'geografica', 'geologica', 'gfk', 'hermes', 'hilok',
'khk', 'kmf', 'lila', 'lombrosiana', 'moeder-lies', 'oak', 'politeia', 'slavia', 'vbk', 'vdk', 'vek', 'veto',
'vgk-fgen', 'vgk-flwi', 'vlak', 'vlk', 'vppk', 'vrg', 'vtk', 'wina']
resp = HTTParty.get(
"#{Rails.application.secrets.fk_auth_url}/#{user.username}/Gandalf",
Expand All @@ -35,7 +35,7 @@ def fk_fetch_club
return Set.new unless resp.success?

hash = JSON[resp.body]
clubs = hash['clubs'].map { |club| club['internal_name'] }.to_set
clubs = hash['clubs'].to_set { |club| club['internal_name'].downcase }
# Only return clubs FK can manage
clubs & fk_authorized_clubs
end
Expand Down Expand Up @@ -77,6 +77,8 @@ def dsa_fetch_club
next return_map
end

return Set.new if cas_to_dsa_associations.nil?

cas_to_dsa_associations.fetch(user.username, Set[])
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/registrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ $(document).on('turbolinks:load', function() {
}
};

$("#registration_access_levels").on('change', function() {
$("#registration_access_level").on('change', function() {
return hideCommentFieldIfNeeded($(this).val());
});

return hideCommentFieldIfNeeded($("#registration_access_levels").val());
return hideCommentFieldIfNeeded($("#registration_access_level").val());

});
});
4 changes: 4 additions & 0 deletions app/assets/stylesheets/barcodes.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
table.barby-barcode { border-spacing: 0; }
tr.barby-row {}
td.barby-cell { width: 3px; height: 70px; }
td.barby-cell.on { background: #000; }
18 changes: 9 additions & 9 deletions app/controllers/access_levels_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ class AccessLevelsController < ApplicationController

respond_to :html, :js

def index
@event = Event.find params.require(:event_id)
authorize! :read, @event
end

def show
@access_level = AccessLevel.find params.require(:id)
end

def index
def edit
@event = Event.find params.require(:event_id)
authorize! :read, @event
authorize! :update, @event
@access_level = @event.access_levels.find(params.require(:id))
respond_with @access_level
end

def create
Expand All @@ -24,13 +31,6 @@ def create
respond_with @access_level
end

def edit
@event = Event.find params.require(:event_id)
authorize! :update, @event
@access_level = @event.access_levels.find(params.require(:id))
respond_with @access_level
end

def update
@event = Event.find params.require(:event_id)
authorize! :update, @event
Expand Down
38 changes: 13 additions & 25 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,21 @@ def show

respond_to do |format|
format.html { render :show }
format.ics do
cal = Icalendar::Calendar.new
cal.event do |e|
e.dtstart = @event.start_date
e.dtend = @event.end_date
e.location = @event.location
e.summary = @event.name
e.organizer = "mailto:#{@event.contact_email}"
e.organizer = Icalendar::Values::CalAddress.new("mailto:#{@event.contact_email}", cn: @event.club.name)
end
cal.publish
render plain: cal.to_ical
end
format.ics { render plain: GenerateIcal.new(@event).call }
end
end

def new; end

def edit; end

def destroy
@event.destroy!
redirect_to action: :index
def create
authorize! :create, Event

@event = Event.new(event_create_params)
flash.now[:success] = "Successfully created event." if @event.save

respond_with @event
end

def update
Expand All @@ -60,6 +52,11 @@ def update
render action: :edit
end

def destroy
@event.destroy!
redirect_to action: :index
end

def toggle_registration_open
@event = Event.find params.require(:id)
authorize! :update, @event
Expand All @@ -69,15 +66,6 @@ def toggle_registration_open
redirect_to action: :edit
end

def create
authorize! :create, Event

@event = Event.new(event_create_params)
flash.now[:success] = "Successfully created event." if @event.save

respond_with @event
end

def statistics
@event = Event.find params.require(:id)
authorize! :view_stats, @event
Expand Down
16 changes: 8 additions & 8 deletions app/controllers/partners_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ def new
@partner = Partner.new
end

def edit
@event = Event.find params.require(:event_id)
authorize! :update, @event

@partner = @event.partners.find params.require(:id)
respond_with @partner
end

def create
@event = Event.find params.require(:event_id)
authorize! :update, @event
Expand All @@ -39,14 +47,6 @@ def create
respond_with @partner
end

def edit
@event = Event.find params.require(:event_id)
authorize! :update, @event

@partner = @event.partners.find params.require(:id)
respond_with @partner
end

def update
@event = Event.find params.require(:event_id)
authorize! :update, @event
Expand Down
Loading

0 comments on commit 5f03f4c

Please sign in to comment.