changed enum to string in user and job model

This commit is contained in:
2024-09-07 23:24:07 +02:00
parent fc26bdc3ac
commit ba4331c252
6 changed files with 14 additions and 13 deletions

View File

@@ -27,11 +27,11 @@ class Job < ApplicationRecord
# NOTE: Multiple status if paing before brinting? # NOTE: Multiple status if paing before brinting?
enum :status, { enum :status, {
open: 0, open: "open",
printing: 1, printing: "printing",
pickup: 2, pickup: "pickup",
paid: 3, paid: "paid",
canceled: 4 canceled: "canceled"
} }
AVAILABLE_PAGE_FORMATS = [ :a0, :a1, :a2, :a3 ] AVAILABLE_PAGE_FORMATS = [ :a0, :a1, :a2, :a3 ]

View File

@@ -22,9 +22,9 @@ class User < ApplicationRecord
normalizes :email, with: -> { _1.strip.downcase } normalizes :email, with: -> { _1.strip.downcase }
enum :role, { enum :role, {
user: 0, user: "user",
operator: 1, operator: "operator",
admin: 2 admin: "admin"
} }
before_validation if: :email_changed?, on: :update do before_validation if: :email_changed?, on: :update do

View File

@@ -14,7 +14,7 @@ class CreateJobs < ActiveRecord::Migration[7.1]
t.datetime :paid_at t.datetime :paid_at
t.boolean :intern, default: false t.boolean :intern, default: false
t.string :cost_center t.string :cost_center
t.integer :status, default: 0, index: true t.string :status, default: 0, index: true
t.integer :number_of_plans_a0, default: 0 t.integer :number_of_plans_a0, default: 0
t.integer :number_of_plans_a1, default: 0 t.integer :number_of_plans_a1, default: 0
t.integer :number_of_plans_a2, default: 0 t.integer :number_of_plans_a2, default: 0

View File

@@ -6,7 +6,7 @@ class CreateUsers < ActiveRecord::Migration[7.2]
t.string :firstname t.string :firstname
t.string :lastname t.string :lastname
t.integer :role, default: 0, index: true t.string :role, default: 0, index: true
t.boolean :verified, null: false, default: false t.boolean :verified, null: false, default: false

4
db/schema.rb generated
View File

@@ -53,7 +53,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_08_26_144016) do
t.datetime "paid_at" t.datetime "paid_at"
t.boolean "intern", default: false t.boolean "intern", default: false
t.string "cost_center" t.string "cost_center"
t.integer "status", default: 0 t.string "status", default: "0"
t.integer "number_of_plans_a0", default: 0 t.integer "number_of_plans_a0", default: 0
t.integer "number_of_plans_a1", default: 0 t.integer "number_of_plans_a1", default: 0
t.integer "number_of_plans_a2", default: 0 t.integer "number_of_plans_a2", default: 0
@@ -83,7 +83,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_08_26_144016) do
t.string "password_digest", null: false t.string "password_digest", null: false
t.string "firstname" t.string "firstname"
t.string "lastname" t.string "lastname"
t.integer "role", default: 0 t.string "role", default: "0"
t.boolean "verified", default: false, null: false t.boolean "verified", default: false, null: false
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false

View File

@@ -23,12 +23,13 @@ students = []
5.times do 5.times do
firstname = Faker::Name.unique.first_name.delete(" ") firstname = Faker::Name.unique.first_name.delete(" ")
lastname = Faker::Name.unique.last_name.delete(" ") lastname = Faker::Name.unique.last_name.delete(" ")
email=firstname + "." + lastname + "@student.hs-rm.de" email="#{firstname}.#{lastname}@student.hs-rm.de"
email.delete(" ") email.delete(" ")
students << User.new(email: email, firstname: firstname, lastname: lastname, password_digest: BCrypt::Password.create("password"), verified: true) students << User.new(email: email, firstname: firstname, lastname: lastname, password_digest: BCrypt::Password.create("password"), verified: true)
students.last.save! students.last.save!
end end
# Jobs
[ 'GanzWichtig.pdf', 'IchBinIn5MinDran.pdf', 'DerPlanDerImmerProblemeMacht.pdf', [ 'GanzWichtig.pdf', 'IchBinIn5MinDran.pdf', 'DerPlanDerImmerProblemeMacht.pdf',
'DieFarbenGefallenMirNicht.pdf', 'MachHinIchHabsEilig.pdf', 'WarumDauertDasSoLange.pdf', 'DieFarbenGefallenMirNicht.pdf', 'MachHinIchHabsEilig.pdf', 'WarumDauertDasSoLange.pdf',
'DenPlanBezahleIchNicht.pdf', 'IchWarAlsErstesDran.pdf', 'WarumIstDerPlotterDefekt.pdf', 'DenPlanBezahleIchNicht.pdf', 'IchWarAlsErstesDran.pdf', 'WarumIstDerPlotterDefekt.pdf',