From 3adab3f0ae7b5be3dae645e05474dfbecab42da3 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 30 Dec 2014 12:14:55 +0200 Subject: [PATCH] Add legal documents view --- .../admin/legal_documents_controller.rb | 9 +++++++++ app/models/ability.rb | 1 + .../admin/domains/partials/_legal_documents.haml | 14 ++++++++++++++ app/views/admin/domains/show.haml | 2 ++ config/locales/en.yml | 3 +++ config/routes.rb | 2 ++ 6 files changed, 31 insertions(+) create mode 100644 app/controllers/admin/legal_documents_controller.rb create mode 100644 app/views/admin/domains/partials/_legal_documents.haml diff --git a/app/controllers/admin/legal_documents_controller.rb b/app/controllers/admin/legal_documents_controller.rb new file mode 100644 index 000000000..ff5414e40 --- /dev/null +++ b/app/controllers/admin/legal_documents_controller.rb @@ -0,0 +1,9 @@ +class Admin::LegalDocumentsController < AdminController + load_and_authorize_resource + + def show + @ld = LegalDocument.find(params[:id]) + file = Base64.decode64(@ld.body) + send_data file, filename: "#{@ld.created_at}.#{@ld.document_type}" + end +end diff --git a/app/models/ability.rb b/app/models/ability.rb index d9d6e60ef..a38de2a6a 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -23,6 +23,7 @@ class Ability can :manage, User can :manage, EppUser can :manage, Keyrelay + can :manage, LegalDocument can :index, :delayed_job can :create, :zonefile can :access, :settings_menu diff --git a/app/views/admin/domains/partials/_legal_documents.haml b/app/views/admin/domains/partials/_legal_documents.haml new file mode 100644 index 000000000..b9fe5144e --- /dev/null +++ b/app/views/admin/domains/partials/_legal_documents.haml @@ -0,0 +1,14 @@ +.panel.panel-default + .panel-heading.clearfix + = t('legal_documents') + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-8'}= t('created_at') + %th{class: 'col-xs-4'}= t('type') + %tbody + - @domain.legal_documents.each do |x| + %tr + %td= link_to(x.created_at, [:admin, x]) + %td= x.document_type diff --git a/app/views/admin/domains/show.haml b/app/views/admin/domains/show.haml index 9118a23aa..bf064dfb8 100644 --- a/app/views/admin/domains/show.haml +++ b/app/views/admin/domains/show.haml @@ -25,3 +25,5 @@ .col-md-12= render 'admin/domains/partials/dnskeys' .row .col-md-12= render 'admin/domains/partials/keyrelays' +.row + .col-md-12= render 'admin/domains/partials/legal_documents' diff --git a/config/locales/en.yml b/config/locales/en.yml index 443522eab..8730c7df8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -469,3 +469,6 @@ en: keyrelay_details: 'Keyrelay details' unknown_expiry_absolute_pattern: 'Expiry absolute must be compatible to ISO 8601' domain_name: 'Domain name' + created_at: 'Created at' + type: 'Type' + legal_documents: 'Legal documents' diff --git a/config/routes.rb b/config/routes.rb index 14521d126..1c9ef495d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,6 +13,8 @@ Rails.application.routes.draw do resources :zonefile_settings + resources :legal_documents + resources :keyrelays resources :domains resources :settings