Renamed job associations for operator and costumer
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
class Job < ApplicationRecord
|
||||
attr_accessor :current_user
|
||||
|
||||
belongs_to :costumer, class_name: "User", optional: true, counter_cache: :jobs_as_costumer_count, inverse_of: :jobs_as_costumer
|
||||
belongs_to :operator, class_name: "User", optional: true, counter_cache: :jobs_as_operator_count, inverse_of: :jobs_as_operator
|
||||
belongs_to :costumer, class_name: "User", optional: true, counter_cache: :costumer_jobs_count, inverse_of: :costumer_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 :cashier, class_name: "User", optional: true, counter_cache: :cashed_jobs_count, inverse_of: :cashed_jobs
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class User < ApplicationRecord
|
||||
has_secure_password
|
||||
# has_many :jobs
|
||||
has_many :jobs_as_costumer, foreign_key: :costumer_id, class_name: "Job"
|
||||
has_many :jobs_as_operator, foreign_key: :operator_id, class_name: "Job"
|
||||
has_many :costumer_jobs, foreign_key: :costumer_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 :cashed_jobs, foreign_key: :cashier_id, class_name: "Job"
|
||||
|
||||
@@ -45,7 +45,7 @@ class User < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.ransackable_attributes(auth_object = nil)
|
||||
[ "created_at", "email", "firstname", "id", "jobs_as_costumer_count", "jobs_as_operator_count", "lastname", "role", "verified", "name" ]
|
||||
[ "created_at", "email", "firstname", "id", "costumer_jobs_count", "operator_jobs_count", "lastname", "role", "verified", "name" ]
|
||||
end
|
||||
|
||||
def self.ransackable_associations(auth_object = nil)
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
<p>E-Mail Verifiziert:
|
||||
<%= icon bool_icon(user.verified), class: "icon #{user.verified ? "text-green-600" : "text-red-600"}" %></p>
|
||||
<p><%= user.created_at %></p>
|
||||
<p>Druckaufträge als Kunde: <%= @user.jobs_as_costumer.size %></p>
|
||||
<p>davon abgebrochen: <%= @user.jobs_as_costumer.canceled.size %></p>
|
||||
<p>Druckaufträge als Operator: <%= @user.jobs_as_operator.size %></p>
|
||||
<p>Druckaufträge als Kunde: <%= @user.costumer_jobs.size %></p>
|
||||
<p>davon abgebrochen: <%= @user.costumer_jobs.canceled.size %></p>
|
||||
<p>Druckaufträge als Operator: <%= @user.operator_jobs.size %></p>
|
||||
<p>Druckaufträge kassiert: <%= @user.cashed_jobs.size %></p>
|
||||
</div>
|
||||
|
||||
@@ -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, :lastname, "Nachname") %></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, :jobs_as_costumer_count, "# Jobs") %></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-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>
|
||||
</tr>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id='jobs' class="divide-y divivde-gray-300">
|
||||
<%= render partial: "jobs/job_tr", collection: @user.created_jobs.order(created_at: :desc).limit(10), as: :job, locals: { no_actions: true } %>
|
||||
<%= render partial: "jobs/job_tr", collection: @user.costumer_jobs.order(created_at: :desc).limit(10), as: :job, locals: { no_actions: true } %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -22,17 +22,17 @@
|
||||
<h2 class="p-1 text-lg font-bold border-b-2 border-hsrm-red">Aufgegebene Druckaufträge</h2>
|
||||
<p>
|
||||
Aufgegebene Druckaufträge
|
||||
<%= current_user.jobs_as_costumer.size %>
|
||||
<%= current_user.costumer_jobs.size %>
|
||||
</p>
|
||||
<p>
|
||||
Abgebrochene Druckaufgräge
|
||||
<%= current_user.jobs_as_costumer.canceled.size %>
|
||||
<%= current_user.costumer_jobs.canceled.size %>
|
||||
</p>
|
||||
<% if is_admin_or_operator? %>
|
||||
<h2 class="p-1 text-lg font-bold border-b-2 border-hsrm-red">Bearbeitete Druckaufträge</h2>
|
||||
<p>
|
||||
Gedruckte Druckaufträge
|
||||
<%= current_user.jobs_as_operator.paid.size %>
|
||||
<%= current_user.operator_jobs.paid.size %>
|
||||
</p>
|
||||
<% end %>
|
||||
<h2 class="p-1 text-lg font-bold border-b-2 border-hsrm-red">Actions</h2>
|
||||
|
||||
Reference in New Issue
Block a user