mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
houndci fixes
This commit is contained in:
parent
23bf55b66c
commit
9292b79c78
13 changed files with 151 additions and 144 deletions
|
|
@ -5,33 +5,33 @@ module Admin
|
|||
def index
|
||||
session[:return_to] ||= request.referer
|
||||
@pdf_filename = "#{@conference.title}.pdf"
|
||||
@registrations = @conference.registrations.includes(:user).order("registrations.created_at ASC")
|
||||
@attended = @conference.registrations.where("attended = ?", true).count
|
||||
@headers = %w[name email nickname other_needs arrival departure attended]
|
||||
@registrations = @conference.registrations.includes(:user).order('registrations.created_at ASC')
|
||||
@attended = @conference.registrations.where('attended = ?', true).count
|
||||
@headers = %w(name email nickname other_needs arrival departure attended)
|
||||
end
|
||||
|
||||
def change_field
|
||||
@registration = Registration.find(params[:id])
|
||||
field = params[:view_field]
|
||||
if @registration.send(field.to_sym)
|
||||
@registration.update_attribute(:"#{field}",0)
|
||||
else
|
||||
@registration.update_attribute(:"#{field}",1)
|
||||
end
|
||||
@registration = Registration.find(params[:id])
|
||||
field = params[:view_field]
|
||||
if @registration.send(field.to_sym)
|
||||
@registration.update_attribute(:"#{field}", 0)
|
||||
else
|
||||
@registration.update_attribute(:"#{field}", 1)
|
||||
end
|
||||
|
||||
redirect_to admin_conference_registrations_path(@conference.short_title)
|
||||
flash[:notice] = "Updated '#{params[:view_field]}' => #{@registration.attended} for
|
||||
#{(User.where("id = ?", @registration.user_id).first).email}"
|
||||
redirect_to admin_conference_registrations_path(@conference.short_title)
|
||||
flash[:notice] = "Updated '#{params[:view_field]}' => #{@registration.attended} for
|
||||
#{(User.where('id = ?', @registration.user_id).first).email}"
|
||||
end
|
||||
|
||||
def edit
|
||||
@registration = @conference.registrations.where("id = ?", params[:id]).first
|
||||
@user = User.where("id = ?", @registration.user_id).first
|
||||
@registration = @conference.registrations.where('id = ?', params[:id]).first
|
||||
@user = User.where('id = ?', @registration.user_id).first
|
||||
end
|
||||
|
||||
def update
|
||||
@registration = @conference.registrations.where("id = ?", params[:id]).first
|
||||
@user = User.where("id = ?", @registration.user_id).first
|
||||
@registration = @conference.registrations.where('id = ?', params[:id]).first
|
||||
@user = User.where('id = ?', @registration.user_id).first
|
||||
begin
|
||||
@user.update_attributes!(params[:registration][:user_attributes])
|
||||
params[:registration].delete :user_attributes
|
||||
|
|
@ -95,9 +95,9 @@ module Admin
|
|||
end
|
||||
|
||||
def destroy
|
||||
if has_role?(current_user, "Admin")
|
||||
registration = @conference.registrations.where(:id => params[:id]).first
|
||||
user = User.where("id = ?", registration.user_id).first
|
||||
if has_role?(current_user, 'Admin')
|
||||
registration = @conference.registrations.where(id: params[:id]).first
|
||||
user = User.where('id = ?', registration.user_id).first
|
||||
|
||||
begin registration.destroy
|
||||
redirect_to admin_conference_registrations_path
|
||||
|
|
@ -115,14 +115,19 @@ module Admin
|
|||
end
|
||||
|
||||
protected
|
||||
def registration_params
|
||||
params.require(:registration).permit(:attending_with_partner, :using_affiliated_lodging, :handicapped_access_required, :other_special_needs, :attended)
|
||||
end
|
||||
def user_params
|
||||
params.require(:registration).permit(user: [:email, :name, :nickname, :affiliation])
|
||||
end
|
||||
def supporter_params
|
||||
params.require(:registration).permit(supporter_registration: [:supporter_level_id, :code])
|
||||
end
|
||||
|
||||
def registration_params
|
||||
params.require(:registration).permit(:attending_with_partner, :using_affiliated_lodging,
|
||||
:handicapped_access_required, :other_special_needs,
|
||||
:attended)
|
||||
end
|
||||
|
||||
def user_params
|
||||
params.require(:registration).permit(user: [:email, :name, :nickname, :affiliation])
|
||||
end
|
||||
|
||||
def supporter_params
|
||||
params.require(:registration).permit(supporter_registration: [:supporter_level_id, :code])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,44 +5,42 @@ class Conference < ActiveRecord::Base
|
|||
require 'uri'
|
||||
|
||||
attr_accessible :title, :short_title, :social_tag, :contact_email, :timezone, :html_export_path,
|
||||
:start_date, :end_date, :rooms_attributes, :tracks_attributes, :dietary_choices_attributes,
|
||||
:use_dietary_choices, :use_supporter_levels, :supporter_levels_attributes, :social_events_attributes,
|
||||
:event_types_attributes, :registration_start_date, :registration_end_date, :logo,
|
||||
:questions_attributes, :question_ids, :answers_attributes, :answer_ids,
|
||||
:difficulty_levels_attributes, :use_difficulty_levels,
|
||||
:use_vpositions, :use_vdays, :vdays_attributes, :vpositions_attributes, :use_volunteers,
|
||||
:media_id, :media_type, :color, :description,
|
||||
:registration_description, :ticket_description,
|
||||
:sponsorship_levels_attributes,
|
||||
:sponsors_attributes, :facebook_url,
|
||||
:google_url, :twitter_url, :sponsor_description, :sponsor_email,
|
||||
:lodging_description, :include_registrations_in_splash,
|
||||
:include_sponsors_in_splash, :include_tracks_in_splash,
|
||||
:include_tickets_in_splash, :include_social_media_in_splash,
|
||||
:include_program_in_splash, :make_conference_public,
|
||||
:photos_attributes, :banner_photo,
|
||||
:include_banner_in_splash,
|
||||
:targets, :targets_attributes, :campaigns, :campaigns_attributes
|
||||
:start_date, :end_date, :rooms_attributes, :tracks_attributes,
|
||||
:dietary_choices_attributes, :use_dietary_choices, :use_supporter_levels,
|
||||
:supporter_levels_attributes, :social_events_attributes, :event_types_attributes,
|
||||
:registration_start_date, :registration_end_date, :logo, :questions_attributes,
|
||||
:question_ids, :answers_attributes, :answer_ids, :difficulty_levels_attributes,
|
||||
:use_difficulty_levels, :use_vpositions, :use_vdays, :vdays_attributes,
|
||||
:vpositions_attributes, :use_volunteers, :media_id, :media_type, :color,
|
||||
:description, :registration_description, :ticket_description,
|
||||
:sponsorship_levels_attributes, :sponsors_attributes, :facebook_url, :google_url,
|
||||
:twitter_url, :sponsor_description, :sponsor_email, :lodging_description,
|
||||
:include_registrations_in_splash, :include_sponsors_in_splash,
|
||||
:include_tracks_in_splash, :include_tickets_in_splash,
|
||||
:include_social_media_in_splash, :include_program_in_splash,
|
||||
:make_conference_public, :photos_attributes, :banner_photo,
|
||||
:include_banner_in_splash, :targets, :targets_attributes, :campaigns,
|
||||
:campaigns_attributes
|
||||
|
||||
has_paper_trail
|
||||
|
||||
has_and_belongs_to_many :questions
|
||||
|
||||
has_one :email_settings, :dependent => :destroy
|
||||
has_one :call_for_papers, :dependent => :destroy
|
||||
has_many :social_events, :dependent => :destroy
|
||||
has_many :supporter_registrations, :dependent => :destroy
|
||||
has_many :supporter_levels, :dependent => :destroy
|
||||
has_many :dietary_choices, :dependent => :destroy
|
||||
has_many :events, :dependent => :destroy
|
||||
has_many :event_types, :dependent => :destroy
|
||||
has_many :tracks, :dependent => :destroy
|
||||
has_many :difficulty_levels, :dependent => :destroy
|
||||
has_many :rooms, :dependent => :destroy
|
||||
has_many :registrations, :dependent => :destroy
|
||||
has_many :vdays, :dependent => :destroy
|
||||
has_many :vpositions, :dependent => :destroy
|
||||
has_many :vchoices, :dependent => :destroy
|
||||
has_one :email_settings, dependent: :destroy
|
||||
has_one :call_for_papers, dependent: :destroy
|
||||
has_many :social_events, dependent: :destroy
|
||||
has_many :supporter_registrations, dependent: :destroy
|
||||
has_many :supporter_levels, dependent: :destroy
|
||||
has_many :dietary_choices, dependent: :destroy
|
||||
has_many :events, dependent: :destroy
|
||||
has_many :event_types, dependent: :destroy
|
||||
has_many :tracks, dependent: :destroy
|
||||
has_many :difficulty_levels, dependent: :destroy
|
||||
has_many :rooms, dependent: :destroy
|
||||
has_many :registrations, dependent: :destroy
|
||||
has_many :vdays, dependent: :destroy
|
||||
has_many :vpositions, dependent: :destroy
|
||||
has_many :vchoices, dependent: :destroy
|
||||
has_many :sponsorship_levels, dependent: :destroy
|
||||
has_many :sponsors, dependent: :destroy
|
||||
has_many :photos, dependent: :destroy
|
||||
|
|
@ -50,20 +48,20 @@ class Conference < ActiveRecord::Base
|
|||
has_many :campaigns, dependent: :destroy
|
||||
belongs_to :venue
|
||||
|
||||
accepts_nested_attributes_for :rooms, :reject_if => proc {|r| r["name"].blank?}, :allow_destroy => true
|
||||
accepts_nested_attributes_for :tracks, :reject_if => proc {|r| r["name"].blank?}, :allow_destroy => true
|
||||
accepts_nested_attributes_for :difficulty_levels, :allow_destroy => true
|
||||
accepts_nested_attributes_for :social_events, :allow_destroy => true
|
||||
accepts_nested_attributes_for :rooms, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true
|
||||
accepts_nested_attributes_for :tracks, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true
|
||||
accepts_nested_attributes_for :difficulty_levels, allow_destroy: true
|
||||
accepts_nested_attributes_for :social_events, allow_destroy: true
|
||||
accepts_nested_attributes_for :venue
|
||||
accepts_nested_attributes_for :dietary_choices, :allow_destroy => true
|
||||
accepts_nested_attributes_for :supporter_levels, :allow_destroy => true
|
||||
accepts_nested_attributes_for :dietary_choices, allow_destroy: true
|
||||
accepts_nested_attributes_for :supporter_levels, allow_destroy: true
|
||||
accepts_nested_attributes_for :sponsorship_levels, allow_destroy: true
|
||||
accepts_nested_attributes_for :sponsors, allow_destroy: true
|
||||
accepts_nested_attributes_for :event_types, :allow_destroy => true
|
||||
accepts_nested_attributes_for :event_types, allow_destroy: true
|
||||
accepts_nested_attributes_for :email_settings
|
||||
accepts_nested_attributes_for :questions, :allow_destroy => true
|
||||
accepts_nested_attributes_for :vdays, :allow_destroy => true
|
||||
accepts_nested_attributes_for :vpositions, :allow_destroy => true
|
||||
accepts_nested_attributes_for :questions, allow_destroy: true
|
||||
accepts_nested_attributes_for :vdays, allow_destroy: true
|
||||
accepts_nested_attributes_for :vpositions, allow_destroy: true
|
||||
accepts_nested_attributes_for :photos, allow_destroy: true
|
||||
accepts_nested_attributes_for :targets, allow_destroy: true
|
||||
accepts_nested_attributes_for :campaigns, allow_destroy: true
|
||||
|
|
@ -98,7 +96,8 @@ class Conference < ActiveRecord::Base
|
|||
before_create :add_color
|
||||
|
||||
def self.media_types
|
||||
media_types = {:youtube => 'YouTube', :slideshare => 'SlideShare', :flickr => 'Flickr', :vimeo => 'Vimeo', :speakerdeck => 'Speakerdeck', :instagram => 'Instagram'}
|
||||
media_types = { youtube: 'YouTube', slideshare: 'SlideShare', flickr: 'Flickr', vimeo: 'Vimeo',
|
||||
speakerdeck: 'Speakerdeck', instagram: 'Instagram' }
|
||||
return media_types
|
||||
end
|
||||
|
||||
|
|
@ -115,7 +114,7 @@ class Conference < ActiveRecord::Base
|
|||
def user_registered? user
|
||||
return nil if user.nil?
|
||||
|
||||
if self.registrations.where(:user_id => user.id).count == 0
|
||||
if self.registrations.where(user_id: user.id).count == 0
|
||||
logger.debug("User #{user.email} isn't registered to self.title")
|
||||
return false
|
||||
else
|
||||
|
|
@ -721,7 +720,7 @@ class Conference < ActiveRecord::Base
|
|||
guid = SecureRandom.urlsafe_base64
|
||||
# begin
|
||||
# guid = SecureRandom.urlsafe_base64
|
||||
# end # while User.where(:guid => guid).exists?
|
||||
# end while User.where(:guid => guid).exists?
|
||||
self.guid = guid
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,21 @@
|
|||
class EmailSettings < ActiveRecord::Base
|
||||
attr_accessible :send_on_registration, :send_on_accepted, :send_on_rejected, :send_on_confirmed_without_registration,
|
||||
:registration_email_template, :accepted_email_template, :rejected_email_template, :confirmed_email_template,
|
||||
:registration_subject, :accepted_subject, :rejected_subject, :confirmed_without_registration_subject
|
||||
attr_accessible :send_on_registration, :send_on_accepted, :send_on_rejected,
|
||||
:send_on_confirmed_without_registration, :registration_email_template,
|
||||
:accepted_email_template, :rejected_email_template, :confirmed_email_template,
|
||||
:registration_subject, :accepted_subject, :rejected_subject,
|
||||
:confirmed_without_registration_subject
|
||||
|
||||
def get_values(conference, user, event = nil)
|
||||
h = {
|
||||
"email" => user.email,
|
||||
"name" => user.name,
|
||||
"conference" => conference.title,
|
||||
"registrationlink" => Rails.application.routes.url_helpers.register_conference_url(conference.short_title, :host => CONFIG["url_for_emails"])
|
||||
'email' => user.email,
|
||||
'name' => user.name,
|
||||
'conference' => conference.title,
|
||||
'registrationlink' => Rails.application.routes.url_helpers.register_conference_url(conference.short_title, host: CONFIG['url_for_emails'])
|
||||
}
|
||||
|
||||
if !event.nil?
|
||||
h["eventtitle"] = event.title
|
||||
h["proposalslink"] = Rails.application.routes.url_helpers.conference_proposal_url(conference.short_title, event, :host => CONFIG["url_for_emails"])
|
||||
h['eventtitle'] = event.title
|
||||
h['proposalslink'] = Rails.application.routes.url_helpers.conference_proposal_url(conference.short_title, event, host: CONFIG['url_for_emails'])
|
||||
end
|
||||
h
|
||||
end
|
||||
|
|
@ -24,7 +26,6 @@ class EmailSettings < ActiveRecord::Base
|
|||
parse_template(template, values)
|
||||
end
|
||||
|
||||
|
||||
def generate_accepted_email(event)
|
||||
values = get_values(event.conference, event.submitter, event)
|
||||
template = self.accepted_email_template
|
||||
|
|
|
|||
|
|
@ -1,18 +1,20 @@
|
|||
class Event < ActiveRecord::Base
|
||||
include ActiveRecord::Transitions
|
||||
has_paper_trail
|
||||
attr_accessible :title, :subtitle, :abstract, :description, :event_type_id, :users_attributes, :user, :proposal_additional_speakers, :track_id, :media_id, :media_type, :require_registration, :difficulty_level_id
|
||||
attr_accessible :title, :subtitle, :abstract, :description, :event_type_id, :users_attributes,
|
||||
:user, :proposal_additional_speakers, :track_id, :media_id, :media_type,
|
||||
:require_registration, :difficulty_level_id
|
||||
|
||||
acts_as_commentable
|
||||
|
||||
after_create :set_week
|
||||
|
||||
has_many :event_users, :dependent => :destroy
|
||||
has_many :event_attachments, :dependent => :destroy
|
||||
has_many :users, :through => :event_users
|
||||
has_many :speakers, :through => :event_users, :source => :user
|
||||
has_many :event_users, dependent: :destroy
|
||||
has_many :event_attachments, dependent: :destroy
|
||||
has_many :users, through: :event_users
|
||||
has_many :speakers, through: :event_users, source: :user
|
||||
has_many :votes
|
||||
has_many :voters, :through => :votes, :source => :user
|
||||
has_many :voters, through: :votes, source: :user
|
||||
belongs_to :event_type
|
||||
|
||||
has_and_belongs_to_many :registrations
|
||||
|
|
@ -22,20 +24,20 @@ class Event < ActiveRecord::Base
|
|||
belongs_to :difficulty_level
|
||||
belongs_to :conference
|
||||
|
||||
accepts_nested_attributes_for :event_users, :allow_destroy => true
|
||||
accepts_nested_attributes_for :event_attachments, :allow_destroy => true, :reject_if => :all_blank
|
||||
accepts_nested_attributes_for :event_users, allow_destroy: true
|
||||
accepts_nested_attributes_for :event_attachments, allow_destroy: true, reject_if: :all_blank
|
||||
accepts_nested_attributes_for :users
|
||||
before_create :generate_guid
|
||||
|
||||
validate :abstract_limit
|
||||
validate :biography_exists
|
||||
validates :title, :presence => true
|
||||
validates :abstract, :presence => true
|
||||
validates :media_type, :allow_nil => true, inclusion: {in: Conference.media_types.values}
|
||||
validates :title, presence: true
|
||||
validates :abstract, presence: true
|
||||
validates :media_type, allow_nil: true, inclusion: { in: Conference.media_types.values }
|
||||
|
||||
scope :confirmed, -> { where(state: 'confirmed') }
|
||||
|
||||
state_machine :initial => :new do
|
||||
state_machine initial: :new do
|
||||
state :new
|
||||
state :withdrawn
|
||||
state :unconfirmed
|
||||
|
|
@ -64,7 +66,7 @@ class Event < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def voted?(event, user)
|
||||
event.votes.where("user_id = ?", user).first
|
||||
event.votes.where('user_id = ?', user).first
|
||||
end
|
||||
|
||||
def average_rating
|
||||
|
|
@ -73,18 +75,18 @@ class Event < ActiveRecord::Base
|
|||
@total_rating = @total_rating + vote.rating
|
||||
end
|
||||
@total = self.votes.size
|
||||
number_with_precision(@total_rating / @total.to_f, :precision => 2, :strip_insignificant_zeros => true)
|
||||
number_with_precision(@total_rating / @total.to_f, precision: 2, strip_insignificant_zeros: true)
|
||||
end
|
||||
|
||||
def submitter
|
||||
result = self.event_users.where(:event_role => "submitter").first
|
||||
result = self.event_users.where(event_role: 'submitter').first
|
||||
if !result.nil?
|
||||
result.user
|
||||
else
|
||||
user = nil
|
||||
# Perhaps the event_users haven't been saved, if this is a new proposal
|
||||
self.event_users.each do |p|
|
||||
if p.event_role == "submitter"
|
||||
if p.event_role == 'submitter'
|
||||
user = p.user
|
||||
end
|
||||
end
|
||||
|
|
@ -102,7 +104,7 @@ class Event < ActiveRecord::Base
|
|||
end
|
||||
|
||||
if self.track.nil?
|
||||
json[:track_color] = "#ffffff"
|
||||
json[:track_color] = '#ffffff'
|
||||
else
|
||||
json[:track_color] = self.track.color;
|
||||
end
|
||||
|
|
@ -194,14 +196,14 @@ class Event < ActiveRecord::Base
|
|||
|
||||
def biography_exists
|
||||
if self.submitter.biography_word_count == 0
|
||||
errors.add(:user_biography, "must be filled out")
|
||||
errors.add(:user_biography, 'must be filled out')
|
||||
end
|
||||
end
|
||||
|
||||
def generate_guid
|
||||
begin
|
||||
guid = SecureRandom.urlsafe_base64
|
||||
end while self.class.where(:guid => guid).exists?
|
||||
end while self.class.where(guid: guid).exists?
|
||||
self.guid = guid
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
class EventUser < ActiveRecord::Base
|
||||
attr_accessible :event, :user, :user_id, :event_role
|
||||
# TODO Do we need these roles?
|
||||
ROLES = [["Speaker","speaker"], ["Submitter","submitter"], ["Moderator","moderator"]]
|
||||
ROLES = [['Speaker', 'speaker'], ['Submitter', 'submitter'], ['Moderator', 'moderator']]
|
||||
|
||||
belongs_to :event
|
||||
belongs_to :user
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,28 +4,28 @@ class Registration < ActiveRecord::Base
|
|||
belongs_to :dietary_choice
|
||||
|
||||
has_one :supporter_registration
|
||||
has_one :supporter_level, :through => :supporter_registration
|
||||
has_one :supporter_level, through: :supporter_registration
|
||||
has_and_belongs_to_many :social_events
|
||||
has_and_belongs_to_many :events
|
||||
has_and_belongs_to_many :qanswers
|
||||
has_and_belongs_to_many :vchoices
|
||||
|
||||
attr_accessible :user_id, :conference_id, :attending_social_events, :attending_with_partner,
|
||||
:using_affiliated_lodging, :arrival, :departure, :user_attributes, :other_dietary_choice, :dietary_choice_id,
|
||||
:handicapped_access_required, :supporter_registration_attributes, :social_event_ids, :other_special_needs,
|
||||
:event_ids, :attended, :volunteer, :vchoice_ids,
|
||||
:qanswer_ids, :qanswers_attributes
|
||||
:using_affiliated_lodging, :arrival, :departure, :user_attributes, :attended,
|
||||
:other_dietary_choice, :dietary_choice_id, :handicapped_access_required,
|
||||
:supporter_registration_attributes, :social_event_ids, :other_special_needs,
|
||||
:event_ids, :volunteer, :vchoice_ids, :qanswer_ids, :qanswers_attributes
|
||||
|
||||
accepts_nested_attributes_for :user
|
||||
accepts_nested_attributes_for :supporter_registration
|
||||
accepts_nested_attributes_for :social_events
|
||||
accepts_nested_attributes_for :qanswers
|
||||
|
||||
delegate :name, :to => :user
|
||||
delegate :email, :to => :user
|
||||
delegate :nickname, :to => :user
|
||||
delegate :affiliation, :to => :user
|
||||
|
||||
delegate :name, to: :user
|
||||
delegate :email, to: :user
|
||||
delegate :nickname, to: :user
|
||||
delegate :affiliation, to: :user
|
||||
|
||||
alias_attribute :other_needs, :other_special_needs
|
||||
|
||||
after_create :set_week
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class User < ActiveRecord::Base
|
||||
include Gravtastic
|
||||
gravtastic :size => 32
|
||||
gravtastic size: 32
|
||||
|
||||
|
||||
# Include default devise modules. Others available are:
|
||||
|
|
@ -16,11 +16,11 @@ class User < ActiveRecord::Base
|
|||
attr_accessible :email, :password, :password_confirmation, :remember_me, :role_id, :role_ids,
|
||||
:name, :email_public, :biography, :nickname, :affiliation
|
||||
|
||||
has_many :event_users, :dependent => :destroy
|
||||
has_many :events, -> { uniq }, :through => :event_users
|
||||
has_many :registrations, :dependent => :destroy
|
||||
has_many :votes, :dependent => :destroy
|
||||
has_many :voted_events, :through => :votes, :source => :events
|
||||
has_many :event_users, dependent: :destroy
|
||||
has_many :events, -> { uniq }, through: :event_users
|
||||
has_many :registrations, dependent: :destroy
|
||||
has_many :votes, dependent: :destroy
|
||||
has_many :voted_events, through: :votes, source: :events
|
||||
|
||||
accepts_nested_attributes_for :roles
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def role?(role)
|
||||
Rails.logger.debug("Checking role in user")
|
||||
Rails.logger.debug('Checking role in user')
|
||||
!!roles.find_by_name(role.to_s.downcase.camelize)
|
||||
end
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ class User < ActiveRecord::Base
|
|||
|
||||
# If there is a new user, add the necessary attributes
|
||||
if user.new_record?
|
||||
user.password = Devise.friendly_token[0,20]
|
||||
user.password = Devise.friendly_token[0, 20]
|
||||
user.skip_confirmation!
|
||||
user.attributes = params
|
||||
end
|
||||
|
|
@ -99,8 +99,8 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def attending_conference? conference
|
||||
Registration.where(:conference_id => conference.id,
|
||||
:user_id => self.id).count
|
||||
Registration.where(conference_id: conference.id,
|
||||
user_id: self.id).count
|
||||
end
|
||||
|
||||
def proposals conference
|
||||
|
|
@ -118,10 +118,12 @@ class User < ActiveRecord::Base
|
|||
self.biography.split.size
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def biography_limit
|
||||
if !self.biography.nil? && self.biography.split.size > 150
|
||||
errors.add(:abstract, "cannot have more than 150 words")
|
||||
end
|
||||
|
||||
def biography_limit
|
||||
if !self.biography.nil? && self.biography.split.size > 150
|
||||
errors.add(:abstract, 'cannot have more than 150 words')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ class Vote < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
belongs_to :event
|
||||
|
||||
delegate :name, :to => :user
|
||||
delegate :name, to: :user
|
||||
end
|
||||
|
|
|
|||
|
|
@ -20,16 +20,16 @@ class ConferenceSerializer < ActiveModel::Serializer
|
|||
# FIXME: adjusting the format the DIRTY way, for oSC13.
|
||||
# If you think this is ugly, don't look at the methods below
|
||||
def date_range
|
||||
object.date_range_string.try(:split, ",").try(:first)
|
||||
object.date_range_string.try(:split, ',').try(:first)
|
||||
end
|
||||
|
||||
# FIXME: just giving suseconferenceclient something to play with
|
||||
def description
|
||||
"openSUSE Conference 2013 - Power to the Geeko"
|
||||
'openSUSE Conference 2013 - Power to the Geeko'
|
||||
end
|
||||
|
||||
# FIXME: same than the former
|
||||
def url
|
||||
"https://conference.opensuse.org/"
|
||||
'https://conference.opensuse.org/'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@
|
|||
# Needed in order to add the API version number to the conferences array
|
||||
#
|
||||
class ConferencesArraySerializer < ActiveModel::ArraySerializer
|
||||
|
||||
def as_json(*args)
|
||||
json = super
|
||||
json.merge!(:version => 1)
|
||||
json.merge!(version: 1)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
class EventSerializer < ActiveModel::Serializer
|
||||
include ActionView::Helpers::TextHelper
|
||||
|
||||
attributes :guid, :title, :length, :date, :language, :abstract,
|
||||
:speaker_ids, :type, :room, :track
|
||||
attributes :guid, :title, :length, :date, :language, :abstract, :speaker_ids, :type, :room, :track
|
||||
|
||||
def date
|
||||
t = object.start_time
|
||||
t.blank? ? "" : %(#{t.time.strftime("%Y-%m-%dT%H:%M:%S")}#{t.formatted_offset(false)})
|
||||
t.blank? ? '' : %(#{t.time.strftime('%Y-%m-%dT%H:%M:%S')}#{t.formatted_offset(false)})
|
||||
end
|
||||
|
||||
def speaker_ids
|
||||
speakers = object.event_users.select {|i| i.event_role == "speaker" }
|
||||
speakers.map {|i| i.user.id}
|
||||
speakers = object.event_users.select { |i| i.event_role == 'speaker' }
|
||||
speakers.map { |i| i.user.id }
|
||||
end
|
||||
|
||||
def type
|
||||
|
|
@ -31,7 +30,7 @@ class EventSerializer < ActiveModel::Serializer
|
|||
if object.abstract.blank?
|
||||
nil
|
||||
else
|
||||
simple_format(object.abstract).gsub("\n", "")
|
||||
simple_format(object.abstract).gsub('\n', '')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ class RoomSerializer < ActiveModel::Serializer
|
|||
|
||||
# FIXME: just giving suseconferenceclient something to play with
|
||||
def description
|
||||
""
|
||||
''
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class SpeakerSerializer < ActiveModel::Serializer
|
|||
if object.biography.blank?
|
||||
nil
|
||||
else
|
||||
simple_format(object.biography).gsub("\n", "")
|
||||
simple_format(object.biography).gsub('\n', '')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue