Fixed typo

This commit is contained in:
2024-10-02 13:51:15 +02:00
parent 23749c80b8
commit 337ff9b9d9
24 changed files with 79 additions and 79 deletions

View File

@@ -11,13 +11,13 @@ class JobsController < ApplicationController
# GET /jobs/new # GET /jobs/new
def new def new
@job = Job.new(costumer_firstname: current_user.firstname, costumer_lastname: current_user.lastname) @job = Job.new(customer_firstname: current_user.firstname, customer_lastname: current_user.lastname)
end end
# POST /jobs or /jobs.json # POST /jobs or /jobs.json
def create def create
@job = Job.new(job_params) @job = Job.new(job_params)
@job.costumer = current_user @job.customer = current_user
respond_to do |format| respond_to do |format|
if @job.save if @job.save
@@ -95,6 +95,6 @@ class JobsController < ApplicationController
# Only allow a list of trusted parameters through. # Only allow a list of trusted parameters through.
def job_params def job_params
params.require(:job).permit(:costumer_id, :costumer_firstname, :costumer_lastname, :privacy_policy, :pdf) params.require(:job).permit(:customer_id, :customer_firstname, :customer_lastname, :privacy_policy, :pdf)
end end
end end

View File

@@ -114,7 +114,7 @@ class Operator::JobsController < ApplicationController
# Only allow a list of trusted parameters through. # Only allow a list of trusted parameters through.
def job_params def job_params
params.require(:job).permit(:pdf, :operator_id, :costumer_id, :operator_firstname, :operator_lastname, :costumer_firstname, :costumer_lastname, :status, :privacy_policy, :intern, :cost_center, :number_of_plans_a0, :number_of_plans_a1, :number_of_plans_a2, :number_of_plans_a3, :costum_qm_plan) params.require(:job).permit(:pdf, :operator_id, :customer_id, :operator_firstname, :operator_lastname, :customer_firstname, :customer_lastname, :status, :privacy_policy, :intern, :cost_center, :number_of_plans_a0, :number_of_plans_a1, :number_of_plans_a2, :number_of_plans_a3, :costum_qm_plan)
end end
# FIXME: Move broadcast to model though i don't think view logic belongs in the model # FIXME: Move broadcast to model though i don't think view logic belongs in the model

View File

