start on application
This commit is contained in:
parent
409c92b7f5
commit
0a46f2dc46
|
@ -0,0 +1,19 @@
|
|||
module Admin
|
||||
class AppliesController < Admin::ApplicationController
|
||||
# To customize the behavior of this controller,
|
||||
# simply overwrite any of the RESTful actions. For example:
|
||||
#
|
||||
# def index
|
||||
# super
|
||||
# @resources = Apply.all.paginate(10, params[:page])
|
||||
# end
|
||||
|
||||
# Define a custom finder by overriding the `find_resource` method:
|
||||
# def find_resource(param)
|
||||
# Apply.find_by!(slug: param)
|
||||
# end
|
||||
|
||||
# See https://administrate-docs.herokuapp.com/customizing_controller_actions
|
||||
# for more information
|
||||
end
|
||||
end
|
|
@ -32,6 +32,6 @@ class AppliesController < ApplicationController
|
|||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def apply_params
|
||||
params.require(:apply).permit(:primary_choice_id, :secondary_choice_id, :comment, :user_id, :sent)
|
||||
params.require(:apply).permit(:primary_choice_course_id, :secondary_choice_course_id, :comment, :user_id, :sent)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
require "administrate/base_dashboard"
|
||||
|
||||
class ApplyDashboard < Administrate::BaseDashboard
|
||||
# ATTRIBUTE_TYPES
|
||||
# a hash that describes the type of each of the model's fields.
|
||||
#
|
||||
# Each different type represents an Administrate::Field object,
|
||||
# which determines how the attribute is displayed
|
||||
# on pages throughout the dashboard.
|
||||
ATTRIBUTE_TYPES = {
|
||||
user: Field::BelongsTo,
|
||||
id: Field::Number,
|
||||
primary_choice_course_id: Field::Number,
|
||||
secondary_choice_course_id: Field::Number,
|
||||
comment: Field::Text,
|
||||
sent: Field::DateTime,
|
||||
created_at: Field::DateTime,
|
||||
updated_at: Field::DateTime,
|
||||
}
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's index page.
|
||||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:user,
|
||||
:id,
|
||||
:primary_choice_course_id,
|
||||
:secondary_choice_course_id,
|
||||
]
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [
|
||||
:user,
|
||||
:id,
|
||||
:primary_choice_course_id,
|
||||
:secondary_choice_course_id,
|
||||
:comment,
|
||||
:sent,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
]
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:user,
|
||||
:primary_choice_course_id,
|
||||
:secondary_choice_course_id,
|
||||
:comment,
|
||||
:sent,
|
||||
]
|
||||
|
||||
# Overwrite this method to customize how applies are displayed
|
||||
# across all pages of the admin dashboard.
|
||||
#
|
||||
# def display_resource(apply)
|
||||
# "Apply ##{apply.id}"
|
||||
# end
|
||||
end
|
|
@ -1,2 +1,12 @@
|
|||
module AppliesHelper
|
||||
def course_select
|
||||
Course.all.order(:name).map { |c| [c.name, c.id ] }
|
||||
end
|
||||
|
||||
def plan_select
|
||||
{ free: "Free - Only applies on the free course" ,
|
||||
standard: "2100¢ - 8 week prepayment, no cancellation" ,
|
||||
flex: "2400¢ - 8 week prepayment, 2 week cancellation" ,
|
||||
super_flex: "2900¢ - 2 week prepayment, stop anytime" }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class Apply < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
|
||||
validate :primary_choice_id
|
||||
validate :primary_choice_course_id
|
||||
end
|
||||
|
|
|
@ -5,9 +5,18 @@
|
|||
= simple_form_for(@apply , url: application_path ) do |f|
|
||||
= f.error_notification
|
||||
|
||||
.form-inputs
|
||||
= f.input :primary_choice_id
|
||||
= f.input :secondary_choice_id
|
||||
.form-input
|
||||
= f.label "Primary choice to start"
|
||||
= f.select :primary_choice_course_id , course_select #, :prompt => "Select" #, :include_blank => true
|
||||
.form-input
|
||||
= f.label "Optional secondary choice to start"
|
||||
= f.select :secondary_choice_course_id , course_select
|
||||
.form-input
|
||||
= f.label "Payment plan (prices for 2 week modules)"
|
||||
= f.select :plan , plan_select.invert
|
||||
.form-input
|
||||
= f.input :discount_code , label: "Optional code determines prearranged discount"
|
||||
.form-input
|
||||
= f.input :comment
|
||||
|
||||
.form-actions
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
%p
|
||||
%b Primary choice:
|
||||
= @apply.primary_choice_id
|
||||
= @apply.primary_choice_course_id
|
||||
%p
|
||||
%b Secondary choice:
|
||||
= @apply.secondary_choice_id
|
||||
= @apply.secondary_choice_course_id
|
||||
%p
|
||||
%b Comment:
|
||||
= @apply.comment
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
full unused weeks returned.
|
||||
%br
|
||||
Like with plane tickets you can acquire more flexibility for a comparatively small extra cost.
|
||||
In short, the flex fee (1100€ extra) lets you stop the course at any full week, while still
|
||||
In short, the flex fee (1200€ extra) lets you stop the course at any full week, while still
|
||||
paying the full price up front.
|
||||
%br
|
||||
With the pay-as-you-go fee you only have to pay for the next 2 weeks ahead, and you can stop
|
||||
any time you like. Pay-as-you-go costs 2900€ for every 2 week module.
|
||||
With the super_flex fee you only have to pay for the next 2 weeks ahead, and you can stop
|
||||
any time you like. Super flex costs 2900€ for every 2 week module.
|
||||
%br
|
||||
See full details in our
|
||||
= link_to "Payment page" , page_path(:payment)
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
class CreateApplies < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :applies do |t|
|
||||
t.integer :primary_choice_id
|
||||
t.integer :secondary_choice_id
|
||||
t.integer :primary_choice_course_id
|
||||
t.integer :secondary_choice_course_id
|
||||
t.string :plan
|
||||
t.string :discount_code
|
||||
t.text :comment
|
||||
t.integer :user_id
|
||||
t.date :sent
|
||||
|
||||
t.date :accepted
|
||||
|
||||
t.integer :funds_received
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
|
|
12
db/schema.rb
12
db/schema.rb
|
@ -14,13 +14,17 @@
|
|||
ActiveRecord::Schema.define(version: 20160517133538) do
|
||||
|
||||
create_table "applies", force: :cascade do |t|
|
||||
t.integer "primary_choice_id"
|
||||
t.integer "secondary_choice_id"
|
||||
t.integer "primary_choice_course_id"
|
||||
t.integer "secondary_choice_course_id"
|
||||
t.string "plan"
|
||||
t.string "discount_code"
|
||||
t.text "comment"
|
||||
t.integer "user_id"
|
||||
t.date "sent"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.date "accepted"
|
||||
t.integer "funds_received"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "courses", force: :cascade do |t|
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
FactoryGirl.define do
|
||||
factory :apply do
|
||||
primary_choice_id 1
|
||||
secondary_choice_id 1
|
||||
primary_choice_course_id 1
|
||||
secondary_choice_course_id 1
|
||||
comment "MyText"
|
||||
user_id 1
|
||||
sent "2016-05-17"
|
||||
|
|
Loading…
Reference in New Issue