Merge branch 'master' into user_openid_management
This commit is contained in:
commit
2e922650a7
22 changed files with 426 additions and 30 deletions
|
|
@ -76,7 +76,7 @@ module Admin
|
|||
|
||||
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
|
||||
|
|
@ -211,7 +211,7 @@ module Admin
|
|||
:vpositions_attributes, :use_volunteers, :color,
|
||||
:sponsorship_levels_attributes, :sponsors_attributes,
|
||||
:targets, :targets_attributes,
|
||||
:campaigns, :campaigns_attributes, :registration_limit)
|
||||
:campaigns, :campaigns_attributes, :registration_limit, :organization_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
52
app/controllers/admin/organizations_controller.rb
Normal file
52
app/controllers/admin/organizations_controller.rb
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
module Admin
|
||||
class OrganizationsController < Admin::BaseController
|
||||
load_and_authorize_resource :organization
|
||||
|
||||
def index
|
||||
@organizations = Organization.all
|
||||
end
|
||||
|
||||
def create
|
||||
@organization = Organization.new(organization_params)
|
||||
if @organization.save
|
||||
redirect_to admin_organizations_path,
|
||||
notice: 'Organization successfully created'
|
||||
else
|
||||
redirect_to new_admin_organization_path,
|
||||
error: @organization.errors.full_messages.join(', ')
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@organization = Organization.new
|
||||
end
|
||||
|
||||
def edit; end
|
||||
|
||||
def update
|
||||
if @organization.update_attributes(organization_params)
|
||||
redirect_to admin_organizations_path,
|
||||
notice: 'Organization successfully updated'
|
||||
else
|
||||
redirect_to edit_admin_organization_path(@organization),
|
||||
error: @organization.errors.full_messages.join(', ')
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @organization.destroy
|
||||
redirect_to admin_organizations_path,
|
||||
notice: 'Organization successfully destroyed'
|
||||
else
|
||||
redirect_to admin_organizations_path,
|
||||
error: 'Organization cannot be destroyed'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def organization_params
|
||||
params.require(:organization).permit(:name, :description, :picture)
|
||||
end
|
||||
end
|
||||
end
|
||||
7
app/controllers/organizations_controller.rb
Normal file
7
app/controllers/organizations_controller.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class OrganizationsController < ApplicationController
|
||||
load_and_authorize_resource :organization
|
||||
|
||||
def index
|
||||
@organizations = Organization.all
|
||||
end
|
||||
end
|
||||
|
|
@ -83,6 +83,7 @@ class Ability
|
|||
conference.registration_open? && !conference.registration_limit_exceeded? || conference.program.speakers.confirmed.include?(user)
|
||||
end
|
||||
|
||||
can :index, Organization
|
||||
can :index, Ticket
|
||||
can :manage, TicketPurchase, user_id: user.id
|
||||
can [:new, :create], Payment, user_id: user.id
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ class Conference < ActiveRecord::Base
|
|||
|
||||
default_scope { order('start_date DESC') }
|
||||
|
||||
belongs_to :organization
|
||||
|
||||
has_paper_trail ignore: %i(updated_at guid revision events_per_week), meta: { conference_id: :id }
|
||||
|
||||
has_and_belongs_to_many :questions
|
||||
|
|
@ -53,7 +55,8 @@ class Conference < ActiveRecord::Base
|
|||
:start_date,
|
||||
:end_date,
|
||||
:start_hour,
|
||||
:end_hour, presence: true
|
||||
:end_hour,
|
||||
:organization, presence: true
|
||||
|
||||
validates :short_title, uniqueness: true
|
||||
validates :short_title, format: { with: /\A[a-zA-Z0-9_-]*\z/ }
|
||||
|
|
|
|||
7
app/models/organization.rb
Normal file
7
app/models/organization.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class Organization < ActiveRecord::Base
|
||||
has_many :conferences, dependent: :destroy
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
mount_uploader :picture, PictureUploader, mount_on: :picture
|
||||
end
|
||||
13
app/views/admin/organizations/_form.html.haml
Normal file
13
app/views/admin/organizations/_form.html.haml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
= semantic_form_for(@organization, url: (@organization.new_record? ? admin_organizations_path : admin_organization_path(@organization))) do |f|
|
||||
= f.inputs name: 'Organization details' do
|
||||
= f.input :name, as: :string, required: true
|
||||
= f.input :description, as: :text, input_html: { rows: 10 }, placeholder: 'Decribe about your organization..'
|
||||
= image_tag f.object.picture.thumb.url if f.object.picture?
|
||||
- if @organization.picture
|
||||
= image_tag(@organization.picture.thumb.url, width: '20%')
|
||||
= f.input :picture
|
||||
%p.text-right
|
||||
- if @organization.new_record?
|
||||
= f.submit 'Create Organization', class: 'btn btn-success'
|
||||
- else
|
||||
= f.submit 'Update Organization', class: 'btn btn-success'
|
||||
31
app/views/admin/organizations/index.html.haml
Normal file
31
app/views/admin/organizations/index.html.haml
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h1 Organizations
|
||||
.btn-group.pull-right
|
||||
= link_to 'Create Organization', new_admin_organization_path, class: 'btn btn-success pull-right'
|
||||
%p.text-muted
|
||||
Manage organizations in OSEM
|
||||
.row
|
||||
.col-md-12
|
||||
%table.table.table-hover.datatable
|
||||
%thead
|
||||
%th Name
|
||||
%th Upcoming Conferences
|
||||
%th Past Conferences
|
||||
%th Actions
|
||||
%tbody
|
||||
- @organizations.each do |organization|
|
||||
%tr
|
||||
%td
|
||||
= organization.name
|
||||
%td
|
||||
= organization.conferences.count
|
||||
%td
|
||||
= organization.conferences.count
|
||||
%td
|
||||
.btn-group
|
||||
= link_to 'Edit', edit_admin_organization_path(organization),
|
||||
method: :get, class: 'btn btn-primary'
|
||||
= link_to 'Delete', admin_organization_path(organization),
|
||||
method: :delete, class: 'btn btn-danger', data: { confirm: "Warning: This will delete #{organization.name} and all its data which includes data for all conferences within #{organization.name}. Do you really want to continue?" }
|
||||
|
|
@ -32,3 +32,8 @@
|
|||
= link_to(admin_revision_history_path) do
|
||||
%span.fa.fa-history
|
||||
Revision History
|
||||
- if ENV['ORGANIZATIONS_ENABLED'] == 'true'
|
||||
%li
|
||||
= link_to(admin_organizations_path) do
|
||||
%span.fa.fa-group
|
||||
Organizations
|
||||
|
|
|
|||
|
|
@ -49,3 +49,8 @@
|
|||
= link_to(admin_revision_history_path) do
|
||||
%span.fa.fa-history
|
||||
Revision History
|
||||
- if ENV['ORGANIZATIONS_ENABLED'] == 'true'
|
||||
%li
|
||||
= link_to(admin_organizations_path) do
|
||||
%span.fa.fa-group
|
||||
Organizations
|
||||
|
|
|
|||
16
app/views/organizations/index.html.haml
Normal file
16
app/views/organizations/index.html.haml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
.container
|
||||
.row
|
||||
.col-md-12.page-header
|
||||
%h1
|
||||
Organizations
|
||||
.btn-group.pull-right
|
||||
/ = link_to 'Add new', new_organization_path, class: 'btn btn-mini btn-success'
|
||||
- @organizations.each do |organization|
|
||||
.col-md-4
|
||||
.thumbnail
|
||||
= image_tag(organization.picture.thumb.url, width: '20%')
|
||||
.caption
|
||||
%h4
|
||||
= organization.name
|
||||
%button.btn.btn-success Conferences
|
||||
/ = link_to 'Edit', edit_organization_path(organization), class: 'btn btn-mini btn-default'
|
||||
Loading…
Add table
Add a link
Reference in a new issue