Showing
11 changed files
with
227 additions
and
8 deletions
... | @@ -5,11 +5,16 @@ git_source(:github) do |repo_name| | ... | @@ -5,11 +5,16 @@ git_source(:github) do |repo_name| |
5 | "https://github.com/#{repo_name}.git" | 5 | "https://github.com/#{repo_name}.git" |
6 | end | 6 | end |
7 | 7 | ||
8 | +gem 'crud_controller', git: 'git@git.ukko.mx:ukko/crud_controller.git' | ||
9 | +gem 'heimdall_engine', git: 'git@git.ukko.mx:iker.n/heimdall-engine.git', branch: 'rails_5_bootstrap_4' | ||
10 | +gem 'paranoia' | ||
11 | +gem 'paper_trail' | ||
12 | + | ||
8 | 13 | ||
9 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' | 14 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' |
10 | gem 'rails', '~> 5.0.6' | 15 | gem 'rails', '~> 5.0.6' |
11 | # Use sqlite3 as the database for Active Record | 16 | # Use sqlite3 as the database for Active Record |
12 | -gem 'sqlite3' | 17 | +gem 'pg' |
13 | # Use Puma as the app server | 18 | # Use Puma as the app server |
14 | gem 'puma', '~> 3.0' | 19 | gem 'puma', '~> 3.0' |
15 | # Use SCSS for stylesheets | 20 | # Use SCSS for stylesheets | ... | ... |
1 | +GIT | ||
2 | + remote: git@git.ukko.mx:iker.n/heimdall-engine.git | ||
3 | + revision: 23006b005c646fd304c1a3f9f509f9674d060ef5 | ||
4 | + branch: rails_5_bootstrap_4 | ||
5 | + specs: | ||
6 | + heimdall_engine (5.1.6) | ||
7 | + bcrypt | ||
8 | + binding_of_caller | ||
9 | + bootstrap-multiselect-rails | ||
10 | + bootstrap-switch-rails | ||
11 | + jquery-rails | ||
12 | + jwt | ||
13 | + paranoia | ||
14 | + rails (>= 4.2.4) | ||
15 | + rspec-rails | ||
16 | + simple_form | ||
17 | + slim | ||
18 | + | ||
19 | +GIT | ||
20 | + remote: git@git.ukko.mx:ukko/crud_controller.git | ||
21 | + revision: 5452f4ed92d8974d165b932161a046eff25eebeb | ||
22 | + specs: | ||
23 | + crud_controller (0.3.0) | ||
24 | + | ||
1 | GEM | 25 | GEM |
2 | remote: https://rubygems.org/ | 26 | remote: https://rubygems.org/ |
3 | specs: | 27 | specs: |
... | @@ -39,7 +63,13 @@ GEM | ... | @@ -39,7 +63,13 @@ GEM |
39 | minitest (~> 5.1) | 63 | minitest (~> 5.1) |
40 | tzinfo (~> 1.1) | 64 | tzinfo (~> 1.1) |
41 | arel (7.1.4) | 65 | arel (7.1.4) |
66 | + bcrypt (3.1.12) | ||
42 | bindex (0.5.0) | 67 | bindex (0.5.0) |
68 | + binding_of_caller (0.8.0) | ||
69 | + debug_inspector (>= 0.0.1) | ||
70 | + bootstrap-multiselect-rails (0.9.9) | ||
71 | + rails (>= 4.0.0) | ||
72 | + bootstrap-switch-rails (3.3.3) | ||
43 | builder (3.2.3) | 73 | builder (3.2.3) |
44 | byebug (10.0.2) | 74 | byebug (10.0.2) |
45 | coffee-rails (4.2.2) | 75 | coffee-rails (4.2.2) |
... | @@ -51,6 +81,8 @@ GEM | ... | @@ -51,6 +81,8 @@ GEM |
51 | coffee-script-source (1.12.2) | 81 | coffee-script-source (1.12.2) |
52 | concurrent-ruby (1.0.5) | 82 | concurrent-ruby (1.0.5) |
53 | crass (1.0.4) | 83 | crass (1.0.4) |
84 | + debug_inspector (0.0.3) | ||
85 | + diff-lcs (1.3) | ||
54 | erubis (2.7.0) | 86 | erubis (2.7.0) |
55 | execjs (2.7.0) | 87 | execjs (2.7.0) |
56 | ffi (1.9.25) | 88 | ffi (1.9.25) |
... | @@ -65,6 +97,7 @@ GEM | ... | @@ -65,6 +97,7 @@ GEM |
65 | rails-dom-testing (>= 1, < 3) | 97 | rails-dom-testing (>= 1, < 3) |
66 | railties (>= 4.2.0) | 98 | railties (>= 4.2.0) |
67 | thor (>= 0.14, < 2.0) | 99 | thor (>= 0.14, < 2.0) |
100 | + jwt (2.1.0) | ||
68 | listen (3.0.8) | 101 | listen (3.0.8) |
69 | rb-fsevent (~> 0.9, >= 0.9.4) | 102 | rb-fsevent (~> 0.9, >= 0.9.4) |
70 | rb-inotify (~> 0.9, >= 0.9.7) | 103 | rb-inotify (~> 0.9, >= 0.9.7) |
... | @@ -81,6 +114,12 @@ GEM | ... | @@ -81,6 +114,12 @@ GEM |
81 | nio4r (2.3.1) | 114 | nio4r (2.3.1) |
82 | nokogiri (1.8.2) | 115 | nokogiri (1.8.2) |
83 | mini_portile2 (~> 2.3.0) | 116 | mini_portile2 (~> 2.3.0) |
117 | + paper_trail (9.1.1) | ||
118 | + activerecord (>= 4.2, < 5.3) | ||
119 | + request_store (~> 1.1) | ||
120 | + paranoia (2.4.1) | ||
121 | + activerecord (>= 4.0, < 5.3) | ||
122 | + pg (1.0.0) | ||
84 | puma (3.11.4) | 123 | puma (3.11.4) |
85 | rack (2.0.5) | 124 | rack (2.0.5) |
86 | rack-test (0.6.3) | 125 | rack-test (0.6.3) |
... | @@ -112,6 +151,25 @@ GEM | ... | @@ -112,6 +151,25 @@ GEM |
112 | rb-fsevent (0.10.3) | 151 | rb-fsevent (0.10.3) |
113 | rb-inotify (0.9.10) | 152 | rb-inotify (0.9.10) |
114 | ffi (>= 0.5.0, < 2) | 153 | ffi (>= 0.5.0, < 2) |
154 | + request_store (1.4.1) | ||
155 | + rack (>= 1.4) | ||
156 | + rspec-core (3.7.1) | ||
157 | + rspec-support (~> 3.7.0) | ||
158 | + rspec-expectations (3.7.0) | ||
159 | + diff-lcs (>= 1.2.0, < 2.0) | ||
160 | + rspec-support (~> 3.7.0) | ||
161 | + rspec-mocks (3.7.0) | ||
162 | + diff-lcs (>= 1.2.0, < 2.0) | ||
163 | + rspec-support (~> 3.7.0) | ||
164 | + rspec-rails (3.7.2) | ||
165 | + actionpack (>= 3.0) | ||
166 | + activesupport (>= 3.0) | ||
167 | + railties (>= 3.0) | ||
168 | + rspec-core (~> 3.7.0) | ||
169 | + rspec-expectations (~> 3.7.0) | ||
170 | + rspec-mocks (~> 3.7.0) | ||
171 | + rspec-support (~> 3.7.0) | ||
172 | + rspec-support (3.7.1) | ||
115 | sass (3.5.6) | 173 | sass (3.5.6) |
116 | sass-listen (~> 4.0.0) | 174 | sass-listen (~> 4.0.0) |
117 | sass-listen (4.0.0) | 175 | sass-listen (4.0.0) |
... | @@ -123,6 +181,12 @@ GEM | ... | @@ -123,6 +181,12 @@ GEM |
123 | sprockets (>= 2.8, < 4.0) | 181 | sprockets (>= 2.8, < 4.0) |
124 | sprockets-rails (>= 2.0, < 4.0) | 182 | sprockets-rails (>= 2.0, < 4.0) |
125 | tilt (>= 1.1, < 3) | 183 | tilt (>= 1.1, < 3) |
184 | + simple_form (4.0.1) | ||
185 | + actionpack (>= 5.0) | ||
186 | + activemodel (>= 5.0) | ||
187 | + slim (3.0.9) | ||
188 | + temple (>= 0.7.6, < 0.9) | ||
189 | + tilt (>= 1.3.3, < 2.1) | ||
126 | spring (2.0.2) | 190 | spring (2.0.2) |
127 | activesupport (>= 4.2) | 191 | activesupport (>= 4.2) |
128 | spring-watcher-listen (2.0.1) | 192 | spring-watcher-listen (2.0.1) |
... | @@ -135,7 +199,7 @@ GEM | ... | @@ -135,7 +199,7 @@ GEM |
135 | actionpack (>= 4.0) | 199 | actionpack (>= 4.0) |
136 | activesupport (>= 4.0) | 200 | activesupport (>= 4.0) |
137 | sprockets (>= 3.0.0) | 201 | sprockets (>= 3.0.0) |
138 | - sqlite3 (1.3.13) | 202 | + temple (0.8.0) |
139 | thor (0.20.0) | 203 | thor (0.20.0) |
140 | thread_safe (0.3.6) | 204 | thread_safe (0.3.6) |
141 | tilt (2.0.8) | 205 | tilt (2.0.8) |
... | @@ -161,15 +225,19 @@ PLATFORMS | ... | @@ -161,15 +225,19 @@ PLATFORMS |
161 | DEPENDENCIES | 225 | DEPENDENCIES |
162 | byebug | 226 | byebug |
163 | coffee-rails (~> 4.2) | 227 | coffee-rails (~> 4.2) |
228 | + crud_controller! | ||
229 | + heimdall_engine! | ||
164 | jbuilder (~> 2.5) | 230 | jbuilder (~> 2.5) |
165 | jquery-rails | 231 | jquery-rails |
166 | listen (~> 3.0.5) | 232 | listen (~> 3.0.5) |
233 | + paper_trail | ||
234 | + paranoia | ||
235 | + pg | ||
167 | puma (~> 3.0) | 236 | puma (~> 3.0) |
168 | rails (~> 5.0.6) | 237 | rails (~> 5.0.6) |
169 | sass-rails (~> 5.0) | 238 | sass-rails (~> 5.0) |
170 | spring | 239 | spring |
171 | spring-watcher-listen (~> 2.0.0) | 240 | spring-watcher-listen (~> 2.0.0) |
172 | - sqlite3 | ||
173 | turbolinks (~> 5) | 241 | turbolinks (~> 5) |
174 | tzinfo-data | 242 | tzinfo-data |
175 | uglifier (>= 1.3.0) | 243 | uglifier (>= 1.3.0) | ... | ... |
app/models/role.rb
0 → 100644
1 | +# frozen_string_literal: true | ||
2 | + | ||
3 | +# == Schema Information | ||
4 | +# | ||
5 | +# Table name: heimdall_engine_roles | ||
6 | +# | ||
7 | +# id :integer not null, primary key | ||
8 | +# name :string | ||
9 | +# created_at :datetime | ||
10 | +# updated_at :datetime | ||
11 | +# deleted_at :datetime | ||
12 | +# erasable :boolean | ||
13 | +# | ||
14 | +class Role < HeimdallEngine::Role | ||
15 | + acts_as_paranoid | ||
16 | + has_paper_trail | ||
17 | +end |
app/models/user.rb
0 → 100644
1 | +# frozen_string_literal: true | ||
2 | + | ||
3 | +# == Schema Information | ||
4 | +# | ||
5 | +# Table name: users | ||
6 | +# | ||
7 | +# id :integer not null, primary key | ||
8 | +# created_at :datetime not null | ||
9 | +# updated_at :datetime not null | ||
10 | +# deleted_at :datetime | ||
11 | +# name :string | ||
12 | +# mail :string | ||
13 | +# password_hash :string | ||
14 | +# password_salt :string | ||
15 | +# | ||
16 | +class User < ApplicationRecord | ||
17 | + acts_as_paranoid | ||
18 | + has_paper_trail | ||
19 | + acts_as_heimdall | ||
20 | + | ||
21 | + attr_accessor :current_password | ||
22 | + | ||
23 | + validates :name, :mail, presence: true | ||
24 | + validates :password, presence: true, on: :create | ||
25 | + validates :password, confirmation: true | ||
26 | + | ||
27 | + before_save :encrypt_password | ||
28 | + | ||
29 | + has_and_belongs_to_many :roles, inverse_of: :users, | ||
30 | + class_name: 'HeimdallEngine::Role', | ||
31 | + join_table: 'users_roles', | ||
32 | + foreign_key: "user_id", | ||
33 | + association_foreign_key: "role_id" | ||
34 | + | ||
35 | + | ||
36 | + def encrypt_password | ||
37 | + return unless password.present? | ||
38 | + self.password_salt = BCrypt::Engine.generate_salt.force_encoding('UTF-8') | ||
39 | + self.password_hash = BCrypt::Engine.hash_secret(password, password_salt) | ||
40 | + .force_encoding('UTF-8') | ||
41 | + end | ||
42 | +end |
... | @@ -5,21 +5,21 @@ | ... | @@ -5,21 +5,21 @@ |
5 | # gem 'sqlite3' | 5 | # gem 'sqlite3' |
6 | # | 6 | # |
7 | default: &default | 7 | default: &default |
8 | - adapter: sqlite3 | 8 | + adapter: postgresql |
9 | pool: 5 | 9 | pool: 5 |
10 | timeout: 5000 | 10 | timeout: 5000 |
11 | 11 | ||
12 | development: | 12 | development: |
13 | <<: *default | 13 | <<: *default |
14 | - database: db/development.sqlite3 | 14 | + database: quiniela_development |
15 | 15 | ||
16 | # Warning: The database defined as "test" will be erased and | 16 | # Warning: The database defined as "test" will be erased and |
17 | # re-generated from your development database when you run "rake". | 17 | # re-generated from your development database when you run "rake". |
18 | # Do not set this db to the same as development or production. | 18 | # Do not set this db to the same as development or production. |
19 | test: | 19 | test: |
20 | <<: *default | 20 | <<: *default |
21 | - database: db/test.sqlite3 | 21 | + database: quiniela_test |
22 | 22 | ||
23 | production: | 23 | production: |
24 | <<: *default | 24 | <<: *default |
25 | - database: db/production.sqlite3 | 25 | + database: quiniela_production | ... | ... |
1 | Rails.application.routes.draw do | 1 | Rails.application.routes.draw do |
2 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | 2 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html |
3 | + HeimdallEngine.load_routes | ||
4 | + root 'application#root' | ||
3 | end | 5 | end | ... | ... |
1 | +# This migration comes from heimdall_engine (originally 20150410182436) | ||
2 | +class CreateHeimdallEngineRoles < ActiveRecord::Migration[5.0] | ||
3 | + def change | ||
4 | + create_table :heimdall_engine_roles do |t| | ||
5 | + t.string :name | ||
6 | + t.boolean :erasable, default: false | ||
7 | + t.timestamps | ||
8 | + t.datetime :deleted_at | ||
9 | + end | ||
10 | + | ||
11 | + add_index :heimdall_engine_roles, :deleted_at | ||
12 | + end | ||
13 | +end |
1 | +# This migration comes from heimdall_engine (originally 20150413145047) | ||
2 | +class CreateHeimdallEngineRoleAbilities < ActiveRecord::Migration[5.0] | ||
3 | + def change | ||
4 | + create_table :heimdall_engine_role_abilities do |t| | ||
5 | + t.integer :role_id | ||
6 | + t.string :key | ||
7 | + | ||
8 | + t.timestamps null: false | ||
9 | + end | ||
10 | + | ||
11 | + add_index :heimdall_engine_role_abilities, :key | ||
12 | + add_index :heimdall_engine_role_abilities, :role_id | ||
13 | + end | ||
14 | +end |
1 | +# This migration comes from heimdall_engine (originally 20150807194858) | ||
2 | +class CreateHeimdallResponsabilities < ActiveRecord::Migration[5.0] | ||
3 | + def change | ||
4 | + create_table :users_roles do |t| | ||
5 | + t.integer HeimdallEngine.session_user_id | ||
6 | + t.integer :role_id | ||
7 | + end | ||
8 | + | ||
9 | + add_index :users_roles, HeimdallEngine.session_user_id | ||
10 | + add_index :users_roles, :role_id | ||
11 | + end | ||
12 | +end |
db/schema.rb
0 → 100644
1 | +# This file is auto-generated from the current state of the database. Instead | ||
2 | +# of editing this file, please use the migrations feature of Active Record to | ||
3 | +# incrementally modify your database, and then regenerate this schema definition. | ||
4 | +# | ||
5 | +# Note that this schema.rb definition is the authoritative source for your | ||
6 | +# database schema. If you need to create the application database on another | ||
7 | +# system, you should be using db:schema:load, not running all the migrations | ||
8 | +# from scratch. The latter is a flawed and unsustainable approach (the more migrations | ||
9 | +# you'll amass, the slower it'll run and the greater likelihood for issues). | ||
10 | +# | ||
11 | +# It's strongly recommended that you check this file into your version control system. | ||
12 | + | ||
13 | +ActiveRecord::Schema.define(version: 20180608220338) do | ||
14 | + | ||
15 | + # These are extensions that must be enabled in order to support this database | ||
16 | + enable_extension "plpgsql" | ||
17 | + | ||
18 | + create_table "heimdall_engine_role_abilities", force: :cascade do |t| | ||
19 | + t.integer "role_id" | ||
20 | + t.string "key" | ||
21 | + t.datetime "created_at", null: false | ||
22 | + t.datetime "updated_at", null: false | ||
23 | + t.index ["key"], name: "index_heimdall_engine_role_abilities_on_key", using: :btree | ||
24 | + t.index ["role_id"], name: "index_heimdall_engine_role_abilities_on_role_id", using: :btree | ||
25 | + end | ||
26 | + | ||
27 | + create_table "heimdall_engine_roles", force: :cascade do |t| | ||
28 | + t.string "name" | ||
29 | + t.boolean "erasable", default: false | ||
30 | + t.datetime "created_at", null: false | ||
31 | + t.datetime "updated_at", null: false | ||
32 | + t.datetime "deleted_at" | ||
33 | + t.index ["deleted_at"], name: "index_heimdall_engine_roles_on_deleted_at", using: :btree | ||
34 | + end | ||
35 | + | ||
36 | + create_table "users_roles", force: :cascade do |t| | ||
37 | + t.integer "user_id" | ||
38 | + t.integer "role_id" | ||
39 | + t.index ["role_id"], name: "index_users_roles_on_role_id", using: :btree | ||
40 | + t.index ["user_id"], name: "index_users_roles_on_user_id", using: :btree | ||
41 | + end | ||
42 | + | ||
43 | +end |
-
Please register or login to post a comment