mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-16 13:14:03 +00:00
fixes
This commit is contained in:
parent
1cbf78df3d
commit
aeb28833f1
8 changed files with 39 additions and 30 deletions
|
|
@ -196,4 +196,11 @@ module ApplicationHelper
|
|||
end
|
||||
return providers
|
||||
end
|
||||
|
||||
# Receives a hash, generated from User model, function get_roles
|
||||
# Outputs the roles of a user, including the conferences for which the user has the roles
|
||||
# Eg. organizer(oSC13, oSC14), cfp(oSC12, oSC13)
|
||||
def show_roles(roles)
|
||||
roles.map { |x| x[0].titleize + ' ' + x[1] }.join ', '
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -99,8 +99,8 @@ class Ability
|
|||
can :manage, SponsorshipLevel, conference_id: conf_ids_for_organizer
|
||||
can :manage, SupporterLevel, conference_id: conf_ids_for_organizer
|
||||
can :manage, Target, conference_id: conf_ids_for_organizer
|
||||
can :manage, Commercial # , commercialable_type: 'Conference', commercialable_id: conf_ids_for_organizer
|
||||
can :index, Commercial, commercialable_type: 'Conference'
|
||||
can :manage, Commercial, commercialable_type: 'Conference', commercialable_id: conf_ids_for_organizer
|
||||
# Manage commercials for events that belong to a conference of which user is organizer
|
||||
can :manage, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(conference_id: conf_ids_for_organizer + conf_ids_for_cfp).pluck(:id)
|
||||
can :manage, Contact, conference_id: conf_ids_for_organizer
|
||||
|
|
@ -114,6 +114,8 @@ class Ability
|
|||
conference.make_conference_public == true
|
||||
end
|
||||
|
||||
# see commercials too
|
||||
|
||||
can :show, Event do |event|
|
||||
event.state == 'confirmed'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -48,10 +48,6 @@ class User < ActiveRecord::Base
|
|||
user
|
||||
end
|
||||
|
||||
def get_roles
|
||||
roles
|
||||
end
|
||||
|
||||
def setup_role
|
||||
self.is_admin = true if User.count == 0
|
||||
end
|
||||
|
|
@ -59,7 +55,7 @@ class User < ActiveRecord::Base
|
|||
# Gets the roles of the user, groups them by role.name and returns the resource(s) of each role
|
||||
# ====Returns
|
||||
# * +Hash+ * -> e.g. 'organizer' => "(conf1, conf2)"
|
||||
def show_roles
|
||||
def get_roles
|
||||
result = {}
|
||||
Role::ACTIONABLES.each do |role|
|
||||
resources = self.roles.where(name: role.parameterize.underscore).map{ |myrole| Conference.find(myrole.resource_id).short_title }.join ', '
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@
|
|||
%td
|
||||
= user.registrations.where(attended: true).count
|
||||
%td
|
||||
- unless user.show_roles.blank?
|
||||
= user.show_roles.first(2).map { |x| x[0].titleize + ' ' + x[1] }.join ', '
|
||||
- if user.show_roles.count > 2
|
||||
- unless user.get_roles.blank?
|
||||
= show_roles(user.get_roles.first(2))
|
||||
- if user.get_roles.count > 2
|
||||
= '...'
|
||||
- if can? :show, user
|
||||
%td
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
- if can? :edit, @user
|
||||
.pull-right
|
||||
= link_to "Edit", edit_admin_user_path(@user), class: 'btn btn-primary'
|
||||
%table.table
|
||||
- @show_attributes.each do |attr|
|
||||
%tr
|
||||
|
|
@ -6,6 +9,6 @@
|
|||
= attr.capitalize.gsub('_', ' ')
|
||||
- if attr == 'roles'
|
||||
%td
|
||||
= @user.show_roles.map { |x| x[0].titleize + ' ' + x[1] }.join ', '
|
||||
= show_roles(@user.get_roles)
|
||||
- else
|
||||
%td= @user.send(attr)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
= link_to(admin_conference_path(@conference.short_title)) do
|
||||
%span.fa.fa-tachometer
|
||||
Dashboard
|
||||
- if can? :update, @conference
|
||||
- if can? :show, @conference
|
||||
%li{:class=> "#{active_nav_li(edit_admin_conference_path(@conference.short_title))}"}
|
||||
= link_to(edit_admin_conference_path(@conference.short_title)) do
|
||||
%span.fa.fa-home
|
||||
|
|
@ -38,16 +38,16 @@
|
|||
= link_to(edit_admin_conference_contact_path(@conference.short_title)) do
|
||||
%span.fa.fa-envelope-o
|
||||
Contact
|
||||
- if can? :index, @conference.commercials.build
|
||||
%li{:class=> "#{active_nav_li(admin_conference_commercials_path(@conference.short_title))}"}
|
||||
= link_to(admin_conference_commercials_path(@conference.short_title)) do
|
||||
%span.fa.fa-film
|
||||
Commercials
|
||||
- if can? :update, @conference.photos.build
|
||||
%li{:class=> "#{active_nav_li(admin_conference_photos_path(@conference.short_title))}"}
|
||||
= link_to(admin_conference_photos_path(@conference.short_title)) do
|
||||
%span.fa.fa-picture-o
|
||||
Photos
|
||||
- if can? :index, @conference.commercials.build
|
||||
%li{:class=> "#{active_nav_li(admin_conference_commercials_path(@conference.short_title))}"}
|
||||
= link_to(admin_conference_commercials_path(@conference.short_title)) do
|
||||
%span.fa.fa-film
|
||||
Commercials
|
||||
- if can? :update, @conference.photos.build
|
||||
%li{:class=> "#{active_nav_li(admin_conference_photos_path(@conference.short_title))}"}
|
||||
= link_to(admin_conference_photos_path(@conference.short_title)) do
|
||||
%span.fa.fa-picture-o
|
||||
Photos
|
||||
- if can? :update, @conference.events.build
|
||||
%li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))}
|
||||
= link_to(admin_conference_events_path(@conference.short_title)) do
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ Osem::Application.routes.draw do
|
|||
post :add_user
|
||||
delete :remove_user
|
||||
end
|
||||
resource :contact, except: [:index, :new, :create]
|
||||
resource :contact, except: [:index, :new, :create, :show, :destroy]
|
||||
resources :photos, except: [:show]
|
||||
resource :schedule, only: [:show, :update]
|
||||
resources :commercials, except: [:show]
|
||||
|
|
@ -98,10 +98,10 @@ Osem::Application.routes.draw do
|
|||
resource :schedule, only: [] do
|
||||
get "/" => "schedule#index"
|
||||
end
|
||||
get "/register" => "conference_registration#register"
|
||||
patch "/register" => "conference_registration#update"
|
||||
delete "/register" => "conference_registration#unregister"
|
||||
member do
|
||||
get "/register" => "conference_registration#register"
|
||||
patch "/register" => "conference_registration#update"
|
||||
delete "/register" => "conference_registration#unregister"
|
||||
get "gallery_photos"
|
||||
patch "subscription" => "conference#subscribe"
|
||||
delete "subscription" => "conference#unsubscribe"
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ feature 'Has correct abilities' do
|
|||
sign_in user
|
||||
visit admin_conference_path(conference2.short_title)
|
||||
|
||||
expect(page.has_content?('Basics')).to be false
|
||||
expect(page.has_content?('Basics')).to be true
|
||||
expect(page.has_content?('Dashboard')).to be true
|
||||
# expect(page.has_content?('Registrations')).to be false
|
||||
expect(page.has_content?('Events')).to be true
|
||||
|
|
@ -94,7 +94,7 @@ feature 'Has correct abilities' do
|
|||
expect(page.has_content?('E-Mails')).to be true
|
||||
expect(page.has_content?('Call for papers')).to be true
|
||||
expect(page.has_content?('Questions')).to be false
|
||||
# expect(page.has_content?('Commercials')).to be true
|
||||
expect(page.has_content?('Commercials')).to be true
|
||||
|
||||
visit edit_admin_conference_path(conference2.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
|
@ -143,7 +143,7 @@ feature 'Has correct abilities' do
|
|||
sign_in user
|
||||
visit admin_conference_path(conference3.short_title)
|
||||
|
||||
expect(page.has_content?('Basics')).to be false
|
||||
expect(page.has_content?('Basics')).to be true
|
||||
expect(page.has_content?('Dashboard')).to be true
|
||||
expect(page.has_content?('Registrations')).to be true
|
||||
expect(page.has_content?('Events')).to be false
|
||||
|
|
@ -205,8 +205,9 @@ feature 'Has correct abilities' do
|
|||
scenario 'when user is volunteer coordinator' do
|
||||
sign_in user
|
||||
visit admin_conference_path(conference4.short_title)
|
||||
save_and_open_page
|
||||
|
||||
expect(page.has_content?('Basics')).to be false
|
||||
expect(page.has_content?('Basics')).to be true
|
||||
expect(page.has_content?('Dashboard')).to be true
|
||||
# expect(page.has_content?('Registrations')).to be false
|
||||
expect(page.has_content?('Events')).to be false
|
||||
|
|
@ -219,7 +220,7 @@ feature 'Has correct abilities' do
|
|||
expect(page.has_content?('E-Mails')).to be false
|
||||
expect(page.has_content?('Call for papers')).to be false
|
||||
expect(page.has_content?('Questions')).to be false
|
||||
# expect(page.has_content?('Commercials')).to be true
|
||||
expect(page.has_content?('Commercials')).to be true
|
||||
|
||||
visit edit_admin_conference_path(conference4.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue