Skip to content

Commit

Permalink
Convert and annotate
Browse files Browse the repository at this point in the history
  • Loading branch information
TomNaessens committed May 19, 2024
1 parent 535d0a8 commit 5819d56
Show file tree
Hide file tree
Showing 26 changed files with 147 additions and 146 deletions.
2 changes: 1 addition & 1 deletion app/actions/user/fetch_enrolled_clubs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(user)

def call
resp = HTTParty.get("http://registratie.fkgent.be/api/v2/members/clubs_for_ugent_nr.json", query:
{ key: Rails.application.secrets.enrollment_key, ugent_nr: user.cas_ugentStudentID })
{ key: Rails.application.secrets.enrollment_key, ugent_nr: user.cas_ugentstudentid })

return unless resp.code == 200

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def show
return unless current_user

@registration.name = current_user.display_name
@registration.student_number = current_user.cas_ugentStudentID
@registration.student_number = current_user.cas_ugentstudentid
@registration.email = current_user.cas_mail

respond_to do |format|
Expand Down Expand Up @@ -84,7 +84,7 @@ def statistics
@data = @event.access_levels.map do |al|
{
name: al.name,
data: zeros.merge(al.registrations.group('date(registrations.created_at)').count.transform_keys { |key| key.strftime("%Y-%m-%d") })
data: zeros.merge(al.registrations.group('registrations.name, date(registrations.created_at)').count.transform_keys { |key| key.strftime("%Y-%m-%d") })
}
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def create
@registration.paid = 0

# overwrite student_number so setting this will not work
@registration.student_number = current_user.cas_ugentStudentID if requested_access_level.requires_login?
@registration.student_number = current_user.cas_ugentstudentid if requested_access_level.requires_login?

