Skip to content

Commit

Permalink
Merge branch 'staging' into renovate/all-minor-patch-bundler
Browse files Browse the repository at this point in the history
  • Loading branch information
wilco375 authored May 7, 2023
2 parents 037c8f1 + 9d91781 commit b320c6d
Show file tree
Hide file tree
Showing 35 changed files with 90 additions and 46 deletions.
20 changes: 20 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,30 @@ [email protected]
TREASURER_NAME=
TREASURER_PHONE=

AUTHORIZE_URL=/oauth/authorize
TOKEN_URL=/oauth/token
ME_URL=/oauth/me

COMPANY_NAME=Stichting Sociëteit Flux
COMPANY_IBAN=NL68 INGB 0008 1654 20
COMPANY_ADDRESS=Oude Markt 24-3, 7511 GB Enschede
COMPANY_WEBSITE=https://societeitflux.nl
COMPANY_KVK=41 032 169

SITE_NAME=S.O.F.I.A.
SITE_SHORT_NAME=SOFIA
SITE_ASSOCIATION=C.S.V. Alpha

CODE_BEER=8010
CODE_CRAFT_BEER=8015
CODE_NON_ALCOHOLIC=8020
CODE_DISTILLED=8030
CODE_WINE=8040
CODE_FOOD=8050
CODE_TOBACCO=8060
CODE_DONATION=2095
CODE_CREDIT_MUTATION='0610'
CODE_CASH=1000
CODE_PIN=2060

DOCKER_PASSWORD=somethingsomething
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.3
3.2.2
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.1.3-slim@sha256:9326196714b206561a89136b2d65957a994a37d52737cfca906a138be897fa51
FROM ruby:3.2.2-slim@sha256:70370316b02901d7db3f6e453d6259ed4d0d52326d6ac57e3a579f7e3b616e41

# Add build-essential tools.
RUN apt-get update -qq && \
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@ GEM
parser (3.2.2.1)
ast (~> 2.4.1)
pg (1.5.3)
pry (0.13.1)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.9.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (~> 0.13.0)
pry (>= 0.13, < 0.15)
pry-rails (0.3.9)
pry (>= 0.10.4)
public_suffix (5.0.1)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def index
def create # rubocop:disable Metrics/AbcSize
authorize :payment

