Skip to content

Commit

Permalink
Merge pull request #12 from hitobito/feature/11-anpassungen
Browse files Browse the repository at this point in the history
Anpassungen
  • Loading branch information
TheWalkingLeek authored Jul 18, 2023
2 parents 993284f + 99e6a92 commit b74ba0c
Show file tree
Hide file tree
Showing 22 changed files with 325 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ spec/coverage
spec/reports
brakeman-output.tabs
rubocop-results.xml
config/environment.rb
22 changes: 22 additions & 0 deletions app/abilities/jemk/group_ability.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

# Copyright (c) 2023-2023, Jungschar EMK. This file is part of
# hitobito_jemk and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_jemk.


module Jemk::GroupAbility
extend ActiveSupport::Concern

included do
on(Group) do
permission(:any).may(:'index_event/camps').all

permission(:group_full).may(:'export_event/camps').in_same_group
permission(:group_and_below_full).may(:'export_event/camps').in_same_group_or_below
permission(:layer_read).may(:'export_event/camps').in_same_layer
permission(:layer_and_below_read).may(:'export_event/camps').in_same_layer_or_below
end
end
end
15 changes: 9 additions & 6 deletions app/assets/stylesheets/hitobito/customizable/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ $white: #fff !default;

// Colors
// ----------------------------
$blue: #329897 !default;

$jemk_darkgreen: darken($jemk_green, 20%);

$blue: $emk_darkblue;
$blueDark: darken($blue, 10%) !default;
$green: #8DB850 !default;
$greenDark: darken($green, 10%) !default;
$green: $jemk_green !default;
$greenDark: $jemk_darkgreen;

$orange: #DC795B;
$orangeDark: #C75B3B;
$purple: $jemk_darkblue; // #925D97;
$purpleDark: darken($jemk_darkblue, 20%); //#6A396F;
$purple: $jemk_darkblue;
$purpleDark: darken($jemk_darkblue, 20%);

$red: $orange !default;

Expand All @@ -49,7 +52,7 @@ $bodyBackground: $jemk_darkblue;

$focusColor: $purple;
$shadowColor: darken($pageBackground, 10%);
$linkColor: $jemk_green !default;
$linkColor: $jemk_darkgreen !default;
$linkColorHover: $jemk_darkblue !default;

$footerColor: $jemk_black;
Expand Down
41 changes: 41 additions & 0 deletions app/controllers/jemk/event/lists_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# frozen_string_literal: true

# Copyright (c) 2023-2023, Jungschar EMK. This file is part of
# hitobito_jemk and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_jemk.

module Jemk::Event::ListsController

def camps
authorize!(:list_available, Event::Camp)

@grouped_events = grouped(upcoming_user_events_of_type(Event::Camp))
render :events
end

def events
authorize!(:list_available, Event)

@grouped_events = grouped(upcoming_user_events_of_type(Event, allow_null: true))
end

private

def upcoming_user_events
Event
.upcoming
.in_hierarchy(current_user)
.includes(:dates, :groups, :events_groups)
.order('event_dates.start_at ASC')
end

def upcoming_user_events_of_type(type, allow_null: false)
condition = OrCondition.new
condition.or('events.type = ?', type)
condition.or('events.type IS NULL') if allow_null

upcoming_user_events.where(condition.to_a)
end

end
23 changes: 23 additions & 0 deletions app/helpers/jemk/sheet/event/list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

# Copyright (c) 2023-2023, Jungschar EMK. This file is part of
# hitobito_jemk and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_jemk.

module Jemk::Sheet::Event::List
extend ActiveSupport::Concern

included do
alias_method_chain :render_left_nav, :camps
end

def render_left_nav_with_camps
if view.nav_left == 'camps'
view.render 'nav_left_events'
else
render_left_nav_without_camps
end
end

end
23 changes: 23 additions & 0 deletions app/helpers/jemk/sheet/group.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

# Copyright (c) 2023-2023, Jungschar EMK. This file is part of
# hitobito_jemk and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_jemk.


module Jemk::Sheet::Group
extend ActiveSupport::Concern

included do
tabs.insert(4,
Sheet::Tab.new('activerecord.models.event/camp.other',
:camp_group_events_path,
params: { returning: true },
if: lambda do |view, group|
group.event_types.include?(::Event::Camp) &&
view.can?(:'index_event/camps', group)
end))
end

end
16 changes: 16 additions & 0 deletions app/models/event/camp.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

# Copyright (c) 2023-2023, Jungschar EMK. This file is part of
# hitobito_jemk and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_jemk.

class Event::Camp < Event
self.used_attributes += [:waiting_list]

self.supports_applications = true

def tentative_application_possible?
false
end
end
6 changes: 6 additions & 0 deletions app/models/group/dachverband.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ class Group::Dachverband < ::Group
Group::DachverbandMitglieder
]

self.event_types = [
Event,
Event::Course
]

### ROLES

class Administrator < ::Role
self.permissions = [:admin, :layer_and_below_full, :impersonation]
self.two_factor_authentication_enforced = true
end

