diff --git a/app/controllers/expenses_controller.rb b/app/controllers/expenses_controller.rb index 3d38733..e208a12 100644 --- a/app/controllers/expenses_controller.rb +++ b/app/controllers/expenses_controller.rb @@ -1,76 +1,7 @@ # Copyright (C) 2024 Manuel Bustillo class ExpensesController < ApplicationController - before_action :set_expense, only: %i[ show edit update destroy ] - - # GET /expenses or /expenses.json - def index - @expenses = Expense.all - end - def summary render json: Expenses::TotalQuery.new.call end - - # GET /expenses/1 or /expenses/1.json - def show - end - - # GET /expenses/new - def new - @expense = Expense.new - end - - # GET /expenses/1/edit - def edit - end - - # POST /expenses or /expenses.json - def create - @expense = Expense.new(expense_params) - - respond_to do |format| - if @expense.save - format.html { redirect_to expense_url(@expense), notice: "Expense was successfully created." } - format.json { render :show, status: :created, location: @expense } - else - format.html { render :new, status: :unprocessable_entity } - format.json { render json: @expense.errors, status: :unprocessable_entity } - end - end - end - - # PATCH/PUT /expenses/1 or /expenses/1.json - def update - respond_to do |format| - if @expense.update(expense_params) - format.html { redirect_to expense_url(@expense), notice: "Expense was successfully updated." } - format.json { render :show, status: :ok, location: @expense } - else - format.html { render :edit, status: :unprocessable_entity } - format.json { render json: @expense.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /expenses/1 or /expenses/1.json - def destroy - @expense.destroy! - - respond_to do |format| - format.html { redirect_to expenses_url, notice: "Expense was successfully destroyed." } - format.json { head :no_content } - end - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_expense - @expense = Expense.find(params[:id]) - end - - # Only allow a list of trusted parameters through. - def expense_params - params.require(:expense).permit(:name, :amount, :pricing_type) - end end diff --git a/app/controllers/guests_controller.rb b/app/controllers/guests_controller.rb index 5a1dbb2..ecf5d34 100644 --- a/app/controllers/guests_controller.rb +++ b/app/controllers/guests_controller.rb @@ -3,64 +3,12 @@ require 'csv' class GuestsController < ApplicationController - before_action :set_guest, only: %i[show edit update destroy] - - # GET /guests or /guests.json def index - @guests = Guest.all + @guests = Guest.all.includes(:group) .joins(:group) .order('groups.name' => :asc, first_name: :asc, last_name: :asc) - render jsonapi: @guests - end - - # GET /guests/1 or /guests/1.json - def show; end - - # GET /guests/new - def new - @guest = Guest.new - end - - # GET /guests/1/edit - def edit; end - - # POST /guests or /guests.json - def create - @guest = Guest.new(guest_params) - - respond_to do |format| - if @guest.save - format.html { redirect_to guest_url(@guest), notice: 'Guest was successfully created.' } - format.json { render :show, status: :created, location: @guest } - else - format.html { render :new, status: :unprocessable_entity } - format.json { render json: @guest.errors, status: :unprocessable_entity } - end - end - end - - # PATCH/PUT /guests/1 or /guests/1.json - def update - respond_to do |format| - if @guest.update(guest_params) - format.html { redirect_to guest_url(@guest), notice: 'Guest was successfully updated.' } - format.json { render :show, status: :ok, location: @guest } - else - format.html { render :edit, status: :unprocessable_entity } - format.json { render json: @guest.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /guests/1 or /guests/1.json - def destroy - @guest.destroy! - - respond_to do |format| - format.html { redirect_to guests_url, notice: 'Guest was successfully destroyed.' } - format.json { head :no_content } - end + render jsonapi: @guests end def import @@ -81,16 +29,4 @@ class GuestsController < ApplicationController Guest.where(id: params[:guest_ids]).update!(params.require(:properties).permit(:status)) render json: {}, status: :ok end - - private - - # Use callbacks to share common setup or constraints between actions. - def set_guest - @guest = Guest.find(params[:id]) - end - - # Only allow a list of trusted parameters through. - def guest_params - params.require(:guest).permit(:first_name, :last_name, :email, :phone) - end end diff --git a/app/controllers/tables_arrangements_controller.rb b/app/controllers/tables_arrangements_controller.rb index 8523f5a..75451ca 100644 --- a/app/controllers/tables_arrangements_controller.rb +++ b/app/controllers/tables_arrangements_controller.rb @@ -2,13 +2,10 @@ class TablesArrangementsController < ApplicationController def index - @tables_arrangements = TablesArrangement.all.order(discomfort: :asc).limit(10) + render json: TablesArrangement.all.order(discomfort: :asc).limit(10) end def show - @tables_arrangement = TablesArrangement.find(params[:id]) - @seats = @tables_arrangement.seats - .includes(guest: %i[affinity_groups unbreakable_bonds]) - .group_by(&:table_number) + render json: TablesArrangement.find(params[:id]) end end diff --git a/app/views/expenses/_expense.html.erb b/app/views/expenses/_expense.html.erb deleted file mode 100644 index 5bac9f6..0000000 --- a/app/views/expenses/_expense.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -<%# Copyright (C) 2024 Manuel Bustillo %> - -
-