payment = Payment.create_with_mollie('Sofia zatladder saldo inleg',
payment = Payment.create_with_mollie("#{Rails.application.config.x.site_short_name} zatladder saldo inleg",
user: current_user, amount: params[:payment][:amount])

if payment.valid?
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def refresh_user_list
find_or_create_user(user_json)
end

users_not_in_json = User.active.in_amber.where.not(uid: users_json.pluck('id'))
users_not_in_json = User.active.in_amber.where.not(uid: users_json.pluck('id')).where.not(name: 'Streepsysteem Flux')
users_not_in_json.each(&:archive!)

send_slack_users_refresh_notification
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/order_screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ document.addEventListener('turbolinks:load', () => {
let affilateKey = element.dataset.sumupKey;
let callback = element.dataset.sumupCallback;

let sumupUrl = `sumupmerchant://pay/1.0?affiliate-key=${affilateKey}&currency=EUR&title=Bestelling SOFIA&skip-screen-success=true&foreign-tx-id=${orderId}`;
let sumupUrl = `sumupmerchant://pay/1.0?affiliate-key=${affilateKey}&currency=EUR&title=Bestelling ${element.dataset.siteName}&skip-screen-success=true&foreign-tx-id=${orderId}`;
if (this.isIos) {
sumupUrl += `&amount=${orderTotal}&callbacksuccess=${callback}&callbackfail=${callback}`;
} else {
Expand Down
10 changes: 8 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class User < ApplicationRecord
class User < ApplicationRecord # rubocop:disable Metrics/ClassLength
devise :omniauthable, omniauth_providers: [:amber_oauth2]
has_many :orders, dependent: :destroy
has_many :order_rows, through: :orders, dependent: :destroy
Expand Down Expand Up @@ -84,11 +84,17 @@ def archive!

# TODO: Spec this method
# :nocov:
def self.from_omniauth(auth)
def self.from_omniauth(auth) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
user = where(provider: auth.provider, uid: auth.uid).first_or_create do |u|
u.name = auth[:info][:name]
end
user.update_role(auth[:info][:groups])
user.update(
name: auth[:info][:name],
email: auth[:info][:email],
avatar_thumb_url: auth[:info][:avatar_thumb_url],
birthday: auth[:info][:birthday]
)
user
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/activities/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% content_for :title, 'Activiteiten - SOFIA' %>
<% content_for :title, "Activiteiten - #{Rails.application.config.x.site_name}" %>
<% content_for :modal do %>
<%= render 'modal' %>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/activities/order_screen.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% content_for :title, "Streepscherm #{@activity.title} - SOFIA" %>
<% content_for :title, "Streepscherm #{@activity.title} - #{Rails.application.config.x.site_name}" %>
<%= content_tag :div, id: 'order-screen', class: 'order-screen',
data: {users: @users_json, product_prices: @product_prices_json, activity: @activity_json, sumup_callback: sumup_callback_activity_url, sumup_key: @sumup_key, flashes: flash} do
data: {users: @users_json, product_prices: @product_prices_json, activity: @activity_json, sumup_callback: sumup_callback_activity_url, sumup_key: @sumup_key, flashes: flash, site_name: Rails.application.config.x.site_short_name} do

%>

Expand Down
2 changes: 1 addition & 1 deletion app/views/activities/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% content_for :title, "Activiteit #{@activity.title} - SOFIA" %>
<% content_for :title, "Activiteit #{@activity.title} - #{Rails.application.config.x.site_name}" %>
<% content_for :modal do %>
<%= render 'edit_modal' %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/credit_mutations/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% content_for :title, 'Inleg en saldocorrecties - SOFIA' %>
<% content_for :title, "Inleg en saldocorrecties - #{Rails.application.config.x.site_name}" %>
<% content_for :modal do %>
<%= render 'modal' %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/errors/forbidden.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<% content_for :title, 'Error - SOFIA' %>
<% content_for :title, "Error - #{Rails.application.config.x.site_name}" %>
Je hebt niet de benodigde rechten om deze pagina te mogen bekijken.
2 changes: 1 addition & 1 deletion app/views/errors/internal_server_error.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<% content_for :title, 'Error - SOFIA' %>
<% content_for :title, "Error - #{Rails.application.config.x.site_name}" %>
'Er is een error op de server opgetreden. Stuur een <%= link_to 'mailtje', "mailto:#{Rails.application.config.x.admin_email}" %> naar de ICT-commissie als dit probleem op blijft treden.
2 changes: 1 addition & 1 deletion app/views/errors/not_found.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<% content_for :title, 'Error - SOFIA' %>
<% content_for :title, "Error - #{Rails.application.config.x.site_name}" %>
Deze pagina bestaat niet (meer).
2 changes: 1 addition & 1 deletion app/views/errors/unacceptable.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<% content_for :title, 'Error - SOFIA' %>
<% content_for :title, "Error - #{Rails.application.config.x.site_name}" %>
Er is een error op de server opgetreden. Stuur een <%= link_to 'mailtje', "mailto:#{Rails.application.config.x.admin_email}" %> naar de ICT-commissie als dit probleem op blijft treden.
2 changes: 1 addition & 1 deletion app/views/finance_overview/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= content_for :title, 'Financieel overzicht - SOFIA' %>
<%= content_for :title, "Financieel overzicht - #{Rails.application.config.x.site_name}" %>
<div class="container footer-padding">
<div class="row pt-4">
<div class="col-sm-12 d-flex justify-content-between align-items-center">
Expand Down
2 changes: 1 addition & 1 deletion app/views/index/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% content_for :title, 'SOFIA – Streepsysteem der C.S.V. Alpha' %>
<% content_for :title, "#{Rails.application.config.x.site_name} – Streepsysteem der #{Rails.application.config.x.site_association}" %>
<%= render partial: 'partials/sofia_quote' %>

<div class="container py-sm-3">
Expand Down
2 changes: 1 addition & 1 deletion app/views/invoices/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% content_for :title, 'Facturen - SOFIA' %>
<% content_for :title, "Facturen - #{Rails.application.config.x.site_name}" %>
<% content_for :modal do %>
<%= render 'modal' %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/invoices/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% content_for :title, "Factuur #{@invoice.human_id} - SOFIA" %>
<% content_for :title, "Factuur #{@invoice.human_id} - #{Rails.application.config.x.site_name}" %>


<div id="activity" class="container footer-padding">
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/errors.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title><%= 'SOFIA – Streepsysteem der C.S.V. Alpha' %></title>
<title><%= "#{Rails.application.config.x.site_name} – Streepsysteem der #{Rails.application.config.x.site_association}" %></title>

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/mailer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ a[x-apple-data-detectors=true] {
<div style="color:#fff;line-height:120%;font-family:'Roboto', Tahoma, Verdana, Segoe, sans-serif; padding-right: 10px; padding-left: 10px; padding-top: 10px; padding-bottom: 10px;">
<div style="font-size:12px;line-height:14px;color:#fff;font-weight:400;font-family:'Roboto', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
<p style="margin: 0;font-size: 14px;line-height: 20px;text-align: right">
S.O.F.I.A. - Streepsysteem der C.S.V. Alpha
<%= "#{Rails.application.config.x.site_name} Streepsysteem der #{Rails.application.config.x.site_association}" %>
<br>
</p>
</div>
Expand Down Expand Up @@ -370,7 +370,7 @@ a[x-apple-data-detectors=true] {
<p style="margin: 0;font-size: 16px;line-height: 20px">
Met vriendelijke groet,
<br />
S.O.F.I.A.
<%= Rails.application.config.x.site_name %>
</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/partials/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<% end %>
</span>
<span class="text-muted mx-2">
2018 © ICT-commissie der C.S.V. Alpha
<%= Time.now.year %> © ICT-commissie der C.S.V. Alpha
</span>
</footer>
4 changes: 2 additions & 2 deletions app/views/partials/_login_prompt.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
</div>
<div class="card-body">
<p class="card-text">
Log in with a C.S.V. Alpha account.
Log in with a <%= Rails.application.config.x.site_association %> account.
</p>
<div class="d-grid">
<%= link_to('Sign in with C.S.V. Alpha', user_amber_oauth2_omniauth_authorize_path, class: 'btn btn-primary', method: :post) %>
<%= link_to("Sign in with #{Rails.application.config.x.site_association}", user_amber_oauth2_omniauth_authorize_path, class: 'btn btn-primary', method: :post) %>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/partials/_navigation_bar.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<span class="navbar-brand">
<%= image_tag '/images/sofia.svg', alt: 'SOFIA icon', title: 'SOFIA', height: '25px' %>
<%= image_tag '/images/sofia.svg', alt: "#{Rails.application.config.x.site_name} icon", title: Rails.application.config.x.site_name, height: '25px' %>
</span>
<button aria-controls="mainNavigation" aria-expanded="false" aria-label="Toggle navigation" class="navbar-toggler" data-bs-target="#mainNavigation" data-bs-toggle="collapse" type="button">
<span class="navbar-toggler-icon"></span>
Expand Down
4 changes: 2 additions & 2 deletions app/views/partials/_sofia_quote.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<div class="col-sm-12 py-3 text-center">

<h1 class="sofia-header">
<%= 'S.O.F.I.A. ' %>
<%= image_tag '/images/sofia.svg', alt: 'SOFIA icon', title: 'SOFIA', height: '64px' %>
<%= Rails.application.config.x.site_name %>
<%= image_tag '/images/sofia.svg', alt: "#{Rails.application.config.x.site_name} icon", title: Rails.application.config.x.site_name, height: '64px' %>
</h1>
<h4 class="mb-4">
<small>
Expand Down
2 changes: 1 addition & 1 deletion app/views/payments/add.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% content_for :title, "Saldo opwaarderen voor #{@user.name} - SOFIA" %>
<% content_for :title, "Saldo opwaarderen voor #{@user.name} - #{Rails.application.config.x.site_name}" %>

<%= content_tag :div, id: 'payment-add', class: 'container footer-padding', data: {user_credit: @user.credit, payment_amount: @payment.amount} do %>
<div class="container footer-padding">
Expand Down
2 changes: 1 addition & 1 deletion app/views/payments/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% content_for :title, "Betalingen - SOFIA" %>
<% content_for :title, "Betalingen - #{Rails.application.config.x.site_name}" %>

<div class="container footer-padding">
<div class="row pt-4">
Expand Down
2 changes: 1 addition & 1 deletion app/views/price_lists/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% content_for :title, 'Prijslijsten - SOFIA' %>
<% content_for :title, "Prijslijsten - #{Rails.application.config.x.site_name}" %>
<% content_for :modal do %>
<%= render 'modal' %>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/users/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% content_for :title, 'Gebruikers - SOFIA' %>
<% content_for :title, "Gebruikers - #{Rails.application.config.x.site_name}" %>
<% content_for :modal do %>
<%= render 'modal' %>
<% end %>
Expand All @@ -19,7 +19,7 @@
<users-table :users="manual_users"></users-table>

<div class="d-flex justify-content-between align-items-center mt-5">
<h3>Amber gebruikers</h3>
<h3><%= Rails.application.config.x.site_association %> gebruikers</h3>
<span>
<%= link_to refresh_user_list_users_path, class: 'btn btn-primary btn-sm me-1' do %>
<%= fa_icon 'refresh' %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% content_for :title, "Gebruiker #{@user.name} - SOFIA" %>
<% content_for :title, "Gebruiker #{@user.name} - #{Rails.application.config.x.site_name}" %>
<% content_for :modal do %>
<%= render 'mutation_modal' %>
<%= render 'modal' %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/zatladder/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= content_for :title, 'Zatladder - SOFIA' %>
<%= content_for :title, "Zatladder - #{Rails.application.config.x.site_name}" %>
<div class="container footer-padding">
<div class="row mt-4 d-flex justify-content-around">
<div class="card col-12 col-md-6 pt-3 mx-2">
Expand Down
20 changes: 20 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class Application < Rails::Application
config.x.healthcheck_ids = credentials.dig(Rails.env.to_sym, :healthcheck_ids)
config.x.mollie_api_key = credentials.dig(Rails.env.to_sym, :mollie_api_key)

config.x.authorize_url = ENV.fetch('AUTHORIZE_URL', '/oauth/authorize')
config.x.token_url = ENV.fetch('TOKEN_URL', '/api/v1/oauth/token')
config.x.me_url = ENV.fetch('ME_URL', '/api/v1/users?filter[me]&include="active_groups"')

config.x.from_email = ENV.fetch('FROM_EMAIL', '[email protected]')
config.x.ict_email = ENV.fetch('ICT_EMAIL', '[email protected]')
config.x.admin_email = ENV.fetch('ADMIN_EMAIL', '[email protected]')
Expand All @@ -57,5 +61,21 @@ class Application < Rails::Application
config.x.company_address = ENV.fetch('COMPANY_ADDRESS', nil)
config.x.company_website = ENV.fetch('COMPANY_WEBSITE', nil)
config.x.company_kvk = ENV.fetch('COMPANY_KVK', nil)

config.x.site_name = ENV.fetch('SITE_NAME', 'S.O.F.I.A.')
config.x.site_short_name = ENV.fetch('SITE_SHORT_NAME', 'SOFIA')
config.x.site_association = ENV.fetch('SITE_ASSOCIATION', 'C.S.V. Alpha')

config.x.code_beer = ENV.fetch('CODE_BEER', nil)
config.x.code_craft_beer = ENV.fetch('CODE_CRAFT_BEER', nil)
config.x.code_non_alcoholic = ENV.fetch('CODE_NON_ALCOHOLIC', nil)
config.x.code_distilled = ENV.fetch('CODE_DISTILLED', nil)
config.x.code_wine = ENV.fetch('CODE_WINE', nil)
config.x.code_food = ENV.fetch('CODE_FOOD', nil)
config.x.code_tobacco = ENV.fetch('CODE_TOBACCO', nil)
config.x.code_donation = ENV.fetch('CODE_DONATION', nil)
config.x.code_credit_mutation = ENV.fetch('CODE_CREDIT_MUTATION', nil)
config.x.code_cash = ENV.fetch('CODE_CASH', nil)
config.x.code_pin = ENV.fetch('CODE_PIN', nil)
end
end
2 changes: 0 additions & 2 deletions db/migrate/20170922175055_add_user_model.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
class AddUserModel < ActiveRecord::Migration[5.1]
def change
create_table :users do |t|
t.string :username, null: false

t.datetime :deleted_at
t.timestamps
end
Expand Down
10 changes: 5 additions & 5 deletions lib/omniauth/strategies/amber_oauth2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class AmberOauth2 < OmniAuth::Strategies::OAuth2

option :client_options,
site: Rails.application.config.x.amber_api_url.to_s,
authorize_url: '/oauth/authorize',
token_url: '/api/v1/oauth/token'
authorize_url: Rails.application.config.x.authorize_url,
token_url: Rails.application.config.x.token_url

def authorize_params
params = super
Expand All @@ -21,16 +21,16 @@ def authorize_params
info do
{
uid: raw_info['id'],
username: raw_info['attributes']['username'],
name: full_name(raw_info),
avatar_url: raw_info['attributes']['avatar_url'],
email: raw_info['attributes']['email'],
avatar_thumb_url: raw_info['attributes']['avatar_thumb_url'],
birthday: raw_info['attributes']['birthday'],
groups: groups_from_json(raw_info['relationships']['active_groups']['data'])
}
end

def raw_info
@raw_info ||= JSON.parse(access_token.get('/api/v1/users?filter[me]&include="active_groups"').body)['data'][0]
@raw_info ||= JSON.parse(access_token.get(Rails.application.config.x.me_url).body)['data'][0]
end

# https://github.com/intridea/omniauth-oauth2/issues/81
Expand Down

0 comments on commit b320c6d

Please sign in to comment.