From 80e7642121045b72383a2c4b7fd12091b2bd0d3a Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 8 Jun 2017 17:06:34 +0300 Subject: [PATCH] improve applies admin page --- app/helpers/admin/applies_helper.rb | 5 +++++ app/models/course.rb | 4 ++++ app/views/admin/applies/index.html.haml | 24 +++++++++++++++--------- app/views/admin/applies/show.html.haml | 16 +++++++++++++--- 4 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 app/helpers/admin/applies_helper.rb diff --git a/app/helpers/admin/applies_helper.rb b/app/helpers/admin/applies_helper.rb new file mode 100644 index 0000000..04cfff2 --- /dev/null +++ b/app/helpers/admin/applies_helper.rb @@ -0,0 +1,5 @@ +module Admin + module AppliesHelper + + end +end diff --git a/app/models/course.rb b/app/models/course.rb index aa80f3a..d7ad398 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -21,4 +21,8 @@ class Course < ActiveRecord::Base def start_date I18n.l(self.start.to_date , format: :long) end + + def name_id + "#{name}(#{id})" + end end diff --git a/app/views/admin/applies/index.html.haml b/app/views/admin/applies/index.html.haml index 94f1a98..ac07b6c 100644 --- a/app/views/admin/applies/index.html.haml +++ b/app/views/admin/applies/index.html.haml @@ -2,30 +2,36 @@ .col-md-9.applies .row .col-md-10 - %h2 Applies + %h2= @apply_scope.length.to_s + " Applies" =will_paginate @applies .col-md-3 - = #image_tag "applies.jpg" , :class => "img-responsive" .row .col-md-9 %div %table.table.table-striped.table-bordered.table-condensed %thead %tr - %th=sort_link [:office,@q], :id - %th{:colspan => "2"} - %label.checkbox - = @apply_scope.length.to_s + " Applies" + %th=sort_link [:admin,@q], :user_id , title: "Applicant" + %th Course + %th Secondary + %th Plan + %th Comment + %th Discount %tbody - @applies.each do |apply| %tr{:class => "line-#{cycle("1","2")}"} - %td=apply.id.to_s - %td= link_to "Show" , admin_apply_path(apply), :title => "Show" + %td= link_to apply.user.name , admin_user_path(apply.user) + %td= apply.primary_choice_course.name_id + %td= apply.secondary_choice_course.name_id if apply.secondary_choice_course + %td= apply.plan + %td= apply.comment.to_s + %td= apply.discount_code.to_s + =will_paginate @applies .col-md-3 = search_form_for [:admin , @q], :html => { :class => "form-horizontal" }, :method => :get do |f| .form-group - = f.text_field :id_cont , :class => "form-control" , :placeholder => "ID" + = f.text_field :primary_choice_course_id_eq , :class => "form-control" , :placeholder => "course id" = f.submit "Filter", :id => :filter , :class => "btn btn-success" = link_to "Cancel", admin_applies_path, :class => "btn btn-warning" .applies_index_end diff --git a/app/views/admin/applies/show.html.haml b/app/views/admin/applies/show.html.haml index fa9102c..16ad03d 100644 --- a/app/views/admin/applies/show.html.haml +++ b/app/views/admin/applies/show.html.haml @@ -1,8 +1,18 @@ -%h2.applies_show_start - = "Apply : " + @apply.id.to_s +%h2 + = "Applicant : " + @apply.user.name + = link_to @apply.user.email , admin_user_path(@apply.user) +%p +%p + %b= "Course : #{@apply.primary_choice_course.full_name}" + = "Secondary: #{@apply.secondary_choice_course.full_name}" if @apply.secondary_choice_course +%p + = "Comment: #{@apply.comment}" if @apply.comment %p - %b= "Course : " + @apply.primary_choice_course.to_s + = "Discount: #{@apply.discount_code}" unless @apply.discount_code.blank? + +%p + = "Accepted: #{@apply.accepted}" if @apply.accepted = link_to "Back", admin_applies_path, :class => "btn btn-warning" .applies_show_end