# Send the confirmation email.
if @registration.save
Expand Down
12 changes: 6 additions & 6 deletions app/models/access_level.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ def price=(value)
#
# Table name: access_levels
#
# id :integer not null, primary key
# capacity :integer
# id :bigint not null, primary key
# capacity :bigint
# has_comment :boolean
# hidden :boolean
# name :string(255)
# permit :string(255) default("everyone")
# price :integer
# price :bigint
# created_at :datetime
# updated_at :datetime
# event_id :integer
# event_id :bigint
#
# Indexes
#
# index_access_levels_on_event_id (event_id)
# idx_16847_index_access_levels_on_event_id (event_id)
#
# Foreign Keys
#
# fk_rails_... (event_id => events.id) ON DELETE => cascade
# fk_rails_... (event_id => events.id) ON DELETE => cascade ON UPDATE => restrict
#
4 changes: 2 additions & 2 deletions app/models/club.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def name
#
# Table name: clubs
#
# id :integer not null, primary key
# id :bigint not null, primary key
# display_name :string(255)
# full_name :string(255)
# internal_name :string(255)
Expand All @@ -31,5 +31,5 @@ def name
#
# Indexes
#
# index_clubs_on_internal_name (internal_name) UNIQUE
# idx_16882_index_clubs_on_internal_name (internal_name) UNIQUE
#
12 changes: 6 additions & 6 deletions app/models/clubs_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ class ClubsUser < ApplicationRecord
#
# Table name: clubs_users
#
# club_id :integer
# user_id :integer
# club_id :bigint
# user_id :bigint
#
# Indexes
#
# fk_rails_b7c6964840 (user_id)
# index_clubs_users_on_club_id_and_user_id (club_id,user_id) UNIQUE
# idx_16891_fk_rails_b7c6964840 (user_id)
# idx_16891_index_clubs_users_on_club_id_and_user_id (club_id,user_id) UNIQUE
#
# Foreign Keys
#
# fk_rails_... (club_id => clubs.id) ON DELETE => cascade
# fk_rails_... (user_id => users.id) ON DELETE => cascade
# fk_rails_... (club_id => clubs.id) ON DELETE => cascade ON UPDATE => restrict
# fk_rails_... (user_id => users.id) ON DELETE => cascade ON UPDATE => restrict
#
14 changes: 7 additions & 7 deletions app/models/enrolled_clubs_member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ class EnrolledClubsMember < ApplicationRecord
#
# Table name: enrolled_clubs_members
#
# club_id :integer not null
# user_id :integer not null
# club_id :bigint not null
# user_id :bigint not null
#
# Indexes
#
# index_enrolled_clubs_members_on_club_id (club_id)
# index_enrolled_clubs_members_on_club_id_and_user_id (club_id,user_id) UNIQUE
# index_enrolled_clubs_members_on_user_id (user_id)
# idx_16894_index_enrolled_clubs_members_on_club_id (club_id)
# idx_16894_index_enrolled_clubs_members_on_club_id_and_user_id (club_id,user_id) UNIQUE
# idx_16894_index_enrolled_clubs_members_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (club_id => clubs.id) ON DELETE => cascade
# fk_rails_... (user_id => users.id) ON DELETE => cascade
# fk_rails_... (club_id => clubs.id) ON DELETE => cascade ON UPDATE => restrict
# fk_rails_... (user_id => users.id) ON DELETE => cascade ON UPDATE => restrict
#
14 changes: 7 additions & 7 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ def toggle_registration_open
#
# Table name: events
#
# id :integer not null, primary key
# id :bigint not null, primary key
# bank_number :string(255)
# contact_email :string(255)
# description :text(16777215)
# description :text
# end_date :datetime
# export_content_type :string(255)
# export_file_name :string(255)
# export_file_size :integer
# export_file_size :bigint
# export_status :string(255)
# export_updated_at :datetime
# location :string(255)
Expand All @@ -56,18 +56,18 @@ def toggle_registration_open
# require_physical_ticket :boolean default(FALSE), not null
# show_statistics :boolean
# show_ticket_count :boolean default(TRUE)
# signature :text(65535)
# signature :text
# start_date :datetime
# website :string(255)
# created_at :datetime
# updated_at :datetime
# club_id :integer
# club_id :bigint
#
# Indexes
#
# fk_rails_fc45ac705d (club_id)
# idx_16898_fk_rails_fc45ac705d (club_id)
#
# Foreign Keys
#
# fk_rails_... (club_id => clubs.id) ON DELETE => cascade
# fk_rails_... (club_id => clubs.id) ON DELETE => cascade ON UPDATE => restrict
#
20 changes: 10 additions & 10 deletions app/models/partner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def deliver
#
# Table name: partners
#
# id :integer not null, primary key
# id :bigint not null, primary key
# authentication_token :string(255)
# confirmed :boolean
# current_sign_in_at :datetime
Expand All @@ -44,21 +44,21 @@ def deliver
# remember_created_at :datetime
# reset_password_sent_at :datetime
# reset_password_token :string(255)
# sign_in_count :integer default(0), not null
# sign_in_count :bigint default(0), not null
# created_at :datetime
# updated_at :datetime
# access_level_id :integer
# event_id :integer
# access_level_id :bigint
# event_id :bigint
#
# Indexes
#
# fk_rails_188986c214 (event_id)
# index_partners_on_access_level_id (access_level_id)
# index_partners_on_authentication_token (authentication_token)
# index_partners_on_reset_password_token (reset_password_token) UNIQUE
# idx_16916_fk_rails_188986c214 (event_id)
# idx_16916_index_partners_on_access_level_id (access_level_id)
# idx_16916_index_partners_on_authentication_token (authentication_token)
# idx_16916_index_partners_on_reset_password_token (reset_password_token) UNIQUE
#
# Foreign Keys
#
# fk_rails_... (access_level_id => access_levels.id)
# fk_rails_... (event_id => events.id) ON DELETE => cascade
# fk_rails_... (access_level_id => access_levels.id) ON DELETE => restrict ON UPDATE => restrict
# fk_rails_... (event_id => events.id) ON DELETE => cascade ON UPDATE => restrict
#
24 changes: 12 additions & 12 deletions app/models/registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,32 +134,32 @@ def to_cents(value)
#
# Table name: registrations
#
# id :integer not null, primary key
# id :bigint not null, primary key
# barcode :string(255)
# barcode_data :string(255)
# checked_in_at :datetime
# comment :text(65535)
# comment :text
# email :string(255)
# name :string(255)
# paid :integer
# paid :bigint
# payment_code :string(255)
# price :integer
# price :bigint
# student_number :string(255)
# token :string(255) not null
# created_at :datetime
# updated_at :datetime
# access_level_id :integer not null
# event_id :integer
# access_level_id :bigint not null
# event_id :bigint
#
# Indexes
#
# index_registrations_on_access_level_id (access_level_id)
# index_registrations_on_event_id (event_id)
# index_registrations_on_payment_code (payment_code) UNIQUE
# index_registrations_on_token (token)
# idx_16930_index_registrations_on_access_level_id (access_level_id)
# idx_16930_index_registrations_on_event_id (event_id)
# idx_16930_index_registrations_on_payment_code (payment_code) UNIQUE
# idx_16930_index_registrations_on_token (token)
#
# Foreign Keys
#
# fk_rails_... (access_level_id => access_levels.id)
# fk_rails_... (event_id => events.id) ON DELETE => cascade
# fk_rails_... (access_level_id => access_levels.id) ON DELETE => restrict ON UPDATE => restrict
# fk_rails_... (event_id => events.id) ON DELETE => cascade ON UPDATE => restrict
#
14 changes: 7 additions & 7 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class User < ApplicationRecord
after_create :enqueue_fetch_club, :enqueue_fetch_enrolled_clubs

