Skip to content

Commit

Permalink
Fix missing metadata panel display
Browse files Browse the repository at this point in the history
  • Loading branch information
abartov committed Nov 19, 2024
1 parent 98afb79 commit 15bdcf1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions app/controllers/report_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ def missing_metadata
filters << ' include_images is null ' unless params[:images].present?
filters << ' independent is null ' unless params[:independent].present?
filters << ' genre is null ' unless params[:genre].present?
filters << ' task_teams.task_id is null ' unless params[:team].present?
filters = filters.join(' OR ')
condition = "state <> 'ready_to_publish' AND (kind_id = #{typing} OR kind_id = #{proofing})"
condition += "AND (#{filters})" if filters.present?
condition += "AND name like '%#{params[:q]}%'" if params[:q].present?
condition = "name like '%#{params[:q]}%' AND #{condition}" if params[:q].present?
condition += " AND (#{filters})" if filters.present?
if params[:team].present?
@tasks = Task.where(condition).paginate(:page => params[:page], :per_page => params[:per_page])
else
# joins team_memberships to return tasks that aren't associated with a team
@tasks = Task.joins('LEFT JOIN task_teams ON tasks.id = task_teams.task_id').where("task_teams.task_id IS NULL AND #{condition}").paginate(:page => params[:page], :per_page => params[:per_page])
@tasks = Task.joins('LEFT JOIN task_teams ON tasks.id = task_teams.task_id').where("#{condition}").paginate(:page => params[:page], :per_page => params[:per_page])
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def has_task?(task)

# return users whose role in the team is 'lead'
def team_leads
users.joins(:team_memberships).where(team_memberships: {team_role: TeamMembership.team_roles[:lead], left: nil})
users.where(team_memberships: {team_role: TeamMembership.team_roles[:lead], left: nil})
end

def team_lead_memberships
Expand All @@ -38,7 +38,7 @@ def all_team_memberships_ever
end

def user_ids
users.joins(:team_memberships).where(team_memberships: {left: nil}).map(&:id)
users.where(team_memberships: {left: nil}).map(&:id)
end

def team_lead_ids
Expand Down
6 changes: 3 additions & 3 deletions app/views/report/missing_metadata_panel.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
= form_tag 'update_metadata', remote: true do
= hidden_field_tag :task_id, @task.id
= label_tag 'סוגה'
= select_tag :genre, options_for_select(['']+Task.genres.keys.map{|g| [g, g]})
= select_tag :genre, options_for_select(['']+Task.genres.keys.map{|g| [g, g]}, @task.genre)
= label_tag 'אפשר להעלות בנפרד?'
= check_box_tag :independent
= check_box_tag :independent, '1', @task.independent
= label_tag 'מותר להעלות תמונות?'
= check_box_tag :include_images
= check_box_tag :include_images, '1', @task.include_images
%p
= label_tag 'צוות'
= select_tag :team_id, options_for_select(Team.all.map{|t| [t.name, t.id]}), include_blank: true
Expand Down

0 comments on commit 15bdcf1

Please sign in to comment.