Skip to content

Commit

Permalink
add_vacancy ^O
Browse files Browse the repository at this point in the history
  • Loading branch information
KamMif committed Sep 3, 2016
1 parent f9977ab commit f906b31
Show file tree
Hide file tree
Showing 29 changed files with 292 additions and 104 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ capybara-*.html
/public/system
/coverage/
/spec/tmp
/config/database.yml
/config/secrets.yml
**.orig
rerun.txt
pickle-email-*.html
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/vacancies.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
33 changes: 33 additions & 0 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
@import "bootstrap-sprockets";
@import "bootstrap";

/* forms */

form {
margin-left: 20px;
}
input, textarea, select, .undentable-input {
border: 1px solid black;
width: 20%;
margin-bottom: 15px;
box-sizing: border-box;
}

input {
height: auto !important;
}
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
end
47 changes: 47 additions & 0 deletions app/controllers/vacancies_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# frozen_string_literal: true
class VacanciesController < ApplicationController
before_action :set_vacancy, only: [:edit, :show]
def new
@vacancy = Vacancy.new
end

def index
@vacancy = Vacancy.all
end

def create
@vacancy = Vacancy.new(vacancy_params)
if @vacancy.save
redirect_to vacancy_path(@vacancy), notice: "You vacancy created successfully"
else
render 'new'
end
end

def update
if @vacancy.update_attributes(params[:id])
redirect_to @vacancy
else
render 'edit'
end
end

def edit

end

def show

end

private

def set_vacancy
@vacancy = Vacancy.find(params[:id])
end

def vacancy_params
params.require(:vacancy).permit(:name, :kind, :description, :location, :remote, :company,
:site, :phone)
end
end
1 change: 1 addition & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
module ApplicationHelper
end
2 changes: 2 additions & 0 deletions app/helpers/vacancies_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module VacanciesHelper
end
1 change: 1 addition & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
class ApplicationJob < ActiveJob::Base
end
1 change: 1 addition & 0 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
Expand Down
1 change: 1 addition & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
14 changes: 14 additions & 0 deletions app/models/vacancy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true
class Vacancy < ApplicationRecord
validates :name, presence: true
validates :kind, presence: true
validates :description, presence: true
validates :contact_to, presence: true
validates :expire, presence: true

def expire_dates
expire_dates = [7, 14, 30]
expire_at = DateTime.now + expire_dates[params[:expire]].days
end

end
38 changes: 38 additions & 0 deletions app/views/vacancies/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<div class="row-fluid">
<div class="span4 well">
<%= form_for(@vacancy) do |f| %>
<%= f.label :name %><br>
<%= f.text_field :name %><br>

<%= f.label :kind %><br>
<%= f.text_field :kind %><br>

<%= f.label :description %><br>
<%= f.text_field :description %><br>

<%= f.label :location %><br>
<%= f.text_field :location %><br>

<%= f.label :remote %><br>
<%= f.text_field :remote %><br>

<%= f.label :company %><br>
<%= f.text_field :company %><br>

<%= f.label :site %><br>
<%= f.url_field :site %><br>

<%= f.label :phone %><br>
<%= f.telephone_field :phone %><br>

<%= f.label :contact_to %><br>
<%= f.text_field :contact_to %><br>

<%= f.label :expire %><br>
<%= f.select(:expire, options_for_select( [[7],[14],[30]] )) %><br>

<%= f.submit "Create vacancy", class: "btn btn-large btn-primary" %>

<% end %>
</div>
</div>
3 changes: 3 additions & 0 deletions app/views/vacancies/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>Edit Vacancy</h1>

<%= render 'form' %>
7 changes: 7 additions & 0 deletions app/views/vacancies/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h1>All vacancy</h1>

<% @vacancy.each do |v| %>
<h2><%= link_to v.name, v %><h2/>
<% end %>

<%= link_to "New Vacancy", new_vacancy_path %>
3 changes: 3 additions & 0 deletions app/views/vacancies/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>Create a new vacancy</h1>

<%= render 'form' %>
6 changes: 6 additions & 0 deletions app/views/vacancies/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>Vacancy</h1>

<h2><%= @vacancy.name %></h2>
<%= link_to 'Edit', edit_vacancy_path(@vacancy) %>


1 change: 1 addition & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# This file is used by Rack-based servers to start the application.

require_relative 'config/environment'
Expand Down
54 changes: 0 additions & 54 deletions config/database.yml

This file was deleted.

1 change: 1 addition & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.secret_key_base = ENV["SECRET_KEY_BASE"]
end
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :vacancies
root 'vacancies#index'

end
18 changes: 18 additions & 0 deletions db/migrate/20160827161434_create_vacancies.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class CreateVacancies < ActiveRecord::Migration[5.0]
def change
create_table :vacancies do |t|
t.string :name
t.string :kind
t.text :description
t.string :location
t.boolean :remote
t.string :company
t.string :site
t.string :phone
t.string :contact_to
t.integer :user_id

t.timestamps
end
end
end
5 changes: 5 additions & 0 deletions db/migrate/20160901203829_add_expire_columns_to_vacancies.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddExpireColumnsToVacancies < ActiveRecord::Migration[5.0]
def change
add_column :vacancies, :expire, :integer
end
end
5 changes: 5 additions & 0 deletions db/migrate/20160903082326_change_colunm_vacancies.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeColunmVacancies < ActiveRecord::Migration[5.0]
def change_table vacancies
rename :expire, :expire_at
end
end
5 changes: 5 additions & 0 deletions db/migrate/20160903082931_change_table_vacancies.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeTableVacancies < ActiveRecord::Migration[5.0]
def change
change_column :vacancies, :expire, :DateTime
end
end
5 changes: 5 additions & 0 deletions db/migrate/20160903085417_changes_vacancy_colmns.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangesVacancyColmns < ActiveRecord::Migration[5.0]
def change
change_column :vacancies, :expire, :integer
end
end
5 changes: 5 additions & 0 deletions db/migrate/20160903085743_add_expire_at_to_vacancies.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddExpireAtToVacancies < ActiveRecord::Migration[5.0]
def change
add_column :vacancies, :expire_at, :DateTime
end
end
32 changes: 32 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160903085743) do

create_table "vacancies", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "name"
t.string "kind"
t.text "description", limit: 65535
t.string "location"
t.boolean "remote"
t.string "company"
t.string "site"
t.string "phone"
t.string "contact_to"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "expire"
t.datetime "expire_at"
end

end
Loading

0 comments on commit f906b31

Please sign in to comment.