Browse Source

Resoved issues for managing workshop facilitators

development
Godwin 9 years ago
parent
commit
7a7bb7b579
  1. 29
      app/assets/stylesheets/_application.scss
  2. 31
      app/controllers/conferences_controller.rb
  3. 8
      app/models/workshop.rb
  4. 2
      app/views/conferences/_hosting.html.haml
  5. 18
      app/views/workshops/_show.html.haml
  6. 4
      config/locales/en.yml

29
app/assets/stylesheets/_application.scss

@ -649,7 +649,7 @@ fieldset {
margin: 0 1em;
button, .button {
margin: 0 0.25em;
margin: 0 0.25em 1em;
vertical-align: middle;
}
@ -1583,24 +1583,27 @@ body.policy .policy-agreement ul {
display: inline-block;
.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 {
position: relative;
font-weight: bold;
}
@include before {
content: '';
position: absolute;
width: 0.3em;
height: 0.3em;
background-color: #333;
border-radius: 50%;
left: -0.75em;
top: 0.5em;
@include _(opacity, 0.5);
.details {
margin-top: 0.5em;
}
.email {
margin-bottom: 0.5em;
}
.name, .role {
@ -1616,7 +1619,7 @@ body.policy .policy-agreement ul {
}
@include after {
content: '), ';
content: ')';
}
&:last-child {

31
app/controllers/conferences_controller.rb

@ -1083,9 +1083,12 @@ class ConferencesController < ApplicationController
# creat the new interest row if we weren't interested before
WorkshopInterest.create(:workshop_id => workshop.id, :user_id => current_user.id) unless interested
if request.xhr?
else
# go back to the workshop
redirect_to view_workshop_url(@this_conference.slug, workshop.id)
end
end
def facilitate_workshop
set_conference
@ -1127,16 +1130,18 @@ class ConferencesController < ApplicationController
end
def approve_facilitate_request
return do_403 unless logged_in?
set_conference
set_conference_registration
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
action = params[:approve_or_deny].to_sym
user = User.find(user_id)
if action == :approve
if current_user && workshop.active_facilitator?(current_user) && workshop.requested_collaborator?(User.find(user_id))
case action
when :approve
if workshop.active_facilitator?(current_user) && workshop.requested_collaborator?(User.find(user_id))
f = WorkshopFacilitator.find_by_workshop_id_and_user_id(
workshop.id, user_id)
f.role = :collaborator
@ -1148,8 +1153,8 @@ class ConferencesController < ApplicationController
end
return redirect_to view_workshop_url(@this_conference.slug, workshop.id)
end
elsif action == :deny
if current_user && workshop.active_facilitator?(current_user) && workshop.requested_collaborator?(User.find(user_id))
when :deny
if workshop.active_facilitator?(current_user) && workshop.requested_collaborator?(User.find(user_id))
WorkshopFacilitator.delete_all(
:workshop_id => workshop.id,
:user_id => user_id)
@ -1160,13 +1165,23 @@ class ConferencesController < ApplicationController
end
return redirect_to view_workshop_url(@this_conference.slug, workshop.id)
end
elsif action == :remove
if current_user && current_user.id == user_id
unless workshop.creator?(user)
when :remove
if workshop.can_remove?(current_user, user)
WorkshopFacilitator.delete_all(
:workshop_id => workshop.id,
:user_id => user_id)
return redirect_to view_workshop_url(@this_conference.slug, workshop.id)
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)
end
end

8
app/models/workshop.rb

@ -62,6 +62,14 @@ class Workshop < ActiveRecord::Base
creator?(user) || collaborator?(user) || conference.host?(user)
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)
creator?(user) || conference.host?(user)
end

2
app/views/conferences/_hosting.html.haml

@ -17,7 +17,7 @@
= 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 :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'
.actions.next-prev
= button_tag (params[:step] == :save ? :save : :next), value: :hosting

18
app/views/workshops/_show.html.haml

@ -1,3 +1,4 @@
- is_facilitator = workshop.active_facilitator?(current_user)
= row class: 'view-object' do
= columns(medium: 12) do
%h2=_!workshop.title
@ -19,19 +20,26 @@
.facilitators
- workshop.workshop_facilitators.each do |f|
- 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
.name=_!u.name
.role
=_"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.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])
- 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)
- if workshop.active_facilitator?(current_user)
- if is_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
.email-field.input-field
@ -47,7 +55,7 @@
= columns(medium: 6) do
%h3=_'articles.workshops.headings.theme','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 || '[]')
- if needs.present?
= columns(medium: 6) do

4
config/locales/en.yml

@ -5398,6 +5398,7 @@ en:
vegan: Vegan or vegetarian only
smoking: Smoking is permitted
quiet: Quiet household
pets: House has dogs or cats
can_provide_housing: I can provide housing
questions:
bike:
@ -5674,10 +5675,11 @@ en:
roles:
workshops:
facilitator:
creator: creator
creator: Owner
collaborator: Collaborator
requested: Requested
unregistered: Unregistered
facilitator: Facilitator
workshop:
options:
needs:

Loading…
Cancel
Save