Many Changes: Rename privacy_policy, fixed seed.rb, fixed status in migration file, created new job for operator
This commit is contained in:
@@ -83,6 +83,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_accepted, :pdf)
|
params.require(:job).permit(:costumer_id, :costumer_firstname, :costumer_lastname, :privacy_policy, :pdf)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class Operator::JobsController < ApplicationController
|
|||||||
# 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.created_by_operator = true
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @job.save
|
if @job.save
|
||||||
@@ -43,7 +44,6 @@ class Operator::JobsController < ApplicationController
|
|||||||
format.html { redirect_to operator_jobs_url, notice: "Job was successfully updated." }
|
format.html { redirect_to operator_jobs_url, notice: "Job was successfully updated." }
|
||||||
else
|
else
|
||||||
flash[:alert] = "Job was not updated."
|
flash[:alert] = "Job was not updated."
|
||||||
format.turbo_stream
|
|
||||||
format.html { render :edit, status: :unprocessable_entity }
|
format.html { render :edit, status: :unprocessable_entity }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -110,7 +110,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(:operator_id, :costumer_id, :operator_firstname, :operator_lastname, :costumer_firstname, :costumer_lastname, :status, :privacy_policy_accepted, :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, :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)
|
||||||
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
|
||||||
|
|||||||
@@ -29,8 +29,12 @@ module ApplicationHelper
|
|||||||
def profile_tab?
|
def profile_tab?
|
||||||
controller_name=="profiles"
|
controller_name=="profiles"
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_admin_or_operator?
|
def is_admin_or_operator?
|
||||||
current_user.admin? || current_user.operator?
|
current_user.admin? || current_user.operator?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def edit_form?
|
||||||
|
action_name != "new" && action_name != "create"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,11 +4,10 @@ class Job < ApplicationRecord
|
|||||||
|
|
||||||
has_one_attached :pdf, dependent: :purge
|
has_one_attached :pdf, dependent: :purge
|
||||||
|
|
||||||
validates_presence_of :costumer_firstname, :costumer_lastname, :privacy_policy_accepted, :pdf
|
validates_presence_of :costumer_firstname, :costumer_lastname, :pdf
|
||||||
# validates_numericality_of {:number_of_plans_a0,:number_of_plans_a1, :number_of_plans_a2, :number_of_plans_a3}, greater_than_or_equal_to: 0
|
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, numericality: { greater_than_or_equal_to: 0 }
|
validates :number_of_plans_a0, :number_of_plans_a1, :number_of_plans_a2, :number_of_plans_a3, numericality: { greater_than_or_equal_to: 0 }
|
||||||
|
|
||||||
|
|
||||||
validate :acceptable_pdf
|
validate :acceptable_pdf
|
||||||
|
|
||||||
before_save :update_printed_at, if: :will_save_change_to_status?
|
before_save :update_printed_at, if: :will_save_change_to_status?
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
<%= form.file_field :pdf, accept: "application/pdf", class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
|
<%= form.file_field :pdf, accept: "application/pdf", 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.check_box :privacy_policy_accepted, class: "mt-2 h-5 w-5" %> <%= form.label :privacy_policy_accepted, "Datenschutzerklärung akzeptiert", class: "p-2" %>
|
<%= form.check_box :privacy_policy, class: "mt-2 h-5 w-5" %> <%= form.label :privacy_policy, "Datenschutzerklärung akzeptiert", class: "p-2" %>
|
||||||
</div>
|
</div>
|
||||||
<div class="inline">
|
<div class="inline">
|
||||||
<%= form.submit "Plottauftrag abschicken", class: "py-2 px-3 bg-hsrm-red hover:bg-hsrm-red-light shadow-lg text-white inline-block font-medium cursor-pointer" %>
|
<%= form.submit "Plottauftrag abschicken", class: "py-2 px-3 bg-hsrm-red hover:bg-hsrm-red-light shadow-lg text-white inline-block font-medium cursor-pointer" %>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= form_with(model: job, url: operator_job_path(job), method: "patch", class: "contents") do |form| %>
|
<%= form_with(model: [:operator, job], class: "contents") do |form| %>
|
||||||
<% if job.errors.any? %>
|
<% if job.errors.any? %>
|
||||||
<div id="error_explanation" class="px-3 py-2 mt-3 font-medium text-red-500 border-l rounded-lg shadow-lg bg-red-50 border-red" >
|
<div id="error_explanation" class="px-3 py-2 mt-3 font-medium text-red-500 border-l rounded-lg shadow-lg bg-red-50 border-red" >
|
||||||
<h2><%= pluralize(job.errors.count, "error") %>
|
<h2><%= pluralize(job.errors.count, "error") %>
|
||||||
@@ -26,34 +26,34 @@
|
|||||||
<%= form.label :cost_center %>
|
<%= form.label :cost_center %>
|
||||||
<%= form.text_field :cost_center, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
|
<%= form.text_field :cost_center, 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">
|
<% if edit_form? %>
|
||||||
<%= form.label :number_of_plans_a0 %>
|
<div class="my-5">
|
||||||
<%= form.number_field :number_of_plans_a0, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
|
<%= form.label :number_of_plans_a0 %>
|
||||||
</div>
|
<%= form.number_field :number_of_plans_a0, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
|
||||||
<div class="my-5">
|
</div>
|
||||||
<%= form.label :number_of_plans_a1 %>
|
<div class="my-5">
|
||||||
<%= form.number_field :number_of_plans_a1, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
|
<%= form.label :number_of_plans_a1 %>
|
||||||
</div>
|
<%= form.number_field :number_of_plans_a1, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
|
||||||
<div class="my-5">
|
</div>
|
||||||
<%= form.label :number_of_plans_a2 %>
|
<div class="my-5">
|
||||||
<%= form.number_field :number_of_plans_a2, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
|
<%= form.label :number_of_plans_a2 %>
|
||||||
</div>
|
<%= form.number_field :number_of_plans_a2, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
|
||||||
<div class="my-5">
|
</div>
|
||||||
<%= form.label :number_of_plans_a3 %>
|
<div class="my-5">
|
||||||
<%= form.number_field :number_of_plans_a3, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
|
<%= form.label :number_of_plans_a3 %>
|
||||||
</div>
|
<%= form.number_field :number_of_plans_a3, class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
|
||||||
<div class="my-5">
|
</div>
|
||||||
<%= form.label :costum_qm_plan %>
|
<div class="my-5">
|
||||||
<%= form.number_field :costum_qm_plan, in: 0..20.0, step: 0.01 ,class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
|
<%= form.label :costum_qm_plan %>
|
||||||
</div>
|
<%= form.number_field :costum_qm_plan, in: 0..20.0, step: 0.01 ,class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
|
||||||
<!-- <div>
|
</div>
|
||||||
<%= form.label :pdf, "Plan auswählen (PDF-Format)" %>
|
<% else %>
|
||||||
<%= form.file_field :pdf, accept: "application/pdf", class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
|
<div>
|
||||||
</div> -->
|
<%= form.label :pdf, "Plan auswählen (PDF-Format)" %>
|
||||||
<div>
|
<%= form.file_field :pdf, accept: "application/pdf", class: "block shadow-lg rounded-md border border-hsrm-gray outline-none px-3 py-2 mt-2 w-full" %>
|
||||||
<%= form.check_box :privacy_policy_accepted, class: "mt-2 h-5 w-5" %> <%= form.label :privacy_policy_accepted, "Datenschutzerklärung akzeptiert", class: "p-2" %>
|
</div>
|
||||||
</div>
|
<% end %>
|
||||||
<div class="inline">
|
<div class="inline">
|
||||||
<%= form.submit "Plottauftrag abschicken", class: "py-2 px-3 bg-hsrm-red hover:bg-hsrm-red-light shadow-lg text-white inline-block font-medium cursor-pointer" %>
|
<%= form.submit edit_form? && "Speichern" || "Druckauftrag anlegen", class: "py-2 px-3 bg-hsrm-red hover:bg-hsrm-red-light shadow-lg text-white inline-block font-medium cursor-pointer" %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -15,7 +15,12 @@
|
|||||||
<%= icon(status_icon(:printing), class: "icon") %>
|
<%= icon(status_icon(:printing), class: "icon") %>
|
||||||
Printing
|
Printing
|
||||||
</h1>
|
</h1>
|
||||||
<%= render partial: 'start_next_job_btn', locals: { jobs: @openjobs } %>
|
<div class="flex gap-2">
|
||||||
|
<div id="start_manual_job_btn">
|
||||||
|
<%= link_to icon("printer", class: "icon icon-nohover size-6 mr-2", title: "Nächsten Druckauftrag starten") + "Druckauftrag erstellen" , new_operator_job_path, class: "btn block bg-green-400 text-black" %>
|
||||||
|
</div>
|
||||||
|
<%= render partial: 'start_next_job_btn', locals: { jobs: @openjobs } %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<%# render partial: "job_card", collection: @printingjobs, as: :job %>
|
<%# render partial: "job_card", collection: @printingjobs, as: :job %>
|
||||||
<div class="min-w-full overflow-auto shadow-lg">
|
<div class="min-w-full overflow-auto shadow-lg">
|
||||||
|
|||||||
5
app/views/operator/jobs/new.html.erb
Normal file
5
app/views/operator/jobs/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<div class="mx-auto md:w-2/3 w-full">
|
||||||
|
<h1 class="font-bold text-4xl">Druckauftrag erstellen</h1>
|
||||||
|
<%= render "form", job: @job %>
|
||||||
|
<%= link_to "Zurück zur Übersicht", operator_jobs_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||||
|
</div>
|
||||||
@@ -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.string :status, default: 0, index: true
|
t.string :status, default: "open", 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
|
||||||
@@ -22,9 +22,10 @@ class CreateJobs < ActiveRecord::Migration[7.1]
|
|||||||
t.float :costum_qm_plan, default: 0
|
t.float :costum_qm_plan, default: 0
|
||||||
t.float :cost, default: 0
|
t.float :cost, default: 0
|
||||||
t.float :cost_qm, default: 0
|
t.float :cost_qm, default: 0
|
||||||
t.boolean :privacy_policy_accepted, default: false
|
t.boolean :privacy_policy, default: false
|
||||||
|
t.boolean :created_by_operator, default: false
|
||||||
|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
5
db/schema.rb
generated
5
db/schema.rb
generated
@@ -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.string "status", default: "0"
|
t.string "status", default: "open"
|
||||||
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
|
||||||
@@ -61,7 +61,8 @@ ActiveRecord::Schema[7.2].define(version: 2024_08_26_144016) do
|
|||||||
t.float "costum_qm_plan", default: 0.0
|
t.float "costum_qm_plan", default: 0.0
|
||||||
t.float "cost", default: 0.0
|
t.float "cost", default: 0.0
|
||||||
t.float "cost_qm", default: 0.0
|
t.float "cost_qm", default: 0.0
|
||||||
t.boolean "privacy_policy_accepted", default: false
|
t.boolean "privacy_policy", default: false
|
||||||
|
t.boolean "created_by_operator", default: 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
|
||||||
t.index ["costumer_id"], name: "index_jobs_on_costumer_id"
|
t.index ["costumer_id"], name: "index_jobs_on_costumer_id"
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ end
|
|||||||
'DasNächsteMalGeheIchWoAndersHin.pdf' ].shuffle.each do |pdf|
|
'DasNächsteMalGeheIchWoAndersHin.pdf' ].shuffle.each do |pdf|
|
||||||
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(status:, privacy_policy_accepted: 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))
|
||||||
job.costumer = students[rand(0...4)]
|
job.costumer = students[rand(0...4)]
|
||||||
job.save!
|
job.save!
|
||||||
|
|||||||
Reference in New Issue
Block a user