module Panel::News::BackEnd::NewsBulletinsHelper
  def news_show_reject_reason(news_bulletin)
    by_news_bulletin = news_bulletin.is_rejected
    by_user = (((news_bulletin.create_user_id == current_user.id) rescue nil) or is_manager? or is_admin?)
    by_news_bulletin && by_user
  end
   def news_show_form_status_field(news_bulletin)
    #by_news_bulletin = (!news_bulletin.is_expired? and news_bulletin.is_pending?)
    by_user = ((news_bulletin.news_bulletin_category.authed_users('fact_check').include?(current_user) rescue nil) or is_manager? or is_admin?)
    by_user
  end

  def news_show_approval_link(news_bulletin)
    by_news_bulletin = (!news_bulletin.is_expired? and news_bulletin.is_pending?)
    by_user = ((news_bulletin.news_bulletin_category.authed_users('fact_check').include?(current_user) rescue nil) or is_manager? or is_admin?)
    by_news_bulletin and  by_user
  end

  def news_show_delete_link(news_bulletin)
    by_news_bulletin = (news_bulletin.create_user_id == current_user.id)
    by_user = (is_manager? or is_admin?)
    by_news_bulletin or  by_user
  end

  def show_news_bulletin_title_at_index (news_bulletin)
    if news_bulletin.is_checked?
      link_to news_bulletin.title, panel_news_front_end_news_bulletin_path(news_bulletin, :category_id => news_bulletin.news_bulletin_category.id) rescue ''
    else
      news_bulletin.title
    end  
  end

end