roles Administrator
Expand Down
2 changes: 2 additions & 0 deletions app/models/group/dachverband_geschaeftsstelle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
class Group::DachverbandGeschaeftsstelle < ::Group
class Geschaeftsleiter < ::Role
self.permissions = [:admin, :layer_and_below_full, :impersonation, :contact_data]
self.two_factor_authentication_enforced = true
end

class Angestellter < ::Role
self.permissions = [:admin, :layer_and_below_full, :impersonation, :contact_data]
self.two_factor_authentication_enforced = true
end

roles Geschaeftsleiter, Angestellter
Expand Down
5 changes: 5 additions & 0 deletions app/models/group/lagerverein.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ class Group::Lagerverein < ::Group

children Group::LagervereinVerein

self.event_types = [
Event,
Event::Camp
]

### ROLES

class Administrator < ::Role
Expand Down
5 changes: 5 additions & 0 deletions app/models/group/ortsjungschar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ class Group::Ortsjungschar < ::Group
Group::OrtsjungscharMitglieder
]

self.event_types = [
Event,
Event::Camp
]

### ROLES

class Hauptleiter < ::Role
Expand Down
5 changes: 5 additions & 0 deletions app/models/group/region.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class Group::Region < ::Group
Group::RegionMitglieder
]

self.event_types = [
Event,
Event::Course
]

### ROLES

class Administrator < ::Role
Expand Down
14 changes: 14 additions & 0 deletions app/models/jemk/event/participation_contact_data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

# Copyright (c) 2023-2023, Jungschar EMK. This file is part of
# hitobito_jemk and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_jemk.

module Jemk::Event::ParticipationContactData
extend ActiveSupport::Concern

included do
self.contact_attrs -= [:company_name, :company]
end
end
17 changes: 17 additions & 0 deletions app/models/jemk/person.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

# Copyright (c) 2023-2023, Jungschar EMK. This file is part of
# hitobito_jemk and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_jemk.

module Jemk::Person
extend ActiveSupport::Concern

included do
used_attributes.delete(:company)
used_attributes.delete(:company_name)

Person::FILTER_ATTRS.delete(:company_name)
end
end
7 changes: 7 additions & 0 deletions bin/wagon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -euo pipefail
IFS=$'\n\t'

cd ../hitobito
bin/wagon $@
18 changes: 18 additions & 0 deletions config/locales/jemk.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,21 @@ de:
group/ortsjungschar_mitglieder/passivmitglied:
one: Passivmitglied
# description: TODO

event/camp:
one: Lager
other: Lager

attributes:
person:
nickname: Jungscharname

events:
global:
link:
add_event/camp: Lager erstellen
new:
title_event/camp: Lager erstellen

navigation:
camps: Lager
9 changes: 9 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
language_scope do
# Define wagon routes here

resources :groups do
resources :events, only: [] do # do not redefine events actions, only add new ones
collection do
get 'camp' => 'events#index', type: 'Event::Camp'
end
end
end

get 'list_camps' => 'event/lists#camps', as: :list_camps
end

end
30 changes: 30 additions & 0 deletions lib/hitobito_jemk/wagon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,37 @@ class Wagon < Rails::Engine

config.to_prepare do
# extend application classes here

# Models
Group.include Jemk::Group
Person.include Jemk::Person
Event::ParticipationContactData.include Jemk::Event::ParticipationContactData

# Abilities
GroupAbility.include Jemk::GroupAbility
EventAbility.abilities[Event::Camp] =
EventAbility.abilities[Event] # Camp has same abilities as event

# Decorators
EventDecorator.icons['Event::Camp'] = :campground

# Sheets
Sheet::Group.include Jemk::Sheet::Group
Sheet::Event::List.include Jemk::Sheet::Event::List

# Controllers
Event::ListsController.prepend Jemk::Event::ListsController

# Main navigation
index_courses = NavigationHelper::MAIN.index { |opts| opts[:label] == :courses }
NavigationHelper::MAIN.insert(
index_courses + 1,
label: :camps,
icon_name: :campground,
url: :list_camps_path,
active_for: %w(list_camps),
if: ->(_) { can?(:list_available, Event::Camp) }
)
end

initializer 'jemk.add_settings' do |_app|
Expand Down
18 changes: 18 additions & 0 deletions spec/models/group/dachverband_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

# Copyright (c) 2023-2023, Jungschar EMK. This file is part of
# hitobito_jemk and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_jemk.

require 'spec_helper'

describe Group::Dachverband do
it 'supports events' do
expect(described_class.event_types).to include(Event)
end

it 'supports courses' do
expect(described_class.event_types).to include(Event::Course)
end
end
18 changes: 18 additions & 0 deletions spec/models/group/lagerverein_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

# Copyright (c) 2023-2023, Jungschar EMK. This file is part of
# hitobito_jemk and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_jemk.

require 'spec_helper'

describe Group::Lagerverein do
it 'supports events' do
expect(described_class.event_types).to include(Event)
end

it 'supports camps' do
expect(described_class.event_types).to include(Event::Camp)
end
end
Loading

0 comments on commit b74ba0c

Please sign in to comment.