@@ -1,14 +1,14 @@
class Job < ApplicationRecord class Job < ApplicationRecord
attr_accessor :current_user attr_accessor :current_user
belongs_to :costumer, class_name: "User", optional: true, counter_cache: :costumer_jobs_count, inverse_of: :costumer_jobs belongs_to :customer, class_name: "User", optional: true, counter_cache: :customer_jobs_count, inverse_of: :customer_jobs
belongs_to :operator, class_name: "User", optional: true, counter_cache: :operator_jobs_count, inverse_of: :operator_jobs belongs_to :operator, class_name: "User", optional: true, counter_cache: :operator_jobs_count, inverse_of: :operator_jobs
belongs_to :creator, class_name: "User", optional: true, counter_cache: :created_jobs_count, inverse_of: :created_jobs belongs_to :creator, class_name: "User", optional: true, counter_cache: :created_jobs_count, inverse_of: :created_jobs
belongs_to :cashier, class_name: "User", optional: true, counter_cache: :cashed_jobs_count, inverse_of: :cashed_jobs belongs_to :cashier, class_name: "User", optional: true, counter_cache: :cashed_jobs_count, inverse_of: :cashed_jobs
has_one_attached :pdf, dependent: :purge has_one_attached :pdf, dependent: :purge
validates_presence_of :costumer_firstname, :costumer_lastname, :pdf validates_presence_of :customer_firstname, :customer_lastname, :pdf
validates_presence_of :cost_center, if: :intern validates_presence_of :cost_center, if: :intern
validates :privacy_policy, acceptance: true, unless: :created_by_operator? validates :privacy_policy, acceptance: true, unless: :created_by_operator?
validates :number_of_plans_a0, :number_of_plans_a1, :number_of_plans_a2, :number_of_plans_a3, :costum_qm_plan, numericality: { greater_than_or_equal_to: 0 } validates :number_of_plans_a0, :number_of_plans_a1, :number_of_plans_a2, :number_of_plans_a3, :costum_qm_plan, numericality: { greater_than_or_equal_to: 0 }
@@ -21,7 +21,7 @@ class Job < ApplicationRecord
before_save :set_cost_qm before_save :set_cost_qm
before_save :calc_cost, if: :printed_pages_changes? before_save :calc_cost, if: :printed_pages_changes?
before_validation :set_costumer_infos, unless: :created_by_operator?, on: :create before_validation :set_customer_infos, unless: :created_by_operator?, on: :create
# TODO: works only when job is created. Should move analyzer to activestorage : # TODO: works only when job is created. Should move analyzer to activestorage :
# https://discuss.rubyonrails.org/t/active-storage-in-production-lessons-learned-and-in-depth-look-at-how-it-works/83289 # https://discuss.rubyonrails.org/t/active-storage-in-production-lessons-learned-and-in-depth-look-at-how-it-works/83289
@@ -42,7 +42,7 @@ class Job < ApplicationRecord
AVAILABLE_PAGE_FORMATS = [ :a0, :a1, :a2, :a3 ] AVAILABLE_PAGE_FORMATS = [ :a0, :a1, :a2, :a3 ]
# scope :created_as_operator, -> { where created_as_operator: true } # scope :created_as_operator, -> { where created_as_operator: true }
# scope :created_as_costumer, -> { where created_as_operator: false } # scope :created_as_customer, -> { where created_as_operator: false }
scope :not_canceled, -> { !canceled } scope :not_canceled, -> { !canceled }
# NOTE: only named status are returned because of WHERE/IN clause for the enum values # NOTE: only named status are returned because of WHERE/IN clause for the enum values
@@ -60,7 +60,7 @@ class Job < ApplicationRecord
scope :status_changed_on_day, lambda { |date| scope :status_changed_on_day, lambda { |date|
where("status_changed_at >= ? AND status_changed_at <= ?", date.beginning_of_day, date.end_of_day) where("status_changed_at >= ? AND status_changed_at <= ?", date.beginning_of_day, date.end_of_day)
} }
scope :created_by_costumer, -> { not(:created_by_operator) } scope :created_by_customer, -> { not(:created_by_operator) }
# Returns all jobs with status: open print pickup and jobs from today with status: paid canceled # Returns all jobs with status: open print pickup and jobs from today with status: paid canceled
# paid: only updated_at today # paid: only updated_at today
@@ -72,7 +72,7 @@ class Job < ApplicationRecord
.where("status_changed_at >= ?", Time.now.beginning_of_day)) .where("status_changed_at >= ?", Time.now.beginning_of_day))
# .in_status_order # .in_status_order
.order(created_at: :asc) .order(created_at: :asc)
# .order(:costumer_firstname, :costumer_lastname) # .order(:customer_firstname, :customer_lastname)
.with_attached_pdf # scope from activestorage for .includes(pdf_attachment: :blob) .with_attached_pdf # scope from activestorage for .includes(pdf_attachment: :blob)
# .references(:pdf_attachment, :blob) # creates big join table # .references(:pdf_attachment, :blob) # creates big join table
end end
@@ -81,8 +81,8 @@ class Job < ApplicationRecord
Job.where(status: %i[paid canceled]) Job.where(status: %i[paid canceled])
end end
def costumer_fullname def customer_fullname
[ costumer_firstname, " ", costumer_lastname ].join [ customer_firstname, " ", customer_lastname ].join
end end
def acceptable_pdf def acceptable_pdf
@@ -127,13 +127,13 @@ class Job < ApplicationRecord
csv << columns_readable csv << columns_readable
jobs.each do |job| jobs.each do |job|
# csv << job.attributes.values_at(*columns) # csv << job.attributes.values_at(*columns)
csv << [ job.id, job.costumer_firstname, job.costumer_lastname, job.cashier_firstname, job.cashier_lastname, job.paid_at.localtime.strftime("%Y-%m-%d"), job.cost.to_s + "" ] csv << [ job.id, job.customer_firstname, job.customer_lastname, job.cashier_firstname, job.cashier_lastname, job.paid_at.localtime.strftime("%Y-%m-%d"), job.cost.to_s + "" ]
end end
end end
end end
def self.ransackable_attributes(auth_object = nil) def self.ransackable_attributes(auth_object = nil)
[ "created_at", "id", "costumer_firstname", "costumer_lastname", "pdf.", "created_by_operator", "number_of_plans_a0", "number_of_plans_a1", "number_of_plans_a2", "number_of_plans_a3", "costum_qm_plan", "cost", "status" ] [ "created_at", "id", "customer_firstname", "customer_lastname", "pdf.", "created_by_operator", "number_of_plans_a0", "number_of_plans_a1", "number_of_plans_a2", "number_of_plans_a3", "costum_qm_plan", "cost", "status" ]
end end
def self.ransackable_associations(auth_object = nil) def self.ransackable_associations(auth_object = nil)
@@ -187,10 +187,10 @@ class Job < ApplicationRecord
save save
end end
def set_costumer_infos def set_customer_infos
self.costumer = current_user unless self.costumer self.customer = current_user unless self.customer
self.costumer_firstname = costumer.firstname self.customer_firstname = customer.firstname
self.costumer_lastname = costumer.lastname self.customer_lastname = customer.lastname
end end
def set_operator_infos def set_operator_infos

View File