# this should add all extra CAS attributes returned by the server to the current session
# extra var in session: cas_givenname, cas_surname, cas_ugentStudentID, cas_mail, cas_uid (= UGent login)
# extra var in session: cas_givenname, cas_surname, cas_ugentstudentid, cas_mail, cas_uid (= UGent login)
def cas_extra_attributes=(extra_attributes)
extra_attributes.each do |name, value|
# I prefer a case over reflection; this is safer if we suddenly get an
Expand All @@ -27,7 +27,7 @@ def cas_extra_attributes=(extra_attributes)
when :surname
self.cas_surname = value
when :ugentStudentID
self.cas_ugentStudentID = value
self.cas_ugentstudentid = value
when :mail
self.cas_mail = value
when :uid
Expand All @@ -37,7 +37,7 @@ def cas_extra_attributes=(extra_attributes)

self.save!

if self.cas_ugentStudentID # rubocop:disable Style/GuardClause
if self.cas_ugentstudentid # rubocop:disable Style/GuardClause
enqueue_fetch_club
enqueue_fetch_enrolled_clubs
end
Expand Down Expand Up @@ -79,24 +79,24 @@ def self.from_omniauth(auth)
#
# Table name: users
#
# id :integer not null, primary key
# id :bigint not null, primary key
# admin :boolean
# cas_givenname :string(255)
# cas_mail :string(255)
# cas_surname :string(255)
# cas_ugentStudentID :string(255)
# cas_ugentstudentid :string(255)
# cas_uid :string(255)
# current_sign_in_at :datetime
# current_sign_in_ip :string(255)
# last_sign_in_at :datetime
# last_sign_in_ip :string(255)
# remember_created_at :datetime
# sign_in_count :integer default(0), not null
# sign_in_count :bigint default(0), not null
# username :string(255) not null
# created_at :datetime
# updated_at :datetime
#
# Indexes
#
# index_users_on_username (username) UNIQUE
# idx_16946_index_users_on_username (username) UNIQUE
#
2 changes: 1 addition & 1 deletion db/migrate/20140121123250_add_casfields_to_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class AddCasfieldsToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :cas_givenname, :string
add_column :users, :cas_surname, :string
add_column :users, :cas_ugentStudentID, :string
add_column :users, :cas_ugentstudentid, :string
add_column :users, :cas_mail, :string
add_column :users, :cas_uid, :string
end
Expand Down
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
t.datetime "updated_at"
t.string "cas_givenname"
t.string "cas_surname"
t.string "cas_ugentStudentID"
t.string "cas_ugentstudentid"
t.string "cas_mail"
t.string "cas_uid"
t.boolean "admin"
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:
- "6379:6379"

volumes:
db_data:
gandalf_data:
gandalf_test_data:
redis_data:
12 changes: 6 additions & 6 deletions test/fixtures/access_levels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@ students_only:
#
# Table name: access_levels
#
# id :integer not null, primary key
# capacity :integer
# id :bigint not null, primary key
# capacity :bigint
# has_comment :boolean
# hidden :boolean
# name :string(255)
# permit :string(255) default("everyone")
# price :integer
# price :bigint
# created_at :datetime
# updated_at :datetime
# event_id :integer
# event_id :bigint
#
# Indexes
#
# index_access_levels_on_event_id (event_id)
# idx_16847_index_access_levels_on_event_id (event_id)
#
# Foreign Keys
#
# fk_rails_... (event_id => events.id) ON DELETE => cascade
# fk_rails_... (event_id => events.id) ON DELETE => cascade ON UPDATE => restrict
#
4 changes: 2 additions & 2 deletions test/fixtures/clubs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fk:
#
# Table name: clubs
#
# id :integer not null, primary key
# id :bigint not null, primary key
# display_name :string(255)
# full_name :string(255)
# internal_name :string(255)
Expand All @@ -25,5 +25,5 @@ fk:
#
# Indexes
#
# index_clubs_on_internal_name (internal_name) UNIQUE
# idx_16882_index_clubs_on_internal_name (internal_name) UNIQUE
#
Loading

0 comments on commit 5819d56

Please sign in to comment.