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?
enum :status, {
open: 0,
printing: 1,
pickup: 2,
paid: 3,
canceled: 4
open: "open",
printing: "printing",
pickup: "pickup",
paid: "paid",
canceled: "canceled"
}
AVAILABLE_PAGE_FORMATS = [ :a0, :a1, :a2, :a3 ]

View File

@@ -22,9 +22,9 @@ class User < ApplicationRecord
normalizes :email, with: -> { _1.strip.downcase }
enum :role, {
user: 0,
operator: 1,
admin: 2
user: "user",
operator: "operator",
admin: "admin"
}
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.boolean :intern, default: false
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_a1, 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 :lastname
t.integer :role, default: 0, index: true
t.string :role, default: 0, index: true
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.boolean "intern", default: false
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_a1", 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 "firstname"
t.string "lastname"
t.integer "role", default: 0
t.string "role", default: "0"
t.boolean "verified", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false

View File

@@ -23,12 +23,13 @@ students = []
5.times do
firstname = Faker::Name.unique.first_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(" ")
students << User.new(email: email, firstname: firstname, lastname: lastname, password_digest: BCrypt::Password.create("password"), verified: true)
students.last.save!
end
# Jobs
[ 'GanzWichtig.pdf', 'IchBinIn5MinDran.pdf', 'DerPlanDerImmerProblemeMacht.pdf',
'DieFarbenGefallenMirNicht.pdf', 'MachHinIchHabsEilig.pdf', 'WarumDauertDasSoLange.pdf',
'DenPlanBezahleIchNicht.pdf', 'IchWarAlsErstesDran.pdf', 'WarumIstDerPlotterDefekt.pdf',