@@ -1,7 +1,7 @@
class User < ApplicationRecord class User < ApplicationRecord
has_secure_password has_secure_password
# has_many :jobs # has_many :jobs
has_many :costumer_jobs, foreign_key: :costumer_id, class_name: "Job" has_many :customer_jobs, foreign_key: :customer_id, class_name: "Job"
has_many :operator_jobs, foreign_key: :operator_id, class_name: "Job" has_many :operator_jobs, foreign_key: :operator_id, class_name: "Job"
has_many :created_jobs, foreign_key: :creator_id, class_name: "Job" has_many :created_jobs, foreign_key: :creator_id, class_name: "Job"
has_many :cashed_jobs, foreign_key: :cashier_id, class_name: "Job" has_many :cashed_jobs, foreign_key: :cashier_id, class_name: "Job"
@@ -45,7 +45,7 @@ class User < ApplicationRecord
end end
def self.ransackable_attributes(auth_object = nil) def self.ransackable_attributes(auth_object = nil)
[ "created_at", "email", "firstname", "id", "costumer_jobs_count", "operator_jobs_count", "lastname", "role", "verified", "name" ] [ "created_at", "email", "firstname", "id", "customer_jobs_count", "operator_jobs_count", "lastname", "role", "verified", "name" ]
end end
def self.ransackable_associations(auth_object = nil) def self.ransackable_associations(auth_object = nil)

View File

@@ -2,7 +2,7 @@ class JobPolicy < ApplicationPolicy
skip_pre_check :allow_admins, only: :cancel? skip_pre_check :allow_admins, only: :cancel?
def cancel? def cancel?
record.open? && (user == record.costumer || user.operator? || user.admin?) record.open? && (user == record.customer || user.operator? || user.admin?)
end end
# See https://actionpolicy.evilmartians.io/#/writing_policies # See https://actionpolicy.evilmartians.io/#/writing_policies

View File

@@ -7,10 +7,10 @@
<% end %> <% end %>
</td> </td>
<td class="p-2 py-3"> <td class="p-2 py-3">
<%= link_to job.costumer_firstname, admin_user_path(job.costumer), target: "_top" %> <%= link_to_if job.customer_firstname, admin_user_path(job.customer), target: "_top" %>
</td> </td>
<td class="p-2 py-3"> <td class="p-2 py-3">
<%= link_to job.costumer_lastname, admin_user_path(job.costumer), target: "_top" %> <%= link_to_if job.customer_lastname, admin_user_path(job.customer), target: "_top" %>
</td> </td>
<td class="p-2 py-3"> <td class="p-2 py-3">
<% if job.pdf.attached? %> <% if job.pdf.attached? %>

View File

@@ -12,7 +12,7 @@
<%= link_to icon("calendar", class: "icon size-5 mr-3") + 'Kalender', admin_jobs_path(calendar: true), class: "px-4 py-2 hover:bg-gray-100 hover:text-hsrm-red border-b-4 hover:border-hsrm-red-light" %> <%= link_to icon("calendar", class: "icon size-5 mr-3") + 'Kalender', admin_jobs_path(calendar: true), class: "px-4 py-2 hover:bg-gray-100 hover:text-hsrm-red border-b-4 hover:border-hsrm-red-light" %>
<div class="flex items-center justify-between py-4"> <div class="flex items-center justify-between py-4">
<%= search_form_for @q, data: { turbo_frame: :admin_jobs, turbo_action: 'advance' }, url: admin_jobs_path() do |f| %> <%= search_form_for @q, data: { turbo_frame: :admin_jobs, turbo_action: 'advance' }, url: admin_jobs_path() do |f| %>
<%= f.search_field :costumer_firstname_or_costumer_lastname_or_pdf_blob_filename_cont, placeholder: "Suchen", oninput: 'this.form.requestSubmit();' %> <%= f.search_field :customer_firstname_or_customer_lastname_or_pdf_blob_filename_cont, placeholder: "Suchen", oninput: 'this.form.requestSubmit();' %>
<%= f.label :status_eq, "Status:" %> <%= f.label :status_eq, "Status:" %>
<%= f.select :status_eq, Job.statuses.keys, {include_blank: "alle"}, onchange: 'this.form.requestSubmit();' %> <%= f.select :status_eq, Job.statuses.keys, {include_blank: "alle"}, onchange: 'this.form.requestSubmit();' %>
<%= f.label :created_by_operator_eq, "Erstellt vom:" %> <%= f.label :created_by_operator_eq, "Erstellt vom:" %>
@@ -32,8 +32,8 @@
<thead class="font-semibold tracking-wide bg-gray-200 border-b-2 border-gray-300 text text-hsrm-gray"> <thead class="font-semibold tracking-wide bg-gray-200 border-b-2 border-gray-300 text text-hsrm-gray">
<tr> <tr>
<th class="w-1 p-2 py-3 text-center text-nowrap"><%= sort_link(@q, :id, "ID", ) %></th> <th class="w-1 p-2 py-3 text-center text-nowrap"><%= sort_link(@q, :id, "ID", ) %></th>
<th class="min-w-24 p-2 py-3 text-left"><%= sort_link(@q, :costumer_firstname, "Vorname") %></th> <th class="min-w-24 p-2 py-3 text-left"><%= sort_link(@q, :customer_firstname, "Vorname") %></th>
<th class="min-w-24 p-2 py-3 text-left"><%= sort_link(@q, :costumer_lastname, "Nachname") %></th> <th class="min-w-24 p-2 py-3 text-left"><%= sort_link(@q, :customer_lastname, "Nachname") %></th>
<th class="p-2 py-3 text-left"><%= sort_link(@q, :pdf_blob_filename, "PDF") %></th> <th class="p-2 py-3 text-left"><%= sort_link(@q, :pdf_blob_filename, "PDF") %></th>
<th class="w-1 p-1 py-3 text-left text-nowrap"><%= sort_link(@q, :number_of_plans_a0, "A0") %></th> <th class="w-1 p-1 py-3 text-left text-nowrap"><%= sort_link(@q, :number_of_plans_a0, "A0") %></th>
<th class="w-1 p-1 py-3 text-left text-nowrap"><%= sort_link(@q, :number_of_plans_a1, "A1") %></th> <th class="w-1 p-1 py-3 text-left text-nowrap"><%= sort_link(@q, :number_of_plans_a1, "A1") %></th>

