Skip to content

Commit

Permalink
Merge pull request #58 from Lifeline-Solutions/membership-update
Browse files Browse the repository at this point in the history
Membership update
  • Loading branch information
ger619 authored Jul 19, 2023
2 parents 1f07979 + bf3ea67 commit 4ebb331
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 65 deletions.
2 changes: 1 addition & 1 deletion app/controllers/advert_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ def destroy
private

def advert_params
params.permit(:type_of_advert, :header_advert, :mobile_image, :desk_image, :user_id)
params.require(:advert).permit(:type_of_advert, :header_advert, :mobile_image, :desk_image, :user_id)
end
end
2 changes: 1 addition & 1 deletion app/controllers/cart_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class CartController < ApplicationController
before_action :authenticate_user!, except: %i[show add remove]

def show
@render_cart = false
@render_cart = true
end

def add
Expand Down
36 changes: 20 additions & 16 deletions app/controllers/club_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,50 @@ class ClubController < ApplicationController
before_action :authenticate_user!, except: %i[index show]

def index
@clubs = Club.all.order('created_at DESC')
@club = Club.all.order('created_at DESC')
end

def show
@clubs = Club.find(params[:id])
@club = Club.find(params[:id])
end

def new
@club = Club.new
end

def create
@clubs = Club.new(clubs_params)
@clubs.user_id = current_user.id
@club = Club.new(club_params)
@club.user_id = current_user.id

respond_to do |format|
if @clubs.save
format.html { redirect_to club_index_path(@clubs), notice: 'News was successfully created.' }
if @club.save
format.html { redirect_to club_index_path(@club), notice: 'News was successfully created.' }
else
format.html { redirect_to club_index_path, notice: 'Failure' }
end
end
end

def edit
@clubs = Club.find(params[:id])
@club = Club.find(params[:id])
end

def update
@clubs = Club.find(params[:id])
@clubs.user_id = current_user.id
@club = Club.find(params[:id])
@club.user_id = current_user.id
respond_to do |format|
if @clubs.update(clubs_params)
format.html { redirect_to club_index_path(@clubs), notice: 'Clubs was successfully updated.' }
if @club.update(club_params)
format.html { redirect_to club_index_path(@club), notice: 'Clubs was successfully updated.' }
else
format.html { redirect_to club_index_path, notice: 'Failure' }
end
end
end

def destroy
@clubs = Club.find(params[:id])
@clubs.user_id = current_user.id
@clubs.delete
@club = Club.find(params[:id])
@club.user_id = current_user.id
@club.delete

respond_to do |format|
format.html { redirect_to club_index_path, notice: 'News was successfully deleted.' }
Expand All @@ -50,7 +54,7 @@ def destroy

private

def clubs_params
params.permit(:header, :body, :photo, :user_id)
def club_params
params.require(:club).permit(:header, :body, :photo, :user_id)
end
end
4 changes: 2 additions & 2 deletions app/controllers/membership_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class MembershipController < ApplicationController
before_action :authenticate_user!, except: [:index]
before_action :authenticate_user!, except: %i[index show new create]

def index; end

Expand Down Expand Up @@ -33,6 +33,6 @@ def destroy
private

def membership_params
params.permit(:type_of_membership, :title, :country, :date_of_birth, :email, :phone_number, :photo)
params.permit(:type_of_membership, :title, :country, :date_of_birth, :email, :phone_number)
end
end
2 changes: 1 addition & 1 deletion app/views/advert/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_with model: @adverts, url: advert_index_url, method: :post, data: { turbo: false }, local: true do |f| %>
<%= form_with model: @advert, url: advert_index_url, method: :post, data: { turbo: false }, local: true do |f| %>

<div class="md:p-0">
<div class="p-6 bg-[#FAE115] font-bold uppercase lg:text-5xl md:text-4xl text-3xl flex justify-between">
Expand Down
11 changes: 5 additions & 6 deletions app/views/cart/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
</div>
<div class="flex">
<div class="w-[70%]">
<div
class="border-b-2 border-[#000] justify-between flex p-5 mx-20 items-center"
>
<h1 class="font-bold text-3xl">Shopping cart</h1>
<div class="border-b-2 border-[#000] justify-between flex p-5 mx-20 items-center">
<h1 class="font-bold text-3xl">Items Loaded</h1>
<p class="font-bold text-3xl"><%= @cart.orderables.count %> Items</p>
</div>
<div>
Expand All @@ -43,8 +41,9 @@
<td class="text-center"><%= orderable.quantity %></td>
<td class="text-center"><%= orderable.product.price %></td>
<td class="text-center">
<%= form_with(url: cart_remove_path) do |f| %> <%=
f.hidden_field :id, value: orderable.id %> <%= f.submit "X" %>
<%= form_with(url: cart_remove_path) do |f| %>
<%= f.hidden_field :id, value: orderable.id %>
<%= f.submit "X" %>
<% end %>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion app/views/club/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_with model: @clubs, url: club_index_path, method: :club, data: { turbo: false }, local: true do |f| %>
<%= form_with model: @club, url: club_index_path, method: :club, data: { turbo: false }, local: true do |f| %>

