Merge branch 'master' into text-camp

This commit is contained in:
Torsten Ruger 2017-06-08 22:35:34 +03:00
commit 0d768c93a8
11 changed files with 70 additions and 23 deletions

View File

@ -0,0 +1,5 @@
module Admin
module AppliesHelper
end
end

View File

@ -0,0 +1,11 @@
module Admin
module UsersHelper
def application_link(user)
return "" unless user.application
link_to user.application.primary_choice_course.start_date ,
admin_apply_path(user.application) ,
title: user.application.summary
end
end
end

View File

@ -14,4 +14,15 @@ class Apply < ActiveRecord::Base
def plan_name
PLANS[self.plan.to_sym]
end
def plan_price
plan_name.split(" - ").first
end
def summary
sum = "Comment: #{self.comment}\n"
sum += "Discount: #{self.discount_code}\n" unless self.discount_code.blank?
sum +="Secondary: #{self.secondary_choice_course.name}" if self.secondary_choice_course_id
sum + plan_name
end
end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -21,7 +21,7 @@
%tr{:class => "line-#{cycle("1","2")}"}
%td= link_to user.email , admin_user_path(user), :title => "#{user.street}\n#{user.city}\n#{user.country}"
%td= link_to "#{user.resume.percent} %" , admin_resume_path(user.resume)
%td= link_to user.application.primary_choice_course.start_date , admin_apply_path(user.application) if user.application
%td= application_link(user)
=will_paginate @users
.col-md-3
= search_form_for [:admin , @q], :html => { :class => "form-horizontal" }, :method => :get do |f|

View File

@ -0,0 +1,7 @@
class RemoveStreetCityCountryFromResume < ActiveRecord::Migration[5.0]
def change
remove_column :resumes, :street, :string
remove_column :resumes, :city, :string
remove_column :resumes, :country, :string
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170602115219) do
ActiveRecord::Schema.define(version: 20170608141102) do
create_table "applies", force: :cascade do |t|
t.integer "primary_choice_course_id"
@ -35,9 +35,6 @@ ActiveRecord::Schema.define(version: 20170602115219) do
end
create_table "resumes", force: :cascade do |t|
t.string "street"
t.string "city"
t.string "country"
t.text "school"
t.text "uni"
t.text "internship"

View File

@ -14,10 +14,6 @@ FactoryGirl.define do
finance "I got money"
other "Some final words"
street "WhereIlive 111"
city "CityOfTesters"
country "WhereIam"
user
end
end

View File

@ -17,10 +17,10 @@ RSpec.describe Resume, type: :model do
resume = build :resume
expect(resume.percent).to eq 0
end
it "has 7 percent when one is filled" do
it "has 9 percent when one is filled" do
resume = build :resume
resume.motivation = "I am motivated"
expect(resume.percent).to eq 7
expect(resume.percent).to eq 9
end
it "has 100 percent when all are filled" do
resume = build :filled_resume