View File

@@ -8,8 +8,8 @@
<p>E-Mail Verifiziert: <p>E-Mail Verifiziert:
<%= icon bool_icon(user.verified), class: "icon #{user.verified ? "text-green-600" : "text-red-600"}" %></p> <%= icon bool_icon(user.verified), class: "icon #{user.verified ? "text-green-600" : "text-red-600"}" %></p>
<p><%= user.created_at %></p> <p><%= user.created_at %></p>
<p>Druckaufträge als Kunde: <%= @user.costumer_jobs.size %></p> <p>Druckaufträge als Kunde: <%= @user.customer_jobs.size %></p>
<p>davon abgebrochen: <%= @user.costumer_jobs.canceled.size %></p> <p>davon abgebrochen: <%= @user.customer_jobs.canceled.size %></p>
<p>Druckaufträge als Operator: <%= @user.operator_jobs.size %></p> <p>Druckaufträge als Operator: <%= @user.operator_jobs.size %></p>
<p>Druckaufträge kassiert: <%= @user.cashed_jobs.size %></p> <p>Druckaufträge kassiert: <%= @user.cashed_jobs.size %></p>
</div> </div>

View File

@@ -74,7 +74,7 @@
<th class="min-w-24 p-2 py-3 text-left"><%= sort_link(@q, :firstname, "Vorname") %></th> <th class="min-w-24 p-2 py-3 text-left"><%= sort_link(@q, :firstname, "Vorname") %></th>
<th class="min-w-24 p-2 py-3 text-left"><%= sort_link(@q, :lastname, "Nachname") %></th> <th class="min-w-24 p-2 py-3 text-left"><%= sort_link(@q, :lastname, "Nachname") %></th>
<th class="p-2 py-3 text-left"><%= sort_link(@q, :email, "E-Mail-Adresse") %></th> <th class="p-2 py-3 text-left"><%= sort_link(@q, :email, "E-Mail-Adresse") %></th>
<th class="w-1 p-2 py-3 text-right text-nowrap"><%= sort_link(@q, :costumer_jobs_count, "# Jobs") %></th> <th class="w-1 p-2 py-3 text-right text-nowrap"><%= sort_link(@q, :customer_jobs_count, "# Jobs") %></th>
<th class="w-1 p-2 py-3 text-center text-nowrap"><%= sort_link(@q, :created_at, "Registriert am") %></th> <th class="w-1 p-2 py-3 text-center text-nowrap"><%= sort_link(@q, :created_at, "Registriert am") %></th>
<th class="w-1 p-2 py-3 text-center"><%= sort_link(@q, :role, "Rolle") %></th> <th class="w-1 p-2 py-3 text-center"><%= sort_link(@q, :role, "Rolle") %></th>
</tr> </tr>

View File

@@ -21,7 +21,7 @@
</tr> </tr>
</thead> </thead>
<tbody id='jobs' class="divide-y divivde-gray-300"> <tbody id='jobs' class="divide-y divivde-gray-300">
<%= render partial: "jobs/job_tr", collection: @user.costumer_jobs.order(created_at: :desc).limit(10), as: :job, locals: { no_actions: true } %> <%= render partial: "jobs/job_tr", collection: @user.customer_jobs.order(created_at: :desc).limit(10), as: :job, locals: { no_actions: true } %>
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@@ -11,12 +11,12 @@
</div> </div>
<% end %> <% end %>
<div class="my-5"> <div class="my-5">
<%= form.label :costumer_firstname, 'Vorname' %> <%= form.label :customer_firstname, 'Vorname' %>
<%= form.text_field :costumer_firstname, disabled: true ,class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %> <%= form.text_field :customer_firstname, disabled: true ,class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
</div> </div>
<div class="my-5"> <div class="my-5">
<%= form.label :costumer_lastname, 'Nachname' %> <%= form.label :customer_lastname, 'Nachname' %>
<%= form.text_field :costumer_lastname, disabled: true ,class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %> <%= form.text_field :customer_lastname, disabled: true ,class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
</div> </div>
<div> <div>
<%= form.label :pdf, "Plan auswählen (PDF-Format)" %> <%= form.label :pdf, "Plan auswählen (PDF-Format)" %>

View File

@@ -11,7 +11,7 @@
<% end %> <% end %>
</td> </td>
<td class="p-2 py-3"> <td class="p-2 py-3">
<%= job.costumer_fullname %> <%= job.customer_fullname %>
</td> </td>
<td class="p-2 py-3"> <td class="p-2 py-3">
<% if job.pdf.attached? %> <% if job.pdf.attached? %>

View File

@@ -11,12 +11,12 @@
</div> </div>
<% end %> <% end %>
<div class="my-5"> <div class="my-5">
<%= form.label :costumer_firstname, 'Vorname' %> <%= form.label :customer_firstname, 'Vorname' %>
<%= form.text_field :costumer_firstname, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %> <%= form.text_field :customer_firstname, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
</div> </div>
<div class="my-5"> <div class="my-5">
<%= form.label :costumer_lastname, 'Nachname' %> <%= form.label :customer_lastname, 'Nachname' %>
<%= form.text_field :costumer_lastname, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %> <%= form.text_field :customer_lastname, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
</div> </div>
<div class="my-5 inline"> <div class="my-5 inline">
<%= form.check_box :intern, class: "pr-2 h-5 w-5" %> <%= form.check_box :intern, class: "pr-2 h-5 w-5" %>

View File

@@ -4,9 +4,9 @@
</div> </div>
<div> <div>
<p class="my-3"> <p class="my-3">
<strong class="mb-1 font-medium">Costumer ID:</strong> <strong class="mb-1 font-medium">customer ID:</strong>
<% if job.costumer %> <% if job.customer %>
<%= link_to_if allowed_to?(:show?, job.costumer, namespace: :Admin), "#{job.costumer_id} - #{job.costumer.name} (#{job.costumer.email})", admin_user_path(job.costumer) %> <%= link_to_if allowed_to?(:show?, job.customer, namespace: :Admin), "#{job.customer_id} - #{job.customer.name} (#{job.customer.email})", admin_user_path(job.customer) %>
<% else %> <% else %>
- -
<% end %> <% end %>
@@ -37,7 +37,7 @@
</p> </p>
<p class="my-3"> <p class="my-3">
<strong class="mb-1 font-medium">Kunde:</strong> <strong class="mb-1 font-medium">Kunde:</strong>
<%= link_to_if job.costumer && allowed_to?(:show? , job.costumer, namespace: :Admin), "#{job.costumer_firstname} #{job.costumer_lastname}", ( job.costumer ? admin_user_path(job.costumer) : "" ) %> <%= link_to_if job.customer && allowed_to?(:show? , job.customer, namespace: :Admin), "#{job.customer_firstname} #{job.customer_lastname}", ( job.customer ? admin_user_path(job.customer) : "" ) %>
</p> </p>
<p class="my-3"> <p class="my-3">
<strong class="mb-1 font-medium">Operator:</strong> <strong class="mb-1 font-medium">Operator:</strong>

View File

@@ -13,7 +13,7 @@
<% end %> <% end %>
</td> </td>
<td class="p-2 py-3"> <td class="p-2 py-3">
<%= job.costumer_fullname %> <%= job.customer_fullname %>
</td> </td>
<td class="p-2 py-3"> <td class="p-2 py-3">
<% if job.pdf.attached? %> <% if job.pdf.attached? %>

View File

@@ -22,11 +22,11 @@
<h2 class="p-1 text-lg font-bold border-b-2 border-hsrm-red">Aufgegebene Druckaufträge</h2> <h2 class="p-1 text-lg font-bold border-b-2 border-hsrm-red">Aufgegebene Druckaufträge</h2>
<p> <p>
Aufgegebene Druckaufträge Aufgegebene Druckaufträge
<%= current_user.costumer_jobs.size %> <%= current_user.customer_jobs.size %>
</p> </p>
<p> <p>
Abgebrochene Druckaufgräge Abgebrochene Druckaufgräge
<%= current_user.costumer_jobs.canceled.size %> <%= current_user.customer_jobs.canceled.size %>
</p> </p>
<% if is_admin_or_operator? %> <% if is_admin_or_operator? %>
<h2 class="p-1 text-lg font-bold border-b-2 border-hsrm-red">Bearbeitete Druckaufträge</h2> <h2 class="p-1 text-lg font-bold border-b-2 border-hsrm-red">Bearbeitete Druckaufträge</h2>

View File

@@ -33,8 +33,8 @@ de:
job: job:
pdf: "Plan (PDF Format)" pdf: "Plan (PDF Format)"
privacy_policy: "Datenschutzerklärung" privacy_policy: "Datenschutzerklärung"
costumer_firstname: "Vorname" customer_firstname: "Vorname"
costumer_lastname: "Nachname" customer_lastname: "Nachname"
errors: errors:
models: models:
job: job:

View File

@@ -1,12 +1,12 @@
class CreateJobs < ActiveRecord::Migration[7.1] class CreateJobs < ActiveRecord::Migration[7.1]
def change def change
create_table :jobs do |t| create_table :jobs do |t|
t.references :costumer, null: true t.references :customer, null: true
t.references :creator, null: true t.references :creator, null: true
t.references :cashier, null: true t.references :cashier, null: true
t.references :operator, null: true t.references :operator, null: true
t.string :costumer_firstname t.string :customer_firstname
t.string :costumer_lastname t.string :customer_lastname
t.string :operator_firstname t.string :operator_firstname
t.string :operator_lastname t.string :operator_lastname
t.string :cashier_firstname t.string :cashier_firstname

View File

@@ -10,14 +10,14 @@ class CreateUsers < ActiveRecord::Migration[7.2]
t.boolean :verified, null: false, default: false t.boolean :verified, null: false, default: false
t.integer :costumer_jobs_count, default: 0 t.integer :customer_jobs_count, default: 0
t.integer :operator_jobs_count, default: 0 t.integer :operator_jobs_count, default: 0
t.integer :created_jobs_count, default: 0 t.integer :created_jobs_count, default: 0
t.integer :cashed_jobs_count, default: 0 t.integer :cashed_jobs_count, default: 0
t.timestamps t.timestamps
end end
add_foreign_key :jobs, :users, column: :costumer_id add_foreign_key :jobs, :users, column: :customer_id
add_foreign_key :jobs, :users, column: :operator_id add_foreign_key :jobs, :users, column: :operator_id
add_foreign_key :jobs, :users, column: :creator_id add_foreign_key :jobs, :users, column: :creator_id
add_foreign_key :jobs, :users, column: :cashier_id add_foreign_key :jobs, :users, column: :cashier_id

12
db/schema.rb generated
View File

@@ -40,12 +40,12 @@ ActiveRecord::Schema[7.2].define(version: 2024_08_26_144016) do
end end
create_table "jobs", force: :cascade do |t| create_table "jobs", force: :cascade do |t|
t.integer "costumer_id" t.integer "customer_id"
t.integer "creator_id" t.integer "creator_id"
t.integer "cashier_id" t.integer "cashier_id"
t.integer "operator_id" t.integer "operator_id"
t.string "costumer_firstname" t.string "customer_firstname"
t.string "costumer_lastname" t.string "customer_lastname"
t.string "operator_firstname" t.string "operator_firstname"
t.string "operator_lastname" t.string "operator_lastname"
t.string "cashier_firstname" t.string "cashier_firstname"
@@ -68,8 +68,8 @@ ActiveRecord::Schema[7.2].define(version: 2024_08_26_144016) do
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.index ["cashier_id"], name: "index_jobs_on_cashier_id" t.index ["cashier_id"], name: "index_jobs_on_cashier_id"
t.index ["costumer_id"], name: "index_jobs_on_costumer_id"
t.index ["creator_id"], name: "index_jobs_on_creator_id" t.index ["creator_id"], name: "index_jobs_on_creator_id"
t.index ["customer_id"], name: "index_jobs_on_customer_id"
t.index ["operator_id"], name: "index_jobs_on_operator_id" t.index ["operator_id"], name: "index_jobs_on_operator_id"
t.index ["status"], name: "index_jobs_on_status" t.index ["status"], name: "index_jobs_on_status"
end end
@@ -90,7 +90,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_08_26_144016) do
t.string "lastname" t.string "lastname"
t.string "role", default: "user" t.string "role", default: "user"
t.boolean "verified", default: false, null: false t.boolean "verified", default: false, null: false
t.integer "costumer_jobs_count", default: 0 t.integer "customer_jobs_count", default: 0
t.integer "operator_jobs_count", default: 0 t.integer "operator_jobs_count", default: 0
t.integer "created_jobs_count", default: 0 t.integer "created_jobs_count", default: 0
t.integer "cashed_jobs_count", default: 0 t.integer "cashed_jobs_count", default: 0
@@ -103,8 +103,8 @@ ActiveRecord::Schema[7.2].define(version: 2024_08_26_144016) do
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" 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 "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "jobs", "users", column: "cashier_id" add_foreign_key "jobs", "users", column: "cashier_id"
add_foreign_key "jobs", "users", column: "costumer_id"
add_foreign_key "jobs", "users", column: "creator_id" add_foreign_key "jobs", "users", column: "creator_id"
add_foreign_key "jobs", "users", column: "customer_id"
add_foreign_key "jobs", "users", column: "operator_id" add_foreign_key "jobs", "users", column: "operator_id"
add_foreign_key "sessions", "users" add_foreign_key "sessions", "users"
end end

