Merge branch 'master' into custom-domain

This commit is contained in:
Shlok Srivastava 2017-08-22 19:10:02 +00:00 committed by GitHub
commit e3d41bcf7d
30 changed files with 271 additions and 21 deletions

View file

@ -55,7 +55,6 @@ $(function() {
}
function draw_line_chart(animation, $canvas){
var options = get_animation({}, animation);
var chart_data = create_dataset($canvas);
var weeks = $canvas.parent().data('weeks');
var data = {
@ -63,10 +62,27 @@ $(function() {
datasets : chart_data
}
var options = get_animation(wholeNumberAxisFix(data), animation);
var ctx = $canvas.get(0).getContext("2d");
new Chart(ctx).Line(data, options);
}
function wholeNumberAxisFix(data){
var maxValue = false;
for(datasetIndex = 0; datasetIndex < data.datasets.length; ++datasetIndex){
var setMax = Math.max.apply(null, data.datasets[datasetIndex].data);
if (maxValue === false || setMax > maxValue) maxValue = setMax;
}
var steps = maxValue;
var stepWidth = 1;
if (maxValue > 10) {
stepWidth = Math.floor(maxValue / 10);
steps = Math.ceil(maxValue / stepWidth);
}
return { scaleOverride: true, scaleSteps: steps, scaleStepWidth: stepWidth, scaleStartValue: 0 };
}
function create_dataset($canvas){
var selected = getSelectedConferences($canvas);
var chart_data = $canvas.parent().data('chart');

View file

@ -94,3 +94,13 @@ p.comment-body {
.box{
height: 230px;
}
/* sidebar hamburger btn */
.side-nav-btn{
margin-left: 10px;
float: left;
}
.qr-image{
margin-left: 120px;
}

View file

@ -72,11 +72,12 @@ module Admin
def new
@conference = Conference.new
@organizations = Organization.accessible_by(current_ability, :update).pluck(:name, :id)
end
def create
@conference = Conference.new(conference_params)
@conference.organization = Organization.find_or_create_by(name: 'organization')
if @conference.save
# user that creates the conference becomes organizer of that conference
current_user.add_role :organizer, @conference

View file

@ -1,6 +1,7 @@
module Admin
class OrganizationsController < Admin::BaseController
load_and_authorize_resource :organization
before_action :verify_user, only: [:assign_org_admins, :unassign_org_admins]
def index
@organizations = Organization.all
@ -43,8 +44,49 @@ module Admin
end
end
def assign_org_admins
if @user.has_role? 'organization_admin', @organization
flash[:error] = "User #{@user.email} already has the role organization admin"
elsif @user.add_role 'organization_admin', @organization
flash[:notice] = "Successfully added role organization admin to user #{@user.email}"
else
flash[:error] = "Coud not add role organization admin to #{@user.email}"
end
redirect_to admins_admin_organization_path(@organization)
end
def unassign_org_admins
if @user.remove_role 'organization_admin', @organization
flash[:notice] = "Successfully removed role organization admin from user #{@user.email}"
else
flash[:error] = "Could not remove role organization admin from user #{@user.email}"
end
redirect_to admins_admin_organization_path(@organization)
end
def admins
@role = @organization.roles.first
@users = @role.users
render 'show_org_admins'
end
private
def user_params
params.require(:user).permit(:email)
end
def verify_user
@user = User.find_by(email: user_params[:email])
unless @user
redirect_to admins_admin_organization_path(@organization),
error: 'Could not find user. Please provide a valid email!'
return
end
end
def organization_params
params.require(:organization).permit(:name, :description, :picture)
end

View file

@ -13,6 +13,7 @@ class PhysicalTicketController < ApplicationController
@file_name = "ticket_for_#{@conference.short_title}"
@user = @physical_ticket.user
@ticket_layout = @conference.ticket_layout.to_sym
@qrcode_image = RQRCode::QRCode.new(@physical_ticket.token).as_png(size: 180, border_modules: 0)
respond_to do |format|
format.html
format.pdf do

View file

@ -2,6 +2,7 @@ class TicketPurchasesController < ApplicationController
before_filter :authenticate_user!
load_resource :conference, find_by: :short_title
authorize_resource :conference_registrations, class: Registration
authorize_resource
def create
current_user.ticket_purchases.by_conference(@conference).unpaid.destroy_all

View file

@ -28,7 +28,7 @@ class AdminAbility
conference.registration_open? && !conference.registration_limit_exceeded? || conference.program.speakers.confirmed.include?(user)
end
can :index, Organization
can [:index, :admins], Organization
can :index, Ticket
can :manage, TicketPurchase, user_id: user.id
can [:new, :create], Payment, user_id: user.id
@ -96,13 +96,11 @@ class AdminAbility
org_ids_for_organization_admin = Organization.with_role(:organization_admin, user).pluck(:id)
conf_ids_for_organization_admin = Conference.where(organization_id: org_ids_for_organization_admin).pluck(:id)
can [:read, :update, :destroy], Organization, id: org_ids_for_organization_admin
can [:read, :update, :destroy, :assign_org_admins, :unassign_org_admins, :admins], Organization, id: org_ids_for_organization_admin
can :new, Conference
can :manage, Conference, organization_id: org_ids_for_organization_admin
can [:index, :show], Role
can [:edit, :update], Role do |role|
role.resource_type == 'Organization' && (org_ids_for_organization_admin.include? role.resource_id)
end
signed_in_with_organizer_role(user, conf_ids_for_organization_admin)
end
@ -123,7 +121,10 @@ class AdminAbility
can :manage, Commercial, commercialable_type: 'Conference',
commercialable_id: conf_ids
can :manage, Registration, conference_id: conf_ids
can :manage, RegistrationPeriod, conference_id: conf_ids
can :manage, RegistrationPeriod do |registration_period|
conference = registration_period.conference
conf_ids.include?(conference.id) && conference.tickets.for_registration.any?
end
can :manage, Booth, conference_id: conf_ids
can :manage, Question, conference_id: conf_ids
can :manage, Question do |question|

View file

@ -26,7 +26,11 @@ class Conference < ActiveRecord::Base
has_many :ticket_purchases, dependent: :destroy
has_many :payments, dependent: :destroy
has_many :supporters, through: :ticket_purchases, source: :user
has_many :tickets, dependent: :destroy
has_many :tickets, dependent: :destroy do
def for_registration
where(registration_ticket: true)
end
end
has_many :resources, dependent: :destroy
has_many :booths, dependent: :destroy

View file

@ -77,5 +77,9 @@ class TicketPdf < Prawn::Document
move_up 180
end
def draw_fourth_square; end
def draw_fourth_square
x = @mid_horizontal + (@right - @mid_horizontal - 180) / 2
y = cursor - (bounds.top - @mid_vertical - 180) / 2
print_qr_code(@physical_ticket.token, pos: [x, y], extent: 180, stroke: false)
end
end

View file

@ -2,6 +2,7 @@
.col-md-8
= semantic_form_for(@conference, url: admin_conferences_path) do |f|
= f.inputs 'Basic Information' do
= f.input :organization, as: :select, collection: @organizations
= f.input :title, hint: "The name of your conference as it shall appear throughout the site. Example: 'OpenSUSE Conference 2013'",
input_html: { required: 'required' }
= f.input :short_title, hint: "A short and unique handle for your conference, using only letters, numbers, underscores, and dashes. This will be used to identify your conference in URLs etc. Example: 'froscon2011'",

View file

@ -0,0 +1,25 @@
.page-header
%h3 Users (#{users.length})
- if users.present?
%table.table.table-striped.table-bordered.table-hover.datatable#users
%thead
%th Name
%th Email
- if ( can? :unassign_org_admins, organization )
%th
Actions
%tbody
- users.each do |user|
%tr
%td= user.name
%td= user.email
- if ( can? :unassign_org_admins, organization )
%td
= link_to 'Remove from organization admin',
unassign_org_admins_admin_organization_path(organization.id,
role.name,
user: {email: user.email}),
method: :delete,
class: 'btn btn-danger'
- else
%h5 No users found!

View file

@ -25,6 +25,8 @@
= organization.conferences.past.count
%td
.btn-group
= link_to 'Admins', admins_admin_organization_path(organization),
method: :get, class: 'btn btn-success'
= link_to 'Edit', edit_admin_organization_path(organization),
method: :get, class: 'btn btn-primary'
= link_to 'Delete', admin_organization_path(organization),

View file

@ -0,0 +1,24 @@
.row
.col-md-12
.page-header
%h2
Organization admins for #{@organization.name}
.text-muted
= @role.description
.row.col-md-3
- if ( can? :assign_org_admins, @organization )
= semantic_form_for :user,
url: assign_org_admins_admin_organization_path(@organization,
@role.name), method: :post do |u|
= u.label 'Add user by email: '
.input-group
= u.input :email, label: false, placeholder: "User's email"
.input-group-btn
= u.submit 'Add', id: 'user-add', class: 'btn btn-primary'
.row
.col-md-12
= render partial: 'users_with_org_admin_role',
locals: { users: @users, organization: @organization, role: @role }

View file

@ -25,5 +25,12 @@
= link_to 'Delete', admin_conference_registration_period_path,
method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger'
- else
- if can? :create, @conference.build_registration_period
= link_to 'New Registration Period', new_admin_conference_registration_period_path, class: 'btn btn-primary'
- unless @conference.tickets.for_registration.empty?
- if can? :create, @conference.build_registration_period
= link_to 'New Registration Period', new_admin_conference_registration_period_path, class: 'btn btn-primary'
- else
.h3.text-left
No Registration Tickets!
%small
= link_to 'Create registration tickets', new_admin_conference_ticket_path
before creating the registration period.

View file

@ -1,4 +1,4 @@
%ul.nav.nav-stacked.nav-pills.mySidebar
%ul.nav.nav-stacked.nav-pills.mySidebar.collapse.navbar-collapse#side-nav
.btn-group
%button{type:'button', class: 'btn btn-default btn-link dropdown-toggle', 'data-toggle'=>'dropdown'}
%span.fa.fa-cog

View file

@ -1,7 +1,13 @@
.navbar.navbar-default.navbar-fixed-top.nav-osem{role: 'navigation'}
.container
.navbar-header
%button{"data-target"=>".navbar-collapse", "data-toggle"=>"collapse", class: 'navbar-toggle', type: 'button'}
- if @conference && @conference.short_title.present?
%button{ "data-target"=>"#side-nav", "data-toggle"=>"collapse", class: 'navbar-toggle side-nav-btn', type: 'button' }
%span.sr-only Toggle navigation
%span.icon-bar
%span.icon-bar
%span.icon-bar
%button{"data-target"=>"#main-nav", "data-toggle"=>"collapse", class: 'navbar-toggle', type: 'button'}
%span.sr-only
Toggle navigation
%span.icon-bar
@ -11,7 +17,7 @@
= link_to (ENV['OSEM_NAME'] || 'OSEM'), root_path, class: 'navbar-brand', title: 'Open Source Event Manager'
- else
= link_to conference.organization.name, organizations_path, class: 'navbar-brand', title: 'Open Source Event Manager'
.collapse.navbar-collapse
.collapse.navbar-collapse#main-nav
- if content_for :splash_nav
%ul.nav.navbar-nav#splash-nav
= content_for :splash_nav

View file

@ -67,6 +67,7 @@
= @physical_ticket.ticket_purchase.id
%br
.col-md-5.col-md-offset-2.box.well
= image_tag(@qrcode_image.to_data_url, class: 'img-responsive qr-image')
.row
.col-md-12
%p.text-left