# -*- coding: utf-8 -*-

# Family. Возвращаю подробности отчета
class CrxjsonController < ApplicationController

  def show
    jsn = { }    
    if Report.exists? params[:id]
      @report = Report.find params[:id]      
      key_sha = params[:key_sha]
      key_sha_new = @report.get_key_sha        
      if key_sha == key_sha_new
        status = 200      
        jsn = @report.comment_for_json
      else
        status = 403
      end
      jsn[:status] = status 
      jsn[:root] = true
    else
      jsn[:status] = 404
      
    end
    respond_to do |format|
      format.json { render :json => jsn}
    end 
  end


  def shagetkforexmpl
    @report = Report.find params[:id]
     respond_to do |format|
      format.json { render :json => {:k => @report.get_key_sha}, :root => true }
    end 
  end



end
