Skip to content

Commit

Permalink
remove profession load from user json
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiomagalhaes committed Apr 2, 2024
1 parent 48ad84c commit 292bc22
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
32 changes: 16 additions & 16 deletions app/models/time_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ class TimeEntry < ApplicationRecord
validates :date, presence: true

validates :date, uniqueness: { scope: %i[user_id statement_of_work_id] }
# validate :assignment_must_exist_in_period
# validate :assignment_must_exist_in_period

scope :active_in_period, ->(start_date, end_date) { where('date <= ? AND date >= ?', end_date, start_date) }

# def assignment_must_exist_in_period
# assignment_exists = Assignment.joins(:requirement)
# .where(user_id:)
# .where(requirements: { statement_of_work_id: })
# .exists?(['? >= assignments.start_date AND ? <= assignments.end_date', date, date])
#
# # If not, add an error.
# return if assignment_exists
#
# errors.add(:base,
# "There is no valid assignment for the user
# and statement of work in this period: #{user.name}
# date:#{date} for the SOW: #{statement_of_work.name}
# in the project #{statement_of_work.project.name}")
# end
# def assignment_must_exist_in_period
# assignment_exists = Assignment.joins(:requirement)
# .where(user_id:)
# .where(requirements: { statement_of_work_id: })
# .exists?(['? >= assignments.start_date AND ? <= assignments.end_date', date, date])
#
# # If not, add an error.
# return if assignment_exists
#
# errors.add(:base,
# "There is no valid assignment for the user
# and statement of work in this period: #{user.name}
# date:#{date} for the SOW: #{statement_of_work.name}
# in the project #{statement_of_work.project.name}")
# end
end
3 changes: 0 additions & 3 deletions app/views/users/_user.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
json.extract! user, :id, :active, :contract_type, :first_name,
:last_name, :email, :google_id, :slug, :image_url, :seniority, :profession_id, :country, :internal

# Render the profession partial
json.profession user.profession, partial: 'professions/profession', as: :profession

# Render the permissions partial for each permission
json.permissions user.permissions, partial: 'permissions/permission', as: :permission

Expand Down

0 comments on commit 292bc22

Please sign in to comment.