View File

@@ -78,7 +78,7 @@ end
job = Job.new(status:, privacy_policy: true, created_at: created_at) job = Job.new(status:, privacy_policy: true, created_at: created_at)
job.pdf = File.open(Rails.root.join('db/pdfs/', pdf)) job.pdf = File.open(Rails.root.join('db/pdfs/', pdf))
student = students[rand(0..9)] student = students[rand(0..9)]
job.costumer = student job.customer = student
job.creator = student job.creator = student
operator = operators[rand(0...1)] operator = operators[rand(0...1)]
job.operator = operator if status != :open job.operator = operator if status != :open
@@ -112,7 +112,7 @@ end
job = Job.new(status:, privacy_policy: true, created_at: created_at) job = Job.new(status:, privacy_policy: true, created_at: created_at)
job.pdf = File.open(Rails.root.join('db/pdfs/', pdf)) job.pdf = File.open(Rails.root.join('db/pdfs/', pdf))
student = students[rand(0...9)] student = students[rand(0...9)]
job.costumer = student job.customer = student
job.creator = student job.creator = student
operator = operators[rand(0...1)] operator = operators[rand(0...1)]
job.operator = operator if status == :paid job.operator = operator if status == :paid
@@ -137,7 +137,7 @@ end
job = Job.new(status:, privacy_policy: true) job = Job.new(status:, privacy_policy: true)
job.pdf = File.open(Rails.root.join('db/pdfs/', pdf)) job.pdf = File.open(Rails.root.join('db/pdfs/', pdf))
student = students[rand(0...4)] student = students[rand(0...4)]
job.costumer = student job.customer = student
job.creator = student job.creator = student
operator = operators[rand(0...1)] operator = operators[rand(0...1)]
job.operator = operator if status != :open job.operator = operator if status != :open
@@ -154,9 +154,9 @@ end
job = Job.new(privacy_policy: true) job = Job.new(privacy_policy: true)
job.pdf = File.open(Rails.root.join('db/pdfs/', pdf)) job.pdf = File.open(Rails.root.join('db/pdfs/', pdf))
student = students[rand(0...9)] student = students[rand(0...9)]
job.costumer = [ student, student, false ].sample job.customer = [ student, student, false ].sample
job.costumer_firstname = student.firstname job.customer_firstname = student.firstname
job.costumer_lastname = student.lastname job.customer_lastname = student.lastname
job.creator = operators[rand(0...1)] job.creator = operators[rand(0...1)]
job.created_by_operator = true job.created_by_operator = true
job.inspect job.inspect

View File

@@ -17,7 +17,7 @@ class JobsControllerTest < ActionDispatch::IntegrationTest
test "should create job" do test "should create job" do
assert_difference("Job.count") do assert_difference("Job.count") do
post jobs_url, params: { job: { cost_center: @job.cost_center, costum_qm_plan: @job.costum_qm_plan, costumer_firstname: @job.costumer_firstname, costumer_id_id: @job.costumer_id_id, costumer_lastname: @job.costumer_lastname, intern: @job.intern, number_of_plans_a0: @job.number_of_plans_a0, number_of_plans_a1: @job.number_of_plans_a1, number_of_plans_a2: @job.number_of_plans_a2, number_of_plans_a3: @job.number_of_plans_a3, operator_firstname: @job.operator_firstname, operator_id_id: @job.operator_id_id, operator_lastname: @job.operator_lastname, paid: @job.paid, printed_at: @job.printed_at } } post jobs_url, params: { job: { cost_center: @job.cost_center, costum_qm_plan: @job.costum_qm_plan, customer_firstname: @job.customer_firstname, customer_id_id: @job.customer_id_id, customer_lastname: @job.customer_lastname, intern: @job.intern, number_of_plans_a0: @job.number_of_plans_a0, number_of_plans_a1: @job.number_of_plans_a1, number_of_plans_a2: @job.number_of_plans_a2, number_of_plans_a3: @job.number_of_plans_a3, operator_firstname: @job.operator_firstname, operator_id_id: @job.operator_id_id, operator_lastname: @job.operator_lastname, paid: @job.paid, printed_at: @job.printed_at } }
end end
assert_redirected_to job_url(Job.last) assert_redirected_to job_url(Job.last)
@@ -34,7 +34,7 @@ class JobsControllerTest < ActionDispatch::IntegrationTest
end end
test "should update job" do test "should update job" do
patch job_url(@job), params: { job: { cost_center: @job.cost_center, costum_qm_plan: @job.costum_qm_plan, costumer_firstname: @job.costumer_firstname, costumer_id_id: @job.costumer_id_id, costumer_lastname: @job.costumer_lastname, intern: @job.intern, number_of_plans_a0: @job.number_of_plans_a0, number_of_plans_a1: @job.number_of_plans_a1, number_of_plans_a2: @job.number_of_plans_a2, number_of_plans_a3: @job.number_of_plans_a3, operator_firstname: @job.operator_firstname, operator_id_id: @job.operator_id_id, operator_lastname: @job.operator_lastname, paid: @job.paid, printed_at: @job.printed_at } } patch job_url(@job), params: { job: { cost_center: @job.cost_center, costum_qm_plan: @job.costum_qm_plan, customer_firstname: @job.customer_firstname, customer_id_id: @job.customer_id_id, customer_lastname: @job.customer_lastname, intern: @job.intern, number_of_plans_a0: @job.number_of_plans_a0, number_of_plans_a1: @job.number_of_plans_a1, number_of_plans_a2: @job.number_of_plans_a2, number_of_plans_a3: @job.number_of_plans_a3, operator_firstname: @job.operator_firstname, operator_id_id: @job.operator_id_id, operator_lastname: @job.operator_lastname, paid: @job.paid, printed_at: @job.printed_at } }
assert_redirected_to job_url(@job) assert_redirected_to job_url(@job)
end end

View File

@@ -2,11 +2,11 @@
one: one:
operator_id: one operator_id: one
costumer_id: one customer_id: one
operator_firstname: MyString operator_firstname: MyString
operator_lastname: MyString operator_lastname: MyString
costumer_firstname: MyString customer_firstname: MyString
costumer_lastname: MyString customer_lastname: MyString
paid: false paid: false
printed_at: 2024-07-27 12:13:47 printed_at: 2024-07-27 12:13:47
intern: false intern: false
@@ -19,11 +19,11 @@ one:
two: two:
operator_id: two operator_id: two
costumer_id: two customer_id: two
operator_firstname: MyString operator_firstname: MyString
operator_lastname: MyString operator_lastname: MyString
costumer_firstname: MyString customer_firstname: MyString
costumer_lastname: MyString customer_lastname: MyString
paid: false paid: false
printed_at: 2024-07-27 12:13:47 printed_at: 2024-07-27 12:13:47
intern: false intern: false

View File

@@ -16,9 +16,9 @@ class JobsTest < ApplicationSystemTestCase
fill_in "Cost center", with: @job.cost_center fill_in "Cost center", with: @job.cost_center
fill_in "Costum qm plan", with: @job.costum_qm_plan fill_in "Costum qm plan", with: @job.costum_qm_plan
fill_in "Costumer firstname", with: @job.costumer_firstname fill_in "customer firstname", with: @job.customer_firstname
fill_in "Costumer id", with: @job.costumer_id_id fill_in "customer id", with: @job.customer_id_id
fill_in "Costumer lastname", with: @job.costumer_lastname fill_in "customer lastname", with: @job.customer_lastname
check "Intern" if @job.intern check "Intern" if @job.intern
fill_in "Number of plans a0", with: @job.number_of_plans_a0 fill_in "Number of plans a0", with: @job.number_of_plans_a0
fill_in "Number of plans a1", with: @job.number_of_plans_a1 fill_in "Number of plans a1", with: @job.number_of_plans_a1
@@ -41,9 +41,9 @@ class JobsTest < ApplicationSystemTestCase
fill_in "Cost center", with: @job.cost_center fill_in "Cost center", with: @job.cost_center
fill_in "Costum qm plan", with: @job.costum_qm_plan fill_in "Costum qm plan", with: @job.costum_qm_plan
fill_in "Costumer firstname", with: @job.costumer_firstname fill_in "customer firstname", with: @job.customer_firstname
fill_in "Costumer id", with: @job.costumer_id_id fill_in "customer id", with: @job.customer_id_id
fill_in "Costumer lastname", with: @job.costumer_lastname fill_in "customer lastname", with: @job.customer_lastname
check "Intern" if @job.intern check "Intern" if @job.intern
fill_in "Number of plans a0", with: @job.number_of_plans_a0 fill_in "Number of plans a0", with: @job.number_of_plans_a0
fill_in "Number of plans a1", with: @job.number_of_plans_a1 fill_in "Number of plans a1", with: @job.number_of_plans_a1