From 3c356cbaaf36252214135bb35bb3f20fed2ececf Mon Sep 17 00:00:00 2001 From: Aditya Prakash Date: Sun, 17 Apr 2016 10:48:56 +0530 Subject: [PATCH] Remove unused functions from user model set_up is callback and should be a private method. removed methods: * ticket(id) was introduced in 5f8a8ac6, however never used. * self.prepare(params) only use instance was removed in d21e19b9 * attending_conference?(conference) introduced in merge of person and user model 23bf55b6, any previous use instance difficult to find * biography_word_count: we are using js for this now * biography_limit only use instance was removed in 23bf55b6 --- app/models/user.rb | 47 ++++------------------------------------------ 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index d548853e..3b282955 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -61,13 +61,6 @@ class User < ActiveRecord::Base self.subscriptions.find_by(conference_id: conference.id).present? end - # Returns the purchased ticket - # ====Returns - # * +TicketUser::ActiveRecord_Relation+ -> user - def ticket(id) - ticket_purchases.where(ticket_id: id).first - end - def supports? conference ticket_purchases.find_by(conference_id: conference.id).present? end @@ -122,12 +115,6 @@ class User < ActiveRecord::Base user end - def setup_role - if User.count == 1 && User.first.email == 'deleted@localhost.osem' - self.is_admin = true - end - end - # Gets the roles of the user, groups them by role.name and returns the resource(s) of each role # ====Returns # * +Hash+ * -> e.g. 'organizer' => "(conf1, conf2)" @@ -140,20 +127,6 @@ class User < ActiveRecord::Base result end - def self.prepare(params) - email = params['email'] - user = User.where(email: email).first_or_initialize - - # If there is a new user, add the necessary attributes - if user.new_record? - user.password = Devise.friendly_token[0, 20] - user.skip_confirmation! - user.attributes = params - end - - user - end - def registered registrations = self.registrations if registrations.count == 0 @@ -176,11 +149,6 @@ class User < ActiveRecord::Base !confirmed_at.nil? end - def attending_conference?(conference) - Registration.where(conference_id: conference.id, - user_id: id).count - end - def proposals(conference) events.where('program_id = ? AND event_users.event_role=?', conference.program.id, 'submitter') end @@ -189,18 +157,11 @@ class User < ActiveRecord::Base proposals(conference).count end - def biography_word_count - if biography.nil? - 0 - else - biography.split.size - end - end - private - def biography_limit - errors.add(:abstract, 'cannot have more than 150 words') if biography && - biography.split.size > 150 + def setup_role + if User.count == 1 && User.first.email == 'deleted@localhost.osem' + self.is_admin = true + end end end