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
lodewiges authored Nov 22, 2024
2 parents 55b9e29 + 18f18df commit 590e431
Show file tree
Hide file tree
Showing 49 changed files with 383 additions and 174 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ AMBER_CLIENT_SECRET=
FROM_EMAIL=[email protected]
ICT_EMAIL=[email protected]
ADMIN_EMAIL=[email protected]
TREASURER_TITLE=penningmeester
TREASURER_EMAIL=[email protected]
TREASURER_NAME=
TREASURER_PHONE=
Expand All @@ -28,12 +29,15 @@ COMPANY_KVK=41 032 169

SITE_NAME=S.O.F.I.A.
SITE_SHORT_NAME=SOFIA
SITE_LONG_NAME=Streepsysteem voor de Ordentelijke Festiviteiten van Inleggend Alpha
SITE_ASSOCIATION=C.S.V. Alpha

CODE_BEER=8010
CODE_LOW_ALCOHOL_BEER=8011
CODE_CRAFT_BEER=8015
CODE_NON_ALCOHOLIC=8020
CODE_DISTILLED=8030
CODE_WHISKEY=8035
CODE_WINE=8040
CODE_FOOD=8050
CODE_TOBACCO=8060
Expand Down
16 changes: 5 additions & 11 deletions .github/workflows/cleanup-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@ on:
- cron: '0 0 * * 1' # https://crontab.guru/#0_0_*_*_1
workflow_dispatch:

env:
IMAGE_NAMES: sofia

jobs:
cleanup:
name: Cleanup
runs-on: ubuntu-latest
steps:
- name: Delete old versions
uses: snok/container-retention-policy@f617f1ca161a52bce48417eedd76924e71d0b4d9 # v2.1.0
- name: Delete untagged images
uses: actions/delete-package-versions@0d39a63126868f5eefaa47169615edd3c0f61e20 # v4.1.1
with:
image-names: ${{ env.IMAGE_NAMES }}
cut-off: 2 days ago UTC
account-type: org
org-name: ${{ github.repository_owner }}
skip-tags: latest,staging
token: ${{ secrets.GH_PAT }}
package-name: ${{ github.event.repository.name }}
package-type: container
delete-only-untagged-versions: true
26 changes: 24 additions & 2 deletions .github/workflows/continuous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ on:
description: Merge staging into master first? (y/N)
required: false
default: 'n'
target_env:
type: choice
description: Target environment
options:
- csvalpha
- luxadmosam
default: 'csvalpha'

concurrency:
group: cd-${{ github.ref_name }}
Expand All @@ -20,11 +27,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Validate branch
env:
TARGET_ENV: ${{ github.event.inputs.target_env }}
run: |
if [ "$GITHUB_REF_NAME" != 'staging' ] && [ "$GITHUB_REF_NAME" != 'master' ]; then
echo 'This workflow can only be run on branches staging and master.'
exit 1
fi
if [ "$TARGET_ENV" == 'luxadmosam' ] && [ "$GITHUB_REF_NAME" != 'master' ]; then
echo 'Only the master branch can be deployed to Lux ad Mosam.'
exit 1
fi
metadata:
name: Metadata
Expand All @@ -41,6 +54,7 @@ jobs:
id: get_metadata
env:
INPUT_MERGE: ${{ github.event.inputs.merge }}
TARGET_ENV: ${{ github.event.inputs.target_env }}
run: |
if [ "$GITHUB_REF_NAME" = 'master' ]; then
if [ "${INPUT_MERGE,,}" = 'y' ]; then
Expand All @@ -52,7 +66,11 @@ jobs:
fi
fi
echo 'stage=production' >> "$GITHUB_OUTPUT"
if [ "$TARGET_ENV" == 'luxadmosam' ]; then
echo 'stage=luxproduction' >> "$GITHUB_OUTPUT"
else
echo 'stage=production' >> "$GITHUB_OUTPUT"
fi
else
echo 'stage=staging' >> "$GITHUB_OUTPUT"
fi
Expand Down Expand Up @@ -130,8 +148,12 @@ jobs:
steps:
- name: Get environment URL
id: get_url
env:
TARGET_ENV: ${{ github.event.inputs.target_env }}
run: |
if [ "$GITHUB_REF_NAME" = 'master' ]; then
if [ "$TARGET_ENV" == 'luxadmosam' ] && [ "$GITHUB_REF_NAME" = 'master' ]; then
echo 'environment_url=https://luxstreep.csvalpha.nl' >> "$GITHUB_OUTPUT"
elif [ "$GITHUB_REF_NAME" = 'master' ]; then
echo 'environment_url=https://streep.csvalpha.nl' >> "$GITHUB_OUTPUT"
else
echo 'environment_url=https://stagingstreep.csvalpha.nl' >> "$GITHUB_OUTPUT"
Expand Down
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ AllCops:
Rails/UnknownEnv:
Environments:
- production
- luxproduction
- development
- test
- staging
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ARG RAILS_MASTER_KEY

