From 3365edcdf0e95f38b6caa1d3816922c549a161dd Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Thu, 2 Oct 2014 20:07:36 +0200 Subject: [PATCH] Add admin interface for user feedbacks --- .../admin/user_feedbacks_controller.rb | 16 ++++++++++++ app/models/user_feedback.rb | 1 + .../admin/user_feedbacks/index.html.slim | 25 +++++++++++++++++++ app/views/layouts/administrator.html.slim | 5 ++-- config/locales/models.en.yml | 2 ++ config/routes.rb | 2 ++ 6 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 app/controllers/admin/user_feedbacks_controller.rb create mode 100644 app/views/admin/user_feedbacks/index.html.slim diff --git a/app/controllers/admin/user_feedbacks_controller.rb b/app/controllers/admin/user_feedbacks_controller.rb new file mode 100644 index 00000000..dfb1cd33 --- /dev/null +++ b/app/controllers/admin/user_feedbacks_controller.rb @@ -0,0 +1,16 @@ +# encoding: UTF-8 +module Admin + class UserFeedbacksController < Admin::ApplicationController + def index + @user_feedbacks = UserFeedback.all(page: params[:page], per_page: params[:per_page].presence || 40 ) + end + + def show + render nothing: true + end + + def edit + render nothing: true + end + end +end diff --git a/app/models/user_feedback.rb b/app/models/user_feedback.rb index 2021b788..267f214a 100644 --- a/app/models/user_feedback.rb +++ b/app/models/user_feedback.rb @@ -1,5 +1,6 @@ class UserFeedback include SimplyStored::Couch + per_page_method :limit_value #kaminari property :content belongs_to :user end diff --git a/app/views/admin/user_feedbacks/index.html.slim b/app/views/admin/user_feedbacks/index.html.slim new file mode 100644 index 00000000..997b84c7 --- /dev/null +++ b/app/views/admin/user_feedbacks/index.html.slim @@ -0,0 +1,25 @@ +- model_class = UserFeedback +.page-header= title :index, model_class +- if @user_feedbacks.any? + = paginate @user_feedbacks + table.table.table-striped + thead + tr + th= User.model_name.human + th= model_class.human_attribute_name(:content) + th= model_class.human_attribute_name(:created_at) + th=t 'helpers.actions.title' + tbody + - @user_feedbacks.each do |user_feedback| + tr + td= link_to user_feedback.user.email, [:admin, user_feedback.user] + td= user_feedback.content + td=l user_feedback.created_at, format: :short + td + = link_to t('helpers.links.edit'), [:edit, :admin, user_feedback], class: 'btn btn-mini' + ' + = link_to t("helpers.links.destroy"), [:admin, user_feedback], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger' +- else + = no_content_given model_class +/= link_to t("helpers.links.new"), new_admin_user_path, class: 'btn btn-primary' + diff --git a/app/views/layouts/administrator.html.slim b/app/views/layouts/administrator.html.slim index 7a50cd50..b9b5f043 100644 --- a/app/views/layouts/administrator.html.slim +++ b/app/views/layouts/administrator.html.slim @@ -25,6 +25,7 @@ html lang="en" section.top-bar-section ul.left li= link_to User.model_name.human_plural, admin_users_path + li= link_to "User Feedback", admin_user_feedbacks_path li.divider ul.left li.has-dropdown.not-click @@ -49,11 +50,11 @@ html lang="en" .content - if flash[:alert].present? - .alert.alert-error + .alert-box.alert a.close data-dismiss="alert" × div= flash[:alert] - if flash[:notice].present? - .alert.alert-success + .alert-box.success a.close data-dismiss="alert" × div= flash[:notice] .row diff --git a/config/locales/models.en.yml b/config/locales/models.en.yml index 73c8fb17..61c4e851 100644 --- a/config/locales/models.en.yml +++ b/config/locales/models.en.yml @@ -10,6 +10,7 @@ en: product_category: Product category section: Section join_request: Join request + user_feedback: User feedback plural: user: Users supplier: Restaurants @@ -20,6 +21,7 @@ en: product_category: Product categories section: Sections join_request: Join requests + user_feedback: User feedbacks attributes: product_category: name: Name diff --git a/config/routes.rb b/config/routes.rb index 8327635a..fd256ebd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,6 +13,8 @@ Qwaiter::Application.routes.draw do resources :orders resources :sections + resources :user_feedbacks + resources :lists resources :products resources :product_categories