Added authentication_zero
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
class CreateUsers < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :users do |t|
|
||||
t.string :firstname
|
||||
t.string :lastname
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_foreign_key :jobs, :users, column: :operator_id
|
||||
add_foreign_key :jobs, :users, column: :costumer_id
|
||||
end
|
||||
end
|
||||
18
db/migrate/20240826144015_create_users.rb
Normal file
18
db/migrate/20240826144015_create_users.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class CreateUsers < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
create_table :users do |t|
|
||||
t.string :email, null: false, index: { unique: true }
|
||||
t.string :password_digest, null: false
|
||||
t.string :firstname
|
||||
t.string :lastname
|
||||
|
||||
t.integer :role, default: 0, index: true
|
||||
|
||||
t.boolean :verified, null: false, default: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_foreign_key :jobs, :users, column: :operator_id
|
||||
add_foreign_key :jobs, :users, column: :costumer_id
|
||||
end
|
||||
end
|
||||
11
db/migrate/20240826144016_create_sessions.rb
Normal file
11
db/migrate/20240826144016_create_sessions.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateSessions < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
create_table :sessions do |t|
|
||||
t.references :user, null: false, foreign_key: true
|
||||
t.string :user_agent
|
||||
t.string :ip_address
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
24
db/schema.rb
generated
24
db/schema.rb
generated
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.2].define(version: 2024_08_01_153403) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2024_08_26_144016) do
|
||||
create_table "active_storage_attachments", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.string "record_type", null: false
|
||||
@@ -69,15 +69,31 @@ ActiveRecord::Schema[7.2].define(version: 2024_08_01_153403) do
|
||||
t.index ["status"], name: "index_jobs_on_status"
|
||||
end
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "firstname"
|
||||
t.string "lastname"
|
||||
create_table "sessions", force: :cascade do |t|
|
||||
t.integer "user_id", null: false
|
||||
t.string "user_agent"
|
||||
t.string "ip_address"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["user_id"], name: "index_sessions_on_user_id"
|
||||
end
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "email", null: false
|
||||
t.string "password_digest", null: false
|
||||
t.string "firstname"
|
||||
t.string "lastname"
|
||||
t.integer "role", default: 0
|
||||
t.boolean "verified", default: false, null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["email"], name: "index_users_on_email", unique: true
|
||||
t.index ["role"], name: "index_users_on_role"
|
||||
end
|
||||
|
||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "jobs", "users", column: "costumer_id"
|
||||
add_foreign_key "jobs", "users", column: "operator_id"
|
||||
add_foreign_key "sessions", "users"
|
||||
end
|
||||
|
||||
24
db/seeds.rb
24
db/seeds.rb
@@ -10,28 +10,28 @@
|
||||
|
||||
Faker::Config.locale = :de
|
||||
|
||||
10.times do
|
||||
User.new(firstname: Faker::Name.unique.first_name, lastname: Faker::Name.unique.last_name).save
|
||||
# Admin
|
||||
User.create!(email: "david.boehm@hs-rm.de", firstname: "David", lastname: "Böhm", role: :admin, password_digest: BCrypt::Password.create("admin"), verified: true)
|
||||
|
||||
# Students
|
||||
students = []
|
||||
5.times do
|
||||
firstname = Faker::Name.unique.first_name
|
||||
lastname = Faker::Name.unique.last_name
|
||||
students << User.new(email: firstname + "." + lastname + "@student.hs-rm.de", firstname: firstname, lastname: lastname, password_digest: BCrypt::Password.create("password"), verified: true)
|
||||
students.last.save!
|
||||
end
|
||||
|
||||
[ 'GanzWichtig.pdf', 'IchBinIn5MinDran.pdf', 'DerPlanDerImmerProblemeMacht.pdf',
|
||||
'DieFarbenGefallenMirNicht.pdf', 'MachHinIchHabsEilig.pdf', 'WarumDauertDasSoLange.pdf',
|
||||
'DenPlanBezahleIchNicht.pdf', 'IchWarAlsErstesDran.pdf', 'WarumIstDerPlotterDefekt.pdf',
|
||||
'DasNächsteMalGeheIchWoAndersHin.pdf' ].shuffle.each do |pdf|
|
||||
# a0 = rand(0...7)
|
||||
# a1 = rand(0...7)
|
||||
# a2 = rand(0...7)
|
||||
# a3 = rand(0...7)
|
||||
# a0.zero? || a1 = 0 && a2 = 0 && a3 = 0
|
||||
# a1.zero? || a2 = 0 && a3 = 0
|
||||
# a2.zero? || a3 = 0
|
||||
status = %i[open open open open open
|
||||
printing pickup paid canceled].sample
|
||||
status = %i[open open open open open printing pickup paid canceled].sample
|
||||
|
||||
job = Job.new(costumer_firstname: Faker::Name.unique.first_name, costumer_lastname: Faker::Name.unique.last_name,
|
||||
costumer_id: students[rand(0...4)].id,
|
||||
# number_of_plans_a0: a0, number_of_plans_a1: a1, number_of_plans_a2: a2, number_of_plans_a3: a3,
|
||||
status:, privacy_policy_accepted: true)
|
||||
job.pdf = File.open(Rails.root.join('db/pdfs/', pdf))
|
||||
job.save!
|
||||
# sleep 1 # for testing broadcasting
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user