# Pre-install gems, so that they can be cached.
COPY Gemfile* /app/
RUN if [ "$RAILS_ENV" = 'production' ] || [ "$RAILS_ENV" = 'staging' ]; then \
RUN if [ "$RAILS_ENV" = 'production' ] || [ "$RAILS_ENV" = 'staging' ] || [ "$RAILS_ENV" = 'luxproduction' ]; then \
bundle config set --local without 'development test'; \
else \
bundle config set --local without 'development'; \
Expand All @@ -44,7 +44,7 @@ COPY . /app/

# Precompile assets after copying app because whole Rails pipeline is needed.
RUN --mount=type=secret,id=rails_master_key \
if [ "$RAILS_ENV" = 'production' ] || [ "$RAILS_ENV" = 'staging' ]; then \
if [ "$RAILS_ENV" = 'production' ] || [ "$RAILS_ENV" = 'staging' ] || [ "$RAILS_ENV" = 'luxproduction' ]; then \
# Use secret if RAILS_MASTER_KEY build arg is not set.
RAILS_MASTER_KEY="${RAILS_MASTER_KEY:-$(cat /run/secrets/rails_master_key)}" bundle exec rails assets:precompile; \
else \
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ gem 'omniauth', '~> 2.1.1'
gem 'omniauth-oauth2', '~> 1.8.0'
gem 'omniauth-rails_csrf_protection', '~> 1.0', '>= 1.0.1'
gem 'paper_trail', '~> 14.0.0'
gem 'paranoia', '~> 2.6.1'
gem 'paranoia', '~> 3.0.0'
gem 'pg', '~> 1.5.3'
gem 'puma', '~> 6.2.2'
gem 'pundit', '~> 2.3.0'
Expand Down
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ GEM
sidekiq (>= 6.0)
coderay (1.1.3)
colorize (0.8.1)
concurrent-ruby (1.2.2)
concurrent-ruby (1.3.4)
connection_pool (2.4.0)
consistency_fail (0.3.7)
crass (1.0.6)
Expand All @@ -113,7 +113,7 @@ GEM
devise-i18n (1.11.0)
devise (>= 4.9.0)
diff-lcs (1.5.0)
digest (3.1.0)
digest (3.1.1)
docile (1.4.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
Expand Down Expand Up @@ -183,7 +183,7 @@ GEM
domain_name (~> 0.5)
http-form_data (2.3.0)
http_parser.rb (0.8.0)
i18n (1.13.0)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
jbuilder (2.11.5)
actionview (>= 5.0.0)
Expand Down Expand Up @@ -234,7 +234,7 @@ GEM
mini_portile2 (2.8.2)
mini_racer (0.6.3)
libv8-node (~> 16.10.0.0)
minitest (5.18.0)
minitest (5.24.1)
mollie-api-ruby (4.7.1)
msgpack (1.7.0)
multi_json (1.15.0)
Expand Down Expand Up @@ -290,8 +290,8 @@ GEM
activerecord (>= 6.0)
request_store (~> 1.4)
parallel (1.23.0)
paranoia (2.6.1)
activerecord (>= 5.1, < 7.1)
paranoia (3.0.0)
activerecord (>= 6, < 8.1)
parser (3.2.2.1)
ast (~> 2.4.1)
pg (1.5.3)
Expand Down Expand Up @@ -497,7 +497,7 @@ GEM
tilt (2.1.0)
timecop (0.9.5)
timeliness (0.4.5)
timeout (0.3.0)
timeout (0.3.1)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
Expand Down Expand Up @@ -573,7 +573,7 @@ DEPENDENCIES
omniauth-oauth2 (~> 1.8.0)
omniauth-rails_csrf_protection (~> 1.0, >= 1.0.1)
paper_trail (~> 14.0.0)
paranoia (~> 2.6.1)
paranoia (~> 3.0.0)
pg (~> 1.5.3)
pry-byebug
pry-rails
Expand Down
105 changes: 72 additions & 33 deletions app/assets/stylesheets/price_lists.scss
Original file line number Diff line number Diff line change
@@ -1,60 +1,99 @@
@import 'theme_sofia';

.center-text {
margin: 0 auto;
text-align: center;
}
.price-lists-table {
width: fit-content;
max-height: calc(100vh - 18rem);

.center-text {
margin: 0 auto;
text-align: center;
}

th {
&.products-id {
.products-id,
.products-cancel-edit {
left: 0;
width: 1.75rem;
}

&.products-actions {
width: 4rem;
.products-name {
left: 2.1rem;
width: 6rem;
}

.products-actions,
.products-new-edit-button,
.products-save-new {
right: 0;
}

.products-id,
.products-cancel-edit,
.products-name,
.products-new-edit-button,
.products-save-new {
position: sticky;
z-index: 1;
background-color: $body-bg;
}

.products-actions {
position: sticky;
z-index: 1;
}

thead {
position: sticky;
top: 0;
z-index: 2;
background-color: $body-bg;
}

th {
&.products-actions {
width: 4rem;
}
}
}

.price_lists_table {
tr {
&:last-child {
td {
border-bottom-width: 0;
}
}
}
}

td {
&.products-new-edit-button {
padding: .5rem 1rem;
}

&.products-new {
input {
&.form-control {
width: 6rem;
}
td {
&.products-new-edit-button {
padding: .5rem 1rem;
}

select {
&.form-control {
width: 4rem;
&.products-new {
input {
&.form-control {
width: 6rem;
}
}

select {
&.form-control {
width: 4rem;
}
}
}
}

&.products-new-price {
input {
&.form-control {
width: 2rem;
&.products-new-price {
input {
&.form-control {
width: 4rem;
}
}
}
}

&.products-cancel-new,
&.products-cancel-edit,
&.products-save-new {
vertical-align: middle;
&.products-cancel-new,
&.products-cancel-edit,
&.products-save-new {
vertical-align: middle;
}
}
}
2 changes: 1 addition & 1 deletion app/controllers/credit_mutations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def create # rubocop:disable Metrics/MethodLength, Metrics/AbcSize

respond_to do |format|
if @mutation.save
NewCreditMutationNotificationJob.perform_later(@mutation) if Rails.env.production? || Rails.env.staging?
NewCreditMutationNotificationJob.perform_later(@mutation) if Rails.env.production? || Rails.env.staging? || Rails.env.luxproduction?
format.html { redirect_to which_redirect?, flash: { success: 'Inleg of mutatie aangemaakt' } }
format.json do
render json: @mutation, include: { user: { methods: User.orderscreen_json_includes } }
Expand Down
16 changes: 12 additions & 4 deletions app/controllers/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ def create # rubocop:disable Metrics/AbcSize
end
end

def add
def add # rubocop:disable Metrics/AbcSize
authorize :payment

if Rails.application.config.x.mollie_api_key.blank?
flash[:error] = 'iDEAL is niet beschikbaar'
redirect_to users_path
return
end

@user = current_user
@payment = Payment.new

Expand All @@ -39,16 +45,18 @@ def callback # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/Pe
end

if payment.completed?
flash[:error] = 'Deze betaling is al gesloten. Mocht het bedrag niet bij uw inleg staan neem dan contact op met de penningmeester.'
flash[:error] =
"Deze betaling is al gesloten. Mocht het bedrag niet bij uw inleg staan
neem dan contact op met de #{Rails.application.config.x.treasurer_title}"
else
tries = 3
begin
payment.update(status: payment.mollie_payment.status)
if payment.mollie_payment.paid?
flash[:success] = 'iDEAL betaling geslaagd'
else
flash[:error] = 'Uw iDEAL betaling is mislukt.
Mocht het bedrag wel van uw rekening zijn gegaan neem dan contact op met de penningmeester'
flash[:error] = "Uw iDEAL betaling is mislukt. Mocht het bedrag wel van uw rekening zijn gegaan
neem dan contact op met de #{Rails.application.config.x.treasurer_title}"
end
rescue ActiveRecord::StaleObjectError => e
raise e unless (tries -= 1).positive?
Expand Down
Loading

0 comments on commit 590e431

Please sign in to comment.