- Name: - <%= expense.name %> -

- -

- Amount: - <%= expense.amount %> -

- -

- Pricing type: - <%= expense.pricing_type %> -

- -
diff --git a/app/views/expenses/_form.html.erb b/app/views/expenses/_form.html.erb deleted file mode 100644 index 8d9cd9c..0000000 --- a/app/views/expenses/_form.html.erb +++ /dev/null @@ -1,34 +0,0 @@ -<%# Copyright (C) 2024 Manuel Bustillo %> - -<%= form_with(model: expense) do |form| %> - <% if expense.errors.any? %> -
-

<%= pluralize(expense.errors.count, "error") %> prohibited this expense from being saved:

- - -
- <% end %> - -
- <%= form.label :name, style: "display: block" %> - <%= form.text_field :name %> -
- -
- <%= form.label :amount, style: "display: block" %> - <%= form.text_field :amount %> -
- -
- <%= form.label :pricing_type, style: "display: block" %> - <%= form.text_field :pricing_type %> -
- -
- <%= form.submit %> -
-<% end %> diff --git a/app/views/expenses/edit.html.erb b/app/views/expenses/edit.html.erb deleted file mode 100644 index 032aba0..0000000 --- a/app/views/expenses/edit.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<%# Copyright (C) 2024 Manuel Bustillo %> - -

Editing expense

- -<%= render "form", expense: @expense %> - -
- -
- <%= link_to "Show this expense", @expense %> | - <%= link_to "Back to expenses", expenses_path %> -
diff --git a/app/views/expenses/index.html.erb b/app/views/expenses/index.html.erb deleted file mode 100644 index 6e4fd28..0000000 --- a/app/views/expenses/index.html.erb +++ /dev/null @@ -1,30 +0,0 @@ -<%# Copyright (C) 2024 Manuel Bustillo %> - -

<%= notice %>

- -

Expenses

- -
- - - - - - - <% @expenses.each do |expense| %> - - - - - - - <% end %> - - - - - -
NameAmount
<%= expense.name %><%= expense.amount.to_currency %><%= link_to "Show", expense %><%= link_to "Edit", edit_expense_path(expense) %>
Total<%= @expenses.sum(&:amount).to_currency %>
-
- -<%= link_to "New expense", new_expense_path %> diff --git a/app/views/expenses/new.html.erb b/app/views/expenses/new.html.erb deleted file mode 100644 index a7b9844..0000000 --- a/app/views/expenses/new.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<%# Copyright (C) 2024 Manuel Bustillo %> - -

New expense

- -<%= render "form", expense: @expense %> - -
- -
- <%= link_to "Back to expenses", expenses_path %> -
diff --git a/app/views/expenses/show.html.erb b/app/views/expenses/show.html.erb deleted file mode 100644 index b2bec00..0000000 --- a/app/views/expenses/show.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<%# Copyright (C) 2024 Manuel Bustillo %> - -

<%= notice %>

- -<%= render @expense %> - -
- <%= link_to "Edit this expense", edit_expense_path(@expense) %> | - <%= link_to "Back to expenses", expenses_path %> - - <%= button_to "Destroy this expense", @expense, method: :delete %> -
diff --git a/app/views/guests/_form.html.erb b/app/views/guests/_form.html.erb deleted file mode 100644 index e2daaf5..0000000 --- a/app/views/guests/_form.html.erb +++ /dev/null @@ -1,39 +0,0 @@ -<%# Copyright (C) 2024 Manuel Bustillo %> - -<%= form_with(model: guest) do |form| %> - <% if guest.errors.any? %> -
-

<%= pluralize(guest.errors.count, "error") %> prohibited this guest from being saved:

- - -
- <% end %> - -
- <%= form.label :first_name, style: "display: block" %> - <%= form.text_field :first_name %> -
- -
- <%= form.label :last_name, style: "display: block" %> - <%= form.text_field :last_name %> -
- -
- <%= form.label :email, style: "display: block" %> - <%= form.text_field :email %> -
- -
- <%= form.label :phone, style: "display: block" %> - <%= form.text_field :phone %> -
- -
- <%= form.submit %> -
-<% end %> diff --git a/app/views/guests/_guest.html.erb b/app/views/guests/_guest.html.erb deleted file mode 100644 index ed160f9..0000000 --- a/app/views/guests/_guest.html.erb +++ /dev/null @@ -1,24 +0,0 @@ -<%# Copyright (C) 2024 Manuel Bustillo %> - -
-

- First name: - <%= guest.first_name %> -

- -

- Last name: - <%= guest.last_name %> -

- -

- Email: - <%= guest.email %> -

- -

- Phone: - <%= guest.phone %> -

- -
diff --git a/app/views/guests/edit.html.erb b/app/views/guests/edit.html.erb deleted file mode 100644 index d59a8e7..0000000 --- a/app/views/guests/edit.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<%# Copyright (C) 2024 Manuel Bustillo %> - -

Editing guest

- -<%= render "form", guest: @guest %> - -
- -
- <%= link_to "Show this guest", @guest %> | - <%= link_to "Back to guests", guests_path %> -
diff --git a/app/views/guests/index.html.erb b/app/views/guests/index.html.erb deleted file mode 100644 index 3ef84c4..0000000 --- a/app/views/guests/index.html.erb +++ /dev/null @@ -1,39 +0,0 @@ -<%# Copyright (C) 2024 Manuel Bustillo %> - -

<%= notice %>

- -

Guests

- -
- - - - - - - - - - - <% @guests.each_with_index do |guest, i| %> - - - - - - - - - - - <% end %> -
Row #NameEmailPhoneAffinity groupsUnbreakable bonds
<%= i + 1 %><%= guest.full_name %><%= guest.email %><%= guest.phone %><%= guest.affinity_groups.pluck(:name).join(", ") %><%= guest.unbreakable_bonds.pluck(:name).join(", ") %><%= link_to "Show", guest %><%= link_to "Edit", edit_guest_path(guest) %>
-
- -<%= link_to "New guest", new_guest_path %> - -<%= form_with url: import_guests_path, method: :post do |form| %> - <%= form.label :file %> - <%= form.file_field :file %> - <%= form.submit "Import" %> -<% end %> diff --git a/app/views/guests/new.html.erb b/app/views/guests/new.html.erb deleted file mode 100644 index 8405d09..0000000 --- a/app/views/guests/new.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<%# Copyright (C) 2024 Manuel Bustillo %> - -

New guest

- -<%= render "form", guest: @guest %> - -
- -
- <%= link_to "Back to guests", guests_path %> -
diff --git a/app/views/guests/show.html.erb b/app/views/guests/show.html.erb deleted file mode 100644 index 6976007..0000000 --- a/app/views/guests/show.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<%# Copyright (C) 2024 Manuel Bustillo %> - -

<%= notice %>

- -<%= render @guest %> - -
- <%= link_to "Edit this guest", edit_guest_path(@guest) %> | - <%= link_to "Back to guests", guests_path %> - - <%= button_to "Destroy this guest", @guest, method: :delete %> -
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb deleted file mode 100644 index 4c8aeb2..0000000 --- a/app/views/layouts/application.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<%# Copyright (C) 2024 Manuel Bustillo %> - - - - - WeddingPlanner - - <%= csrf_meta_tags %> - <%= csp_meta_tag %> - - <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> - <%= javascript_importmap_tags %> - - - - <%= yield %> - - diff --git a/app/views/tables_arrangements/index.html.erb b/app/views/tables_arrangements/index.html.erb deleted file mode 100644 index b24f7da..0000000 --- a/app/views/tables_arrangements/index.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<%# Copyright (C) 2024 Manuel Bustillo %> - -

Tables arrangements

- -
    - <% @tables_arrangements.each_with_index do |tables_arrangement, i| %> -
  1. -

    <%= link_to "Arrangement ##{i+1}", tables_arrangement_path(tables_arrangement) %> Discomfort: <%= tables_arrangement.discomfort %>

    -
  2. - <% end %> -
\ No newline at end of file diff --git a/app/views/tables_arrangements/show.html.erb b/app/views/tables_arrangements/show.html.erb deleted file mode 100644 index cc90581..0000000 --- a/app/views/tables_arrangements/show.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<%# Copyright (C) 2024 Manuel Bustillo %> - -

ID: <%= @tables_arrangement.id %>

- -

Discomfort: <%= @tables_arrangement.discomfort %>

- -

Seats

- -<% @seats.each do |table_number, seats| %> - -

Table <%= table_number %>

- - -<% end %> \ No newline at end of file