<div class="md:w-[1280px] flex flex-col gap-4 md:my-12 md:mx-auto bg-[#F7F3ED] md:p-4">
<h1 class="md:text-5xl text-2xl ">
Expand Down
2 changes: 1 addition & 1 deletion app/views/club/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<%=link_to "Add Club & History", new_club_path, class: "normal-case border-2 border-[#fff] hover:bg-[#fff] font-normal lg:text-2xl md:text-xl sm:text-sm sm:text-xl text-white hover:text-[#FAE115] p-2 rounded-full mb-2" %>
<% end %>
</div>
<% @clubs.each do |club| %>
<% @club.each do |club| %>
<div class="flex flex-col gap-4 flex odd:flex-row-reverse md:flex-row items-center border-t-2 border-[#FAE115] my-4 bg-[#fdfee9] p-10">
<div class="flex flex-col ">
<h1 class="md:text-4xl text-3xl uppercase mt-5 font-normal mb-8">
Expand Down
6 changes: 3 additions & 3 deletions app/views/club/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="p-8 bg-[#FAE115] font-bold uppercase text-5xl">
CLUB & HISTORY | <span class="text-3xl"><%= @clubs.header %></span>
CLUB & HISTORY | <span class="text-3xl"><%= @club.header %></span>
</div>
<div>
<%= image_tag(@clubs.photo) %>
<%= @clubs.body %>
<%= image_tag(@club.photo) %>
<%= @club.body %>

</div>

57 changes: 32 additions & 25 deletions app/views/home/_landing.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<h5 class="mb-6 text-4xl font-bold tracking-tight text-[#000] mt-5 uppercase">
<%= news.type_of_news %>
</h5>
<p class="mb-2 font-normal text-[#000] truncate max-w-[200px]">

<p class="mb-2 font-normal text-[#000] truncate max-w-[200px] md:w-full lg:w-[300px]">
<%= news.header_news %>
</p>
<%= link_to news_path(news.id) do %>
Expand All @@ -32,30 +33,35 @@
</div>
<% end %>

<% @news.limit(4).each_with_index do |news, index| %>
<% if index == 0 %>
<%# Handle the last item separately %>
<% else %>
<% @news.length - index %>
<div class="inline-flex lg:max-w-[31%] md:max-w-[25%] sm:w-[100%] ml-2">

<div class="bg-white border border-[#FAE115] border-t-4 mt-[28px] ml-2 group">
<%= image_tag(news.image, class: "w-[300px] h-[200px]") %>
<div class="p-5">
<h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 truncate uppercase">
<%= news.type_of_news %>
</h5>
<p class="mb-3 font-normal text-gray-700 truncate ... min-w-[100px] md:w-[150px]">
<%= news.header_news %>.
</p>
<%= link_to news_path(news.id) do %>
<div class="inline-flex items-center px-3 py-2 text-sm font-semibold text-center text-black hover:text-[#FAE115] bg-[#FAE115] uppercase hover:bg-white hover:border-[#FAE115] border focus:ring-4 focus:outline-none focus:ring-blue-300">
Read More
<svg aria-hidden="true" class="w-4 h-4 ml-2 -mr-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
<div class="md:grid grid-cols-3 md:grid-cols-3 gap-5 mt-[28px] 2xl:min-w-[1024px] xl:min-w-[860px] lg:w-[650px] md:w-[500px]">

<% @news.limit(4).each_with_index do |news, index| %>
<% if index == 0 %>
<%# Handle the last item separately %>
<% else %>
<% @news.length - index %>
<div class="">

<div class="bg-white border border-[#FAE115] border-t-4 flex flex-col mt-2 hover:scale-105">
<%= image_tag(news.image, class: "h-[200px] w-full") %>
<div class="p-5">
<h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 truncate uppercase">
<%= news.type_of_news %>
</h5>
<p class="mb-3 font-normal text-gray-700 truncate ...">
<%= news.header_news %>.
</p>
<%= link_to news_path(news.id) do %>
<div class="inline-flex items-center px-3 py-2 text-sm font-semibold text-center text-black hover:text-[#FAE115] bg-[#FAE115] uppercase hover:bg-white hover:border-[#FAE115] border focus:ring-4 focus:outline-none focus:ring-blue-300">
Read More
<svg aria-hidden="true" class="w-4 h-4 ml-2 -mr-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
</div>
<% end %>
</div>
</div>
<% end %>
</div>
</div>
</div>
<% end %>
<% end %>
</div>

<% end %>
Expand All @@ -65,10 +71,11 @@
<div class="bg-white md:flex-col md:flex-row border-t-indigo-500 ">
<% @advert.limit(2).each do |advert| %>

<div class="flex flex-col md:items-end gap-5 mb-2 hidden sm:flex ">
<div class="flex flex-col md:items-end gap-5 mb-2 hidden sm:flex ">
<div class="flex flex-col lg:w-[303px] md:w-[250px] text-white bg-black">
<%= image_tag(advert.desk_image, class: "lg:max-w-[300px] md:max-w-[250px]") %>
</div>
<p>Desktop</p>
</div>
<% end %>
<% @advert.limit(1).each do |advert| %>
Expand Down
14 changes: 14 additions & 0 deletions db/migrate/20230719222935_create_memberships.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class CreateMemberships < ActiveRecord::Migration[7.0]
def change
create_table :memberships do |t|
t.string :type_of_membership
t.string :title
t.string :country
t.date :date_of_birth
t.string :email
t.integer :phone_number

t.timestamps
end
end
end
15 changes: 13 additions & 2 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions test/fixtures/memberships.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ one:
type_of_membership: MyString
title: MyString
country: MyString
date_of_birth: MyString
data_of_birth: 2023-07-20
email: MyString
phone_number: MyString
photo: MyString
phone_number: 1

two:
type_of_membership: MyString
title: MyString
country: MyString
date_of_birth: MyString
data_of_birth: 2023-07-20
email: MyString
phone_number: MyString
photo: MyString
phone_number: 1

0 comments on commit 4ebb331

Please sign in to comment.