Commit 65a0c165 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻
Browse files

Merge branch '447-neue-top-menu-punkt-halbjahresfeedback' into 'develop'

Resolve "Neue Top Menu Punkt Halbjahresfeedback"

Closes #447

See merge request !815
parents c8e992f0 a7a5217c
Pipeline #28536 failed with stage
in 16 minutes and 16 seconds
class SemesterProcessesController < ApplicationController
before_action :set_semester_process, only: [:show, :edit, :update, :destroy]
def index
authorize SemesterProcess
@semester_processes = SemesterProcess.all.paginate(page: params[:page])
end
def show; end
def new
@semester_process = SemesterProcess.new
authorize @semester_process
end
def edit; end
def create
@semester_process = SemesterProcess.new(semester_process_params)
@semester_process.creator = current_user
authorize @semester_process
if @semester_process.save
redirect_to @semester_process, notice: 'Semester process was successfully created.'
else
render :new
end
end
def update
if @semester_process.update(semester_process_params)
redirect_to @semester_process, notice: 'Semester process was successfully updated.'
else
render :edit
end
end
def destroy
if @semester_process.destroy
redirect_to semester_processes_url, notice: 'Semester process was successfully destroyed.'
else
redirect_to semester_processes_url, notice: 'Failure notice'
end
end
private
def set_semester_process
@semester_process = SemesterProcess.find(params[:id])
authorize @semester_process
end
def semester_process_params
params.require(:semester_process).permit(:period_start, :period_end)
end
end
class SemesterProcess < ApplicationRecord
belongs_to :creator, -> { with_deleted }, class_name: 'User', inverse_of: 'semester_processes'
end
......@@ -79,8 +79,11 @@ class User < ApplicationRecord
has_many :mailing_processes_submitted, through: :mailing_volunteer_processes_submitted,
source: :process_submitted_by
has_many :semester_processes, inverse_of: 'creator', foreign_key: 'creator_id'
has_and_belongs_to_many :department
# Roles definition
SUPERADMIN = 'superadmin'.freeze
SOCIAL_WORKER = 'social_worker'.freeze
......
class SemesterProcessPolicy < ApplicationPolicy
class Scope < ApplicationScope
def resolve
return all if superadmin?
none
end
end
# Actions
alias_method :index?, :superadmin?
alias_method :new?, :superadmin?
alias_method :show?, :superadmin?
alias_method :edit?, :superadmin?
alias_method :create?, :superadmin?
alias_method :update?, :superadmin?
alias_method :destroy?, :superadmin?
end
......@@ -21,6 +21,8 @@ nav.navbar.navbar-top.hidden-print
li= link_to 'Begleitungen', assignments_path
- if policy(GroupOffer).index?
li= link_to 'Gruppenangebote', group_offers_path
- if policy(SemesterProcess).index?
li= link_to 'Semester Prozesse', semester_processes_path
- if policy(ReminderMailing).index?
li = link_to 'Erinnerungs-Emails', reminder_mailings_path
- if policy(Event).index?
......
= simple_form_for(@semester_process) do |f|
= simple_error_notice f
.row
.col-xs-12
= f.input :period, as: :date_range_picker, label: false
.row
.col-xs-12
= f.button :submit
nav.navbar.section-navigation
hr
ul.list-inline
li= button_link 'Neuen Semester Prozess erstellen', new_semester_process_path, dimension: 'sm'
hr
h1= t_title(:edit)
= render 'form'
= form_navigation_btn :show
= form_navigation_btn :back
h1= t_title(:index)
= render 'index_nav'
= bootstrap_paginate(@semester_processes)
.table-responsive
table.table.table-striped
thead
tr
th.hidden-print Aktionen
th= t_attr(:creator)
th= t_attr(:period)
th= t_attr(:created_at)
tbody
- @semester_processes.each do |semester_process|
tr
td.index-action-cell.hidden-print
= link_to t_action(:show), semester_process
= link_to t_action(:edit), edit_semester_process_path(semester_process)
= link_to navigation_glyph(:delete), semester_process_path(semester_process), confirm_deleting(semester_process)
td = semester_process.creator
td = semester_process.period_start
td = semester_process.period_end
= bootstrap_paginate(@semester_processes)
= render 'index_nav'
h1= t_title(:new)
= render 'form'
= form_navigation_btn :back
h1= t_title(:new)
p
strong User:
= @semester_process.creator
p
strong Semester start:
= @semester_process.period_start
p
strong Semester end:
= @semester_process.period_end
= form_navigation_btn :edit
= form_navigation_btn :back
......@@ -440,6 +440,11 @@ de:
kind: Art
body: Text
subject: Betreff
semester_process:
period: Semester
period_start: Semester anfang
period_end: Semester ende
creator: Ersteller/in
user:
<<: *id-generic_keys
clients: Kunden/innen
......@@ -554,6 +559,7 @@ de:
profile: Profil
relative: Verwante/r
reminder_mailing: Erinnerungs-Mailing
semester_process: Semester Prozess
trial_feedback: Probezeit Feedback
user: Benutzer/in
volunteer: Freiwillige/n
......
......@@ -68,6 +68,7 @@ Rails.application.routes.draw do
end
resources :feedbacks, only: [:new, :create]
resources :group_assignments, only: [:show, :create, :edit, :update],
concerns: [:submit_feedback, :termination_actions] do
put :set_end_today, on: :member
......@@ -95,6 +96,8 @@ Rails.application.routes.draw do
get :send_half_year, on: :member
end
resources :semester_processes
resources :volunteer_applications, only: [:new, :create] do
get :thanks, on: :collection
end
......
class CreateSemesterProcesses < ActiveRecord::Migration[5.1]
def change
create_table :semester_processes do |t|
t.references :creator, references: :users, index: true
t.datetime :period_start
t.datetime :period_end
t.datetime :deleted_at, index: true
t.timestamps
end
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180713084814) do
ActiveRecord::Schema.define(version: 20181004121332) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -284,7 +284,7 @@ ActiveRecord::Schema.define(version: 20180713084814) do
end
create_table "events", force: :cascade do |t|
t.integer "kind"
t.integer "kind", null: false
t.date "date"
t.time "start_time"
t.time "end_time"
......@@ -624,6 +624,17 @@ ActiveRecord::Schema.define(version: 20180713084814) do
t.index ["deleted_at"], name: "index_reminder_mailings_on_deleted_at"
end
create_table "semester_processes", force: :cascade do |t|
t.bigint "creator_id"
t.datetime "period_start"
t.datetime "period_end"
t.datetime "deleted_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["creator_id"], name: "index_semester_processes_on_creator_id"
t.index ["deleted_at"], name: "index_semester_processes_on_deleted_at"
end
create_table "trial_feedbacks", force: :cascade do |t|
t.text "body"
t.integer "trial_feedbackable_id"
......
FactoryBot.define do
factory :semester_process do
association :creator, factory: :user
period_start { Time.zone.local(2017, 12, 1).beginning_of_day }
period_end { Time.zone.local(2018, 5, 30).end_of_month }
end
end
require 'test_helper'
class SemesterProcessTest < ActiveSupport::TestCase
# TODO: Write model test
end
require 'application_system_test_case'
class SemesterProcessesTest < ApplicationSystemTestCase
# TODO: Write system test
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment