check abilities

This commit is contained in:
Stella Rouzi 2014-07-18 07:08:06 +03:00
parent ffb290de0c
commit 07877f3256
8 changed files with 150 additions and 116 deletions

View file

@ -18,11 +18,13 @@
= ',' = ','
= label_tag dom_id(q), "Answers: #{q.answers.map {|a| a.title}.join(', ')}" = label_tag dom_id(q), "Answers: #{q.answers.map {|a| a.title}.join(', ')}"
%td= link_to 'Edit', edit_admin_conference_question_path(@conference.short_title, q), - if can? :update, q
class: 'btn btn-primary', %td= link_to 'Edit', edit_admin_conference_question_path(@conference.short_title, q),
disabled: q.global == true && !has_role?(current_user, 'Admin') class: 'btn btn-primary',
disabled: q.global == true
%td= link_to 'Delete', admin_conference_question_path(@conference.short_title, q), - if can? :destroy, q
method: :delete, remote: true, class: 'btn btn-danger', %td= link_to 'Delete', admin_conference_question_path(@conference.short_title, q),
confirm: "Delete question '#{q.title}'?", method: :delete, remote: true, class" 'btn btn-danger',
disabled: q.global == true && !has_role?(current_user, "Admin") confirm: "Delete question '#{q.title}'?",
disabled: q.global == true

View file

@ -7,9 +7,11 @@
= "(#{@registrations.length})" = "(#{@registrations.length})"
= " - Attended (#{@attended})" = " - Attended (#{@attended})"
.btn-group.pull-right .btn-group.pull-right
= link_to "New", new_admin_conference_registration_path(@conference.short_title), :class => "btn btn-default" - if can? :create, Registration
= link_to "Export PDF", admin_conference_registrations_path(@conference.short_title, :format => :pdf), :class => "btn btn-default" = link_to "New", new_admin_conference_registration_path(@conference.short_title), :class => "btn btn-default"
= link_to "Export XLS", {:format => :xlsx}, :class => "btn btn-default" - if can? :read, Registration
= link_to "Export PDF", admin_conference_registrations_path(@conference.short_title, :format => :pdf), :class => "btn btn-default"
= link_to "Export XLS", {:format => :xlsx}, :class => "btn btn-default"
%table.table.table-bordered.table-striped.table-hover#registrations %table.table.table-bordered.table-striped.table-hover#registrations
%thead %thead
%th %th
@ -21,7 +23,7 @@
%th %th
%th %th
%th %th
- counter = 0 - counter = 0
- @registrations.each do |registration| - @registrations.each do |registration|
%tr %tr
%td %td
@ -33,7 +35,7 @@
- if registration.supporter_level && registration.supporter_level.title != 'Free' - if registration.supporter_level && registration.supporter_level.title != 'Free'
%p{:style => "color:red"} %p{:style => "color:red"}
= registration.supporter_level.title = registration.supporter_level.title
-elsif field == 'attended' -elsif field == 'attended'
= link_to "#{registration.send(field.to_sym)}", admin_conference_registrations_change_field_path(@conference.short_title, :id => registration.id, :view_field => "#{field}"), :method => :patch, ":#{field}" => registration.send(field.to_sym), :class => "btn btn-success" = link_to "#{registration.send(field.to_sym)}", admin_conference_registrations_change_field_path(@conference.short_title, :id => registration.id, :view_field => "#{field}"), :method => :patch, ":#{field}" => registration.send(field.to_sym), :class => "btn btn-success"
@ -64,11 +66,11 @@
"bLengthChange": false "bLengthChange": false
} ); } );
} ); } );
function toggle(rowid) { function toggle(rowid) {
if( document.getElementById(rowid).style.display=='none' ){ if( document.getElementById(rowid).style.display=='none' ){
document.getElementById(rowid).style.display = ''; document.getElementById(rowid).style.display = '';
}else{ }else{
document.getElementById(rowid).style.display = 'none'; document.getElementById(rowid).style.display = 'none';
} }
}; };

View file

@ -5,7 +5,7 @@
- if @users - if @users
= "(#{@users.length})" = "(#{@users.length})"
= link_to "New User", new_admin_user_path, :class => "btn btn-success pull-right" = link_to "New User", new_admin_user_path, class: 'btn btn-success pull-right'
.well .well
%table.table.table-striped.table-bordered.table-hover#users %table.table.table-striped.table-bordered.table-hover#users
%thead %thead
@ -61,16 +61,22 @@
%button{:class=> "btn btn-danger", "data-dismiss"=> "modal", "aria-hidden"=>"true"} %button{:class=> "btn btn-danger", "data-dismiss"=> "modal", "aria-hidden"=>"true"}
Cancel Cancel
= f.action :submit, :as => :button, :button_html => {:value => "Save", :class => "btn btn-primary"} = f.action :submit, :as => :button, :button_html => {:value => "Save", :class => "btn btn-primary"}
=link_to "#{user.roles.map { |role| role.name }.join ', '}", "#", "data-toggle" => "modal", "data-target" => "#user-role-selection-#{user.id}",id: "user-modify-role-#{user.id}" - if can? :update, Role
%td =link_to "#{user.roles.map { |role| role.name }.join ', '}", "#", "data-toggle" => "modal", "data-target" => "#user-role-selection-#{user.id}",id: "user-modify-role-#{user.id}"
= link_to "Edit", edit_admin_user_path(user)
%td
= link_to "View", admin_user_path(user)
%td
- if current_user.id == user.id or user.role_ids.include? 3
=link_to 'Delete',admin_user_path(user), :method => :delete , :data => {:confirm => 'Are you sure ?'}, :disabled => true,:class => "btn btn-primary disabled btn-danger",:role => "button"
- else - else
=link_to 'Delete',admin_user_path(user), :method=> :delete , :data=> {:confirm => 'Are you sure ?'},:class => "btn btn-primary btn-danger" = user.roles.map { |role| role.name }.join ', '
- if can? :update, user
%td
= link_to "Edit", edit_admin_user_path(user)
- if can? :show, user
%td
= link_to "View", admin_user_path(user)
- if can? :destroy, user
%td
- if current_user.id == user.id or user.role_ids.include? 3
=link_to 'Delete',admin_user_path(user), :method => :delete , :data => {:confirm => 'Are you sure ?'}, :disabled => true,:class => "btn btn-primary disabled btn-danger",:role => "button"
- else
=link_to 'Delete',admin_user_path(user), :method=> :delete , :data=> {:confirm => 'Are you sure ?'},:class => "btn btn-primary btn-danger"
:javascript :javascript

View file

@ -10,83 +10,104 @@
%span.glyphicon.glyphicon-home %span.glyphicon.glyphicon-home
All Conferences All Conferences
- @conferences.each do |conference| - @conferences.each do |conference|
- if can? :show, conference
%li
= link_to(admin_conference_path(conference.short_title)) do
%span.glyphicon.glyphicon-cog
Manage
= conference.short_title
- if can? :create, Conference
%li %li
= link_to(admin_conference_path(conference.short_title)) do = link_to(new_admin_conference_path) do
%span.glyphicon.glyphicon-cog %span.glyphicon.glyphicon-plus
Manage New Conference
= conference.short_title
%li
= link_to(new_admin_conference_path) do
%span.glyphicon.glyphicon-plus
New Conference
%hr %hr
%li{:class=> "#{active_nav_li(admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"} - if can? :show, @conference
= link_to(admin_conference_path(@conference.short_title)) do %li{:class=> "#{active_nav_li(admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"}
%span.glyphicon.glyphicon-dashboard = link_to(admin_conference_path(@conference.short_title)) do
Manage %span.glyphicon.glyphicon-dashboard
%li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))} Manage
= link_to(admin_conference_events_path(@conference.short_title)) do - if can? :index, Event, conference_id: @conference.id
%span.glyphicon.glyphicon-comment %li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))}
Events = link_to(admin_conference_events_path(@conference.short_title)) do
%li{:class=> active_nav_li(admin_conference_registrations_path(@conference.short_title))} %span.glyphicon.glyphicon-comment
= link_to(admin_conference_registrations_path(@conference.short_title)) do Events
%span.glyphicon.glyphicon-user - if can? :index, @conference => Registration
Registrations %li{:class=> active_nav_li(admin_conference_registrations_path(@conference.short_title))}
%li{class: active_nav_li(admin_conference_schedule_path(@conference.short_title))} = link_to(admin_conference_registrations_path(@conference.short_title)) do
= link_to(admin_conference_schedule_path(@conference.short_title), target: '_blank') do %span.glyphicon.glyphicon-user
%span.glyphicon.glyphicon-calendar Registrations
Schedule - if can? :update, :schedule
%li{class: active_nav_li(admin_conference_campaigns_path(@conference.short_title))} %li{class: active_nav_li(admin_conference_schedule_path(@conference.short_title))}
= link_to(admin_conference_campaigns_path(@conference.short_title)) do = link_to(admin_conference_schedule_path(@conference.short_title), target: '_blank') do
%span.glyphicon.glyphicon-bullhorn %span.glyphicon.glyphicon-calendar
Campaigns Schedule
- if can? :index, Campaign, conference_id: @conference.id
%li{class: active_nav_li(admin_conference_campaigns_path(@conference.short_title))}
= link_to(admin_conference_campaigns_path(@conference.short_title)) do
%span.glyphicon.glyphicon-bullhorn
Campaigns
%hr %hr
%li{:class=> "#{active_nav_li(edit_admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"} - if can? :update, Conference, id: @conference.id
= link_to(edit_admin_conference_path(@conference.short_title)) do %li{:class=> "#{active_nav_li(edit_admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"}
%span.glyphicon.glyphicon-cog = link_to(edit_admin_conference_path(@conference.short_title)) do
Settings %span.glyphicon.glyphicon-cog
%li{:class=> "#{active_nav_li(admin_conference_targets_path(@conference.short_title))}"} Settings
= link_to(admin_conference_targets_path(@conference.short_title)) do - if can? :index, Target, conference_id: @conference.id
%span.glyphicon.glyphicon-flag %li{:class=> "#{active_nav_li(admin_conference_targets_path(@conference.short_title))}"}
Targets = link_to(admin_conference_targets_path(@conference.short_title)) do
%li{:class=> "#{active_nav_li(admin_conference_venue_info_path(@conference.short_title))} myAccordion"} %span.glyphicon.glyphicon-flag
= link_to(admin_conference_venue_info_path(@conference.short_title)) do Targets
%span.glyphicon.glyphicon-road - if can? :index, Venue, id: @conference.venue.id
Venue %li{:class=> "#{active_nav_li(admin_conference_venue_info_path(@conference.short_title))} myAccordion"}
%span.small.glyphicon.glyphicon-chevron-right = link_to(admin_conference_venue_info_path(@conference.short_title)) do
%ul.nav.nav-stacked.nav-pills.small.collapse.subNav %span.glyphicon.glyphicon-road
%li{:class=> active_nav_li(admin_conference_rooms_path(@conference.short_title))} Venue
= link_to 'Rooms', admin_conference_rooms_path(@conference.short_title) %span.small.glyphicon.glyphicon-chevron-right
%li{ class: active_nav_li(admin_conference_lodgings_path(@conference.short_title)) } %ul.nav.nav-stacked.nav-pills.small.collapse.subNav
= link_to 'Lodgings', admin_conference_lodgings_path(@conference.short_title) - if can? :index, Room, conference_id: @conference.id
%li{:class=> "#{active_nav_li(admin_conference_sponsorship_levels_path(@conference.short_title))} myAccordion" } %li{:class=> active_nav_li(admin_conference_rooms_path(@conference.short_title))}
= link_to(admin_conference_sponsorship_levels_path(@conference.short_title)) do = link_to 'Rooms', admin_conference_rooms_path(@conference.short_title)
%span.glyphicon.glyphicon-star - if can? :index, Lodging, venue_id: @conference.venue.id
Sponsorship %li{ class: active_nav_li(admin_conference_lodgings_path(@conference.short_title)) }
%span.small.glyphicon.glyphicon-chevron-right = link_to 'Lodgings', admin_conference_lodgings_path(@conference.short_title)
%ul.nav.nav-stacked.nav-pills.small.collapse.subNav - if can? :index, SponsorshipLevel, conference_id: @conference.id
%li{:class=> active_nav_li(admin_conference_sponsors_path(@conference.short_title))} %li{:class=> "#{active_nav_li(admin_conference_sponsorship_levels_path(@conference.short_title))} myAccordion" }
= link_to 'Sponsors', admin_conference_sponsors_path(@conference.short_title) = link_to(admin_conference_sponsorship_levels_path(@conference.short_title)) do
%li{ class: active_nav_li(admin_conference_supporter_levels_path(@conference.short_title)) } %span.glyphicon.glyphicon-star
= link_to(admin_conference_supporter_levels_path(@conference.short_title)) do Sponsorship
%span.glyphicon.glyphicon-usd %span.small.glyphicon.glyphicon-chevron-right
Supporter Levels %ul.nav.nav-stacked.nav-pills.small.collapse.subNav
%li{:class=> active_nav_li(admin_conference_emails_path(@conference.short_title))} - if can? :index, Sponsor, conference_id: @conference.id
= link_to(admin_conference_emails_path(@conference.short_title)) do %li{:class=> active_nav_li(admin_conference_sponsors_path(@conference.short_title))}
%span.glyphicon.glyphicon-envelope = link_to 'Sponsors', admin_conference_sponsors_path(@conference.short_title)
E-Mails - if can? :index, SupporterLevel, conference_id: @conference.id
%li{:class=> "#{active_nav_li(admin_conference_callforpapers_path(@conference.short_title))} myAccordion"} %li{ class: active_nav_li(admin_conference_supporter_levels_path(@conference.short_title)) }
= link_to(admin_conference_callforpapers_path(@conference.short_title)) do = link_to(admin_conference_supporter_levels_path(@conference.short_title)) do
%span.glyphicon.glyphicon-comment %span.glyphicon.glyphicon-usd
Call for papers Supporter Levels
%span.small.glyphicon.glyphicon-chevron-right - if can? :index, EmailSettings, conference_id: @conference.id
%ul.nav.nav-stacked.nav-pills.small.collapse.subNav %li{:class=> active_nav_li(admin_conference_emails_path(@conference.short_title))}
%li{:class=> active_nav_li(admin_conference_tracks_path(@conference.short_title))} = link_to(admin_conference_emails_path(@conference.short_title)) do
= link_to 'Tracks', admin_conference_tracks_path(@conference.short_title) %span.glyphicon.glyphicon-envelope
%li{:class=> active_nav_li(admin_conference_event_types_path(@conference.short_title))} E-Mails
= link_to 'Event types', admin_conference_event_types_path(@conference.short_title) - if can? :index, CallForPapers, conference_id: @conference.id
%li{:class=> active_nav_li(admin_conference_difficulty_levels_path(@conference.short_title))} %li{:class=> "#{active_nav_li(admin_conference_callforpapers_path(@conference.short_title))} myAccordion"}
= link_to 'Difficulty levels', admin_conference_difficulty_levels_path(@conference.short_title) = link_to(admin_conference_callforpapers_path(@conference.short_title)) do
%span.glyphicon.glyphicon-comment
Call for papers
%span.small.glyphicon.glyphicon-chevron-right
%ul.nav.nav-stacked.nav-pills.small.collapse.subNav
- if can? :index, @conference => Track
%li{:class=> active_nav_li(admin_conference_tracks_path(@conference.short_title))}
= link_to 'Tracks', admin_conference_tracks_path(@conference.short_title)
- if can? :index, EventType, conference_id: @conference.id
%li{:class=> active_nav_li(admin_conference_event_types_path(@conference.short_title))}
= link_to 'Event types', admin_conference_event_types_path(@conference.short_title)
- if can? :index, DifficultyLevel, conference_id: @conference.id
%li{:class=> active_nav_li(admin_conference_difficulty_levels_path(@conference.short_title))}
= link_to 'Difficulty levels', admin_conference_difficulty_levels_path(@conference.short_title)
- if can? :index, Question, conference_id: @conference.id
%li{:class=> active_nav_li(admin_conference_questions_path(@conference.short_title))} %li{:class=> active_nav_li(admin_conference_questions_path(@conference.short_title))}
= link_to(admin_conference_questions_path(@conference.short_title)) do = link_to(admin_conference_questions_path(@conference.short_title)) do
%span.glyphicon.glyphicon-question-sign %span.glyphicon.glyphicon-question-sign

View file

@ -10,17 +10,20 @@
%span.glyphicon.glyphicon-home %span.glyphicon.glyphicon-home
All Conferences All Conferences
- @conferences.each do |conference| - @conferences.each do |conference|
- if can? :show, conference
%li
= link_to(admin_conference_path(conference.short_title)) do
%span.glyphicon.glyphicon-cog
Manage
= conference.short_title
- if can? :create, Conference
%li %li
= link_to(admin_conference_path(conference.short_title)) do = link_to(new_admin_conference_path) do
%span.glyphicon.glyphicon-cog %span.glyphicon.glyphicon-plus
Manage New Conference
= conference.short_title - if can? :index, User
%li %hr
= link_to(new_admin_conference_path) do %li
%span.glyphicon.glyphicon-plus = link_to(admin_users_path) do
New Conference %span.glyphicon.glyphicon-user
%hr Users
%li
= link_to(admin_users_path) do
%span.glyphicon.glyphicon-user
Users

View file

@ -11,13 +11,13 @@
= link_to(destroy_user_session_path, :method=>'delete') do = link_to(destroy_user_session_path, :method=>'delete') do
%span.glyphicon.glyphicon-minus %span.glyphicon.glyphicon-minus
Sign out Sign out
-if has_role?(current_user, "admin") || has_role?(current_user, "organizer") - if can? :index, Conference
%li.divider %li.divider
%li %li
= link_to(admin_conference_index_path()) do = link_to(admin_conference_index_path()) do
%span.glyphicon.glyphicon-home %span.glyphicon.glyphicon-home
Administration Administration
-if @conference and @conference.id -if @conference and @conference.id and can? :index, @conference
%li %li
= link_to(admin_conference_path(@conference.short_title)) do = link_to(admin_conference_path(@conference.short_title)) do
%span.glyphicon.glyphicon-cog %span.glyphicon.glyphicon-cog

View file

@ -45,7 +45,7 @@
data.formData = inputs.serializeArray(); data.formData = inputs.serializeArray();
}); });
$.getJSON($('#fileupload').prop('action'), function (files) { $.getJSON($('#fileupload').prop('action'), function (files) {
var fu = $('#fileupload').data('fileupload'), var fu = $('#fileupload').data('blueimpFileupload'),
template; template;
fu._adjustMaxNumberOfFiles(-files.length); fu._adjustMaxNumberOfFiles(-files.length);
template = fu._renderDownload(files) template = fu._renderDownload(files)

View file

@ -1,7 +1,7 @@
= semantic_form_for(@event, :url => @url) do |f| = semantic_form_for(@event, :url => @url) do |f|
%section#basic %section#basic
= f.inputs :name => "Session Information" do = f.inputs :name => "Session Information" do
- if can? :update, @event - if can? :update, @event or can? :create, @event
= f.input :title, :as => :string, :required => true = f.input :title, :as => :string, :required => true
- else - else
Title: #{@event.title} Title: #{@event.title}
@ -9,7 +9,7 @@
%br %br
= f.input :subtitle, :as => :string = f.input :subtitle, :as => :string
%section#details %section#details
- if can? :update, @event - if can? :update, @event or can? :create, @event
= f.input :event_type_id,:as => :select, :collection => @conference.event_types.map {|x| ["#{x.title} - #{show_time(x.length)}", x.id]}, :include_blank => false, :label => "Session Type" = f.input :event_type_id,:as => :select, :collection => @conference.event_types.map {|x| ["#{x.title} - #{show_time(x.length)}", x.id]}, :include_blank => false, :label => "Session Type"
- else - else
Event type: #{@event.event_type.title} Event type: #{@event.event_type.title}