Resoved issues for managing workshop facilitators
This commit is contained in:
parent
ac915f3577
commit
7a7bb7b579
@ -649,7 +649,7 @@ fieldset {
|
|||||||
margin: 0 1em;
|
margin: 0 1em;
|
||||||
|
|
||||||
button, .button {
|
button, .button {
|
||||||
margin: 0 0.25em;
|
margin: 0 0.25em 1em;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1583,24 +1583,27 @@ body.policy .policy-agreement ul {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
||||||
.facilitator {
|
.facilitator {
|
||||||
margin: 0 0 0.5em 1.25em;
|
margin: 0 0 0.5em 0.5em;
|
||||||
|
padding: 1.5em 0.5em 0.5em;
|
||||||
|
border-top: 0.1em solid #CCC;
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
border: 0;
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.name {
|
.name {
|
||||||
position: relative;
|
position: relative;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
@include before {
|
.details {
|
||||||
content: '';
|
margin-top: 0.5em;
|
||||||
position: absolute;
|
}
|
||||||
width: 0.3em;
|
|
||||||
height: 0.3em;
|
.email {
|
||||||
background-color: #333;
|
margin-bottom: 0.5em;
|
||||||
border-radius: 50%;
|
|
||||||
left: -0.75em;
|
|
||||||
top: 0.5em;
|
|
||||||
@include _(opacity, 0.5);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.name, .role {
|
.name, .role {
|
||||||
@ -1616,7 +1619,7 @@ body.policy .policy-agreement ul {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@include after {
|
@include after {
|
||||||
content: '), ';
|
content: ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
|
@ -1083,8 +1083,11 @@ class ConferencesController < ApplicationController
|
|||||||
# creat the new interest row if we weren't interested before
|
# creat the new interest row if we weren't interested before
|
||||||
WorkshopInterest.create(:workshop_id => workshop.id, :user_id => current_user.id) unless interested
|
WorkshopInterest.create(:workshop_id => workshop.id, :user_id => current_user.id) unless interested
|
||||||
|
|
||||||
# go back to the workshop
|
if request.xhr?
|
||||||
redirect_to view_workshop_url(@this_conference.slug, workshop.id)
|
else
|
||||||
|
# go back to the workshop
|
||||||
|
redirect_to view_workshop_url(@this_conference.slug, workshop.id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def facilitate_workshop
|
def facilitate_workshop
|
||||||
@ -1127,16 +1130,18 @@ class ConferencesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def approve_facilitate_request
|
def approve_facilitate_request
|
||||||
|
return do_403 unless logged_in?
|
||||||
set_conference
|
set_conference
|
||||||
set_conference_registration
|
set_conference_registration
|
||||||
workshop = Workshop.find_by_id_and_conference_id(params[:workshop_id], @this_conference.id)
|
workshop = Workshop.find_by_id_and_conference_id(params[:workshop_id], @this_conference.id)
|
||||||
return do_404 unless workshop && current_user
|
return do_404 unless workshop.present?
|
||||||
|
|
||||||
user_id = params[:user_id].to_i
|
user_id = params[:user_id].to_i
|
||||||
action = params[:approve_or_deny].to_sym
|
action = params[:approve_or_deny].to_sym
|
||||||
user = User.find(user_id)
|
user = User.find(user_id)
|
||||||
if action == :approve
|
case action
|
||||||
if current_user && workshop.active_facilitator?(current_user) && workshop.requested_collaborator?(User.find(user_id))
|
when :approve
|
||||||
|
if workshop.active_facilitator?(current_user) && workshop.requested_collaborator?(User.find(user_id))
|
||||||
f = WorkshopFacilitator.find_by_workshop_id_and_user_id(
|
f = WorkshopFacilitator.find_by_workshop_id_and_user_id(
|
||||||
workshop.id, user_id)
|
workshop.id, user_id)
|
||||||
f.role = :collaborator
|
f.role = :collaborator
|
||||||
@ -1148,8 +1153,8 @@ class ConferencesController < ApplicationController
|
|||||||
end
|
end
|
||||||
return redirect_to view_workshop_url(@this_conference.slug, workshop.id)
|
return redirect_to view_workshop_url(@this_conference.slug, workshop.id)
|
||||||
end
|
end
|
||||||
elsif action == :deny
|
when :deny
|
||||||
if current_user && workshop.active_facilitator?(current_user) && workshop.requested_collaborator?(User.find(user_id))
|
if workshop.active_facilitator?(current_user) && workshop.requested_collaborator?(User.find(user_id))
|
||||||
WorkshopFacilitator.delete_all(
|
WorkshopFacilitator.delete_all(
|
||||||
:workshop_id => workshop.id,
|
:workshop_id => workshop.id,
|
||||||
:user_id => user_id)
|
:user_id => user_id)
|
||||||
@ -1160,13 +1165,23 @@ class ConferencesController < ApplicationController
|
|||||||
end
|
end
|
||||||
return redirect_to view_workshop_url(@this_conference.slug, workshop.id)
|
return redirect_to view_workshop_url(@this_conference.slug, workshop.id)
|
||||||
end
|
end
|
||||||
elsif action == :remove
|
when :remove
|
||||||
if current_user && current_user.id == user_id
|
if workshop.can_remove?(current_user, user)
|
||||||
unless workshop.creator?(user)
|
WorkshopFacilitator.delete_all(
|
||||||
WorkshopFacilitator.delete_all(
|
:workshop_id => workshop.id,
|
||||||
:workshop_id => workshop.id,
|
:user_id => user_id)
|
||||||
:user_id => user_id)
|
return redirect_to view_workshop_url(@this_conference.slug, workshop.id)
|
||||||
end
|
end
|
||||||
|
when :switch_ownership
|
||||||
|
if workshop.creator?(current_user)
|
||||||
|
f = WorkshopFacilitator.find_by_workshop_id_and_user_id(
|
||||||
|
workshop.id, current_user.id)
|
||||||
|
f.role = :collaborator
|
||||||
|
f.save
|
||||||
|
f = WorkshopFacilitator.find_by_workshop_id_and_user_id(
|
||||||
|
workshop.id, user_id)
|
||||||
|
f.role = :creator
|
||||||
|
f.save
|
||||||
return redirect_to view_workshop_url(@this_conference.slug, workshop.id)
|
return redirect_to view_workshop_url(@this_conference.slug, workshop.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -62,6 +62,14 @@ class Workshop < ActiveRecord::Base
|
|||||||
creator?(user) || collaborator?(user) || conference.host?(user)
|
creator?(user) || collaborator?(user) || conference.host?(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_remove?(owner, facilitator)
|
||||||
|
# creators cannot be removed
|
||||||
|
return false if creator?(facilitator)
|
||||||
|
|
||||||
|
# creator can remove anyone, facilitators can remove themselves
|
||||||
|
return creator?(owner) || owner.id == facilitator.id
|
||||||
|
end
|
||||||
|
|
||||||
def can_delete?(user)
|
def can_delete?(user)
|
||||||
creator?(user) || conference.host?(user)
|
creator?(user) || conference.host?(user)
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
= fieldset :hosting_dates, heading: 'articles.conference_registration.headings.host.availability', help: 'articles.conference_registration.paragraphs.host.availability' do
|
= fieldset :hosting_dates, heading: 'articles.conference_registration.headings.host.availability', help: 'articles.conference_registration.paragraphs.host.availability' do
|
||||||
= selectfield :first_day, @hosting_data['availability'][0] || @this_conference.start_date, conference_housing_options_list(:before)
|
= selectfield :first_day, @hosting_data['availability'][0] || @this_conference.start_date, conference_housing_options_list(:before)
|
||||||
= selectfield :last_day, @hosting_data['availability'][1] || @this_conference.start_date, conference_housing_options_list(:after)
|
= selectfield :last_day, @hosting_data['availability'][1] || @this_conference.start_date, conference_housing_options_list(:after)
|
||||||
= checkboxes :considerations, [:vegan, :smoking, :quiet], @hosting_data['considerations'], 'articles.conference_registration.host.considerations', heading: 'articles.conference_registration.headings.host.considerations', help: 'articles.conference_registration.paragraphs.host.considerations', vertical: true
|
= checkboxes :considerations, [:vegan, :smoking, :pets, :quiet], @hosting_data['considerations'], 'articles.conference_registration.host.considerations', heading: 'articles.conference_registration.headings.host.considerations', help: 'articles.conference_registration.paragraphs.host.considerations', vertical: true
|
||||||
= textarea :notes, @hosting_data['notes'], heading: 'articles.conference_registration.headings.host.notes', help: 'articles.conference_registration.paragraphs.host.notes'
|
= textarea :notes, @hosting_data['notes'], heading: 'articles.conference_registration.headings.host.notes', help: 'articles.conference_registration.paragraphs.host.notes'
|
||||||
.actions.next-prev
|
.actions.next-prev
|
||||||
= button_tag (params[:step] == :save ? :save : :next), value: :hosting
|
= button_tag (params[:step] == :save ? :save : :next), value: :hosting
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
- is_facilitator = workshop.active_facilitator?(current_user)
|
||||||
= row class: 'view-object' do
|
= row class: 'view-object' do
|
||||||
= columns(medium: 12) do
|
= columns(medium: 12) do
|
||||||
%h2=_!workshop.title
|
%h2=_!workshop.title
|
||||||
@ -19,19 +20,26 @@
|
|||||||
.facilitators
|
.facilitators
|
||||||
- workshop.workshop_facilitators.each do |f|
|
- workshop.workshop_facilitators.each do |f|
|
||||||
- u = User.find(f.user_id)
|
- u = User.find(f.user_id)
|
||||||
- if logged_in? && (workshop.public_facilitator?(u) || f.user_id == current_user.id || workshop.active_facilitator?(current_user))
|
- if logged_in? && (workshop.public_facilitator?(u) || f.user_id == current_user.id || is_facilitator)
|
||||||
.facilitator
|
.facilitator
|
||||||
.name=_!u.name
|
.name=_!u.name
|
||||||
.role
|
.role
|
||||||
=_"roles.workshops.facilitator.#{workshop.role(u).to_s}"
|
=_"roles.workshops.facilitator.#{workshop.role(u).to_s}"
|
||||||
- if preview.blank? && f.role.to_sym == :requested && workshop.active_facilitator?(current_user)
|
- if is_facilitator && preview.blank?
|
||||||
|
.details
|
||||||
|
.email=u.email
|
||||||
|
- if f.role.to_sym == :requested
|
||||||
=(link_to (_'actions.workshops.Approve'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'approve'), :class => [:button, :modify])
|
=(link_to (_'actions.workshops.Approve'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'approve'), :class => [:button, :modify])
|
||||||
=(link_to (_'actions.workshops.Deny'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'deny'), :class => [:button, :delete])
|
=(link_to (_'actions.workshops.Deny'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'deny'), :class => [:button, :delete])
|
||||||
- elsif preview.blank? && (f.user_id == current_user.id && f.role.to_sym != :creator) || (!workshop.conference.registered?(u) && workshop.active_facilitator?(current_user))
|
- elsif workshop.can_remove?(current_user, u)
|
||||||
|
=(link_to (_'actions.workshops.Make_Owner'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'switch_ownership'), :class => [:button, :modify]) unless f.role.to_sym == :creator || !workshop.creator?(current_user)
|
||||||
|
=(link_to (_'actions.workshops.Remove'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'remove'), :class => [:button, :delete])
|
||||||
|
- if f.user_id == current_user.id && workshop.requested_collaborator?(current_user)
|
||||||
|
.details
|
||||||
=(link_to (_'actions.workshops.Remove'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'remove'), :class => [:button, :delete])
|
=(link_to (_'actions.workshops.Remove'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'remove'), :class => [:button, :delete])
|
||||||
- unless preview.present?
|
- unless preview.present?
|
||||||
=(link_to (_'actions.workshops.Facilitate'), facilitate_workshop_path(workshop.conference.slug, workshop.id), :class => [:button, workshop.needs_facilitators ? :accented : :subdued]) unless workshop.facilitator?(current_user)
|
=(link_to (_'actions.workshops.Facilitate'), facilitate_workshop_path(workshop.conference.slug, workshop.id), :class => [:button, workshop.needs_facilitators ? :accented : :subdued]) unless workshop.facilitator?(current_user)
|
||||||
- if workshop.active_facilitator?(current_user)
|
- if is_facilitator
|
||||||
%h4=_'articles.workshops.headings.add_facilitator','Add a facilitator'
|
%h4=_'articles.workshops.headings.add_facilitator','Add a facilitator'
|
||||||
= form_tag workshop_add_facilitator_path(workshop.conference.slug, workshop.id), :class => 'add-facilitator mini-flex-form' do
|
= form_tag workshop_add_facilitator_path(workshop.conference.slug, workshop.id), :class => 'add-facilitator mini-flex-form' do
|
||||||
.email-field.input-field
|
.email-field.input-field
|
||||||
@ -47,7 +55,7 @@
|
|||||||
= columns(medium: 6) do
|
= columns(medium: 6) do
|
||||||
%h3=_'articles.workshops.headings.theme','Theme'
|
%h3=_'articles.workshops.headings.theme','Theme'
|
||||||
%p= Workshop.all_themes.include?((workshop.theme || '').to_sym) ? (_"workshop.options.theme.#{workshop.theme}") : workshop.theme
|
%p= Workshop.all_themes.include?((workshop.theme || '').to_sym) ? (_"workshop.options.theme.#{workshop.theme}") : workshop.theme
|
||||||
- if workshop.active_facilitator?(current_user) || workshop.conference.host?(current_user)
|
- if is_facilitator || workshop.conference.host?(current_user)
|
||||||
- needs = JSON.parse(workshop.needs || '[]')
|
- needs = JSON.parse(workshop.needs || '[]')
|
||||||
- if needs.present?
|
- if needs.present?
|
||||||
= columns(medium: 6) do
|
= columns(medium: 6) do
|
||||||
|
@ -5398,6 +5398,7 @@ en:
|
|||||||
vegan: Vegan or vegetarian only
|
vegan: Vegan or vegetarian only
|
||||||
smoking: Smoking is permitted
|
smoking: Smoking is permitted
|
||||||
quiet: Quiet household
|
quiet: Quiet household
|
||||||
|
pets: House has dogs or cats
|
||||||
can_provide_housing: I can provide housing
|
can_provide_housing: I can provide housing
|
||||||
questions:
|
questions:
|
||||||
bike:
|
bike:
|
||||||
@ -5674,10 +5675,11 @@ en:
|
|||||||
roles:
|
roles:
|
||||||
workshops:
|
workshops:
|
||||||
facilitator:
|
facilitator:
|
||||||
creator: creator
|
creator: Owner
|
||||||
collaborator: Collaborator
|
collaborator: Collaborator
|
||||||
requested: Requested
|
requested: Requested
|
||||||
unregistered: Unregistered
|
unregistered: Unregistered
|
||||||
|
facilitator: Facilitator
|
||||||
workshop:
|
workshop:
|
||||||
options:
|
options:
|
||||||
needs:
|
needs:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user