Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fazer a home page de usuários logados não exibir mais os eventos #146

Merged
merged 5 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/announcements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class AnnouncementsController < ApplicationController
before_action :check_if_event_manager, only: [ :create ]

add_breadcrumb "Home", :dashboard_path
add_breadcrumb "Meus Eventos", :events_path


def index
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ class EventsController < ApplicationController
before_action :check_event_status, only: [ :update ]
before_action :check_if_event_manager, only: [ :new, :create ]
add_breadcrumb "Home", :dashboard_path
add_breadcrumb "Meus Eventos", :events_path

def index
@events = current_user.events
end

def new
@event = Event.new
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/feedbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ class FeedbacksController < ApplicationController
before_action :authenticate_user!
before_action :authorize_event_access
before_action :check_if_event_ended
add_breadcrumb "Home", :dashboard_path
add_breadcrumb "Meus Eventos", :events_path

def index
@feedbacks = @event.feedbacks

add_breadcrumb "#{@event.name}", Proc.new { event_path(@event) }
add_breadcrumb "Feedbacks"
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/schedule_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ScheduleItemsController < ApplicationController
before_action :authorize_schedule_owner, only: [ :new, :create, :destroy, :edit, :update ]
before_action :find_schedule_item, only: [ :edit, :update, :destroy ]
add_breadcrumb "Home", :dashboard_path

add_breadcrumb "Meus Eventos", :events_path

def new
@schedule_item = @schedule.schedule_items.build
Expand Down
1 change: 1 addition & 0 deletions app/controllers/schedules_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class SchedulesController < ApplicationController
before_action :authorize_schedule_access, only: [ :show ]
before_action :find_event, only: [ :show ]
add_breadcrumb "Home", :dashboard_path
add_breadcrumb "Meus Eventos", :events_path

def show
@schedule = Schedule.find_by(id: params[:id])
Expand Down
1 change: 1 addition & 0 deletions app/controllers/ticket_batches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class TicketBatchesController < ApplicationController
before_action :authorize_event_access
before_action :set_ticket_batch, only: [ :edit, :update ]
add_breadcrumb "Home", :dashboard_path
add_breadcrumb "Meus Eventos", :events_path

def index
@ticket_batches = @event.ticket_batches
Expand Down
1 change: 0 additions & 1 deletion app/controllers/verifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class VerificationsController < ApplicationController
before_action :authorize_verification_access, only: [ :show ]
add_breadcrumb "Home", :dashboard_path


def index
@verifications = current_user.verifications.order(created_at: :desc) if current_user.role == "event_manager"
@verifications = Verification.pending.order(created_at: :desc) if current_user.role == "admin"
Expand Down
51 changes: 4 additions & 47 deletions app/views/dashboard/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,48 +1,5 @@
<% if current_user.role == "event_manager"%>
<div class="bg-white p-10 shadow-md rounded">
<div class="flex justify-between items-center">
<h1>Meus Eventos</h1>

<%= link_to 'Criar Evento', new_event_path, class: 'form_button w-fit'%>
</div>

<div class="mt-4">
<% if @events.any? %>
<table class="w-full text-left table-auto">
<thead>
<tr>
<th class="px-4 py-2 border-b border-blue-gray-500">Nome</th>
<th class="px-4 py-2 border-b border-blue-gray-500">Status</th>
<th class="px-4 py-2 border-b border-blue-gray-500">Limite de participantes</th>
<th class="px-4 py-2 border-b border-blue-gray-500">Quando</th>
<th class="px-4 py-2 border-b border-blue-gray-500"></th>
</tr>
</thead>
<tbody>
<% @events.each do |e| %>
<tr class="even:bg-gray-100">
<td class="px-4 py-2 border-b border-blue-gray-100"><%= e.name %></td>
<td class="px-4 py-2 border-b border-blue-gray-100">
<p class="<%=e.status == 'published' ? "text-success font-medium" : "text-warning font-medium" %>"><%= Event.human_enum_name(:status, e.status) %></p>
</td>
<td class="px-4 py-2 border-b border-blue-gray-100"><%= e.participants_limit%></td>
<td class="px-4 py-2 border-b border-blue-gray-100"><%= l(e.start_date.to_date)%></td>
<td class="px-4 py-2 border-b border-blue-gray-100">
<div class="flex gap-4 items-center justify-end">
<%= link_to 'Gerenciar', event_path(e), class: 'outline_button', test_id: "manage-#{e.id}" %>
<%= button_to event_path(e), method: :delete, class: 'danger_button', data: { turbo_method: :delete, turbo_confirm: "Tem certeza que deseja deletar o evento:\n#{e.name}", test_id: "delete-#{e.id}" } do %>
<img src="<%= asset_path('bin.svg')%>" class="h-6 w-6"/>
<% end %>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>

<% else %>
<p>Você não possui eventos cadastrados.</p>
<% end %>
</div>
</div>
<% if current_user.event_manager? %>
<p>Dashboard Manager</p>
<% elsif current_user.admin? %>
<p>Dashboard Admin</p>
<% end %>
45 changes: 45 additions & 0 deletions app/views/events/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<div class="bg-white p-10 shadow-md rounded">
<div class="flex justify-between items-center">
<h1>Meus Eventos</h1>

<%= link_to 'Criar Evento', new_event_path, class: 'form_button w-fit'%>
</div>

<div class="mt-4">
<% if @events.any? %>
<table class="w-full text-left table-auto">
<thead>
<tr>
<th class="px-4 py-2 border-b border-blue-gray-500">Nome</th>
<th class="px-4 py-2 border-b border-blue-gray-500">Status</th>
<th class="px-4 py-2 border-b border-blue-gray-500">Limite de participantes</th>
<th class="px-4 py-2 border-b border-blue-gray-500">Quando</th>
<th class="px-4 py-2 border-b border-blue-gray-500"></th>
</tr>
</thead>
<tbody>
<% @events.each do |e| %>
<tr class="even:bg-gray-100">
<td class="px-4 py-2 border-b border-blue-gray-100"><%= e.name %></td>
<td class="px-4 py-2 border-b border-blue-gray-100">
<p class="<%=e.status == 'published' ? "text-success font-medium" : "text-warning font-medium" %>"><%= Event.human_enum_name(:status, e.status) %></p>
</td>
<td class="px-4 py-2 border-b border-blue-gray-100"><%= e.participants_limit%></td>
<td class="px-4 py-2 border-b border-blue-gray-100"><%= l(e.start_date.to_date)%></td>
<td class="px-4 py-2 border-b border-blue-gray-100">
<div class="flex gap-4 items-center justify-end">
<%= link_to 'Gerenciar', event_path(e), class: 'outline_button', test_id: "manage-#{e.id}" %>
<%= button_to event_path(e), method: :delete, class: 'danger_button', data: { turbo_method: :delete, turbo_confirm: "Tem certeza que deseja deletar o evento:\n#{e.name}", test_id: "delete-#{e.id}" } do %>
<img src="<%= asset_path('bin.svg')%>" class="h-6 w-6"/>
<% end %>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p>Você não possui eventos cadastrados.</p>
<% end %>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/shared/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<%= link_to 'Verificações', verifications_path, class: controller_name == 'verifications' ? 'nav_link_active' : 'nav_link_inactive' %>

<% elsif current_user.role == "event_manager" %>
<%= link_to 'Eventos', dashboard_path, class: ['verifications', 'event_places', 'event_place_recommendations'].exclude?(controller_name) ? 'nav_link_active' : 'nav_link_inactive' %>
<%= link_to 'Meus Eventos', events_path, class: ['verifications', 'event_places', 'event_place_recommendations', 'dashboard'].exclude?(controller_name) ? 'nav_link_active' : 'nav_link_inactive' %>
<span class="link_separator"></span>
<%= link_to 'Meus Locais', event_places_path, class: controller_name == 'event_places' ? 'nav_link_active' : 'nav_link_inactive' %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

root "home#index"

resources :events, only: [ :new, :edit, :create, :update, :destroy, :show ] do
resources :events, only: [ :new, :edit, :create, :update, :destroy, :show, :index ] do
patch :publish, on: :member

resources :ticket_batches, only: [ :index, :new, :create, :edit, :update ]
Expand Down
6 changes: 6 additions & 0 deletions spec/system/announcement/user_create_annoucement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

login_as event_manager
visit root_path
within "nav#navbar" do
click_on 'Meus Eventos'
end
click_on 'Gerenciar'
click_on 'Comunicados'
fill_in 'announcement[title]', with: 'Palestra x foi cancelada'
Expand All @@ -24,6 +27,9 @@

login_as event_manager
visit root_path
within "nav#navbar" do
click_on 'Meus Eventos'
end
click_on 'Gerenciar'
click_on 'Comunicados'
click_on 'Enviar'
Expand Down
12 changes: 9 additions & 3 deletions spec/system/announcement/user_view_announcement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

login_as event_manager
visit root_path

within "nav#navbar" do
click_on 'Meus Eventos'
end
click_on 'Gerenciar'
click_on 'Comunicados'

Expand All @@ -36,7 +38,9 @@

login_as event_manager
visit root_path

within "nav#navbar" do
click_on 'Meus Eventos'
end
click_on 'Gerenciar'
click_on 'Comunicados'

Expand All @@ -57,7 +61,9 @@

login_as event_manager
visit root_path

within "nav#navbar" do
click_on 'Meus Eventos'
end
click_on 'Gerenciar'
click_on 'Comunicados'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
expect(current_path).to eq event_announcements_path(event)
within "#breadcrumbs" do
expect(page).to have_link "Home"
expect(page).to have_link "Meus Eventos"
expect(page).to have_link "#{event.name}"
expect(page).to have_content "Comunicados"
end
Expand Down
4 changes: 4 additions & 0 deletions spec/system/breadcrumbs/user_views_events_breadcrumbs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
expect(current_path).to eq new_event_path
within "#breadcrumbs" do
expect(page).to have_link "Home"
expect(page).to have_link "Meus Eventos"
expect(page).to have_content "Cadastro de Evento"
end
end
Expand All @@ -24,6 +25,7 @@
expect(current_path).to eq event_path(event)
within "#breadcrumbs" do
expect(page).to have_link "Home"
expect(page).to have_link "Meus Eventos"
expect(page).to have_content "#{event.name}"
end
end
Expand All @@ -38,6 +40,7 @@
expect(current_path).to eq edit_event_path(event)
within "#breadcrumbs" do
expect(page).to have_link "Home"
expect(page).to have_link "Meus Eventos"
expect(page).to have_link "#{event.name}"
expect(page).to have_content "Editar Evento"
end
Expand All @@ -54,6 +57,7 @@
expect(current_path).to eq history_events_path
within "#breadcrumbs" do
expect(page).to have_link "Home"
expect(page).to have_link "Meus Eventos"
expect(page).to have_content "Histórico de eventos"
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
expect(current_path).to eq event_schedule_path(schedule.event, schedule)
within "#breadcrumbs" do
expect(page).to have_link "Home"
expect(page).to have_link "Meus Eventos"
expect(page).to have_link "#{event.name}"
expect(page).to have_content "Agenda de #{I18n.l(schedule.date.to_date, format: :short)}"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
expect(current_path).to eq event_ticket_batches_path(ticket_batch.event)
within "#breadcrumbs" do
expect(page).to have_link "Home"
expect(page).to have_link "Meus Eventos"
expect(page).to have_link "#{event.name}"
expect(page).to have_content "Lotes de Ingresso - Evento #{event.name}"
end
end
Expand All @@ -27,7 +29,8 @@
expect(current_path).to eq new_event_ticket_batch_path(ticket_batch.event)
within "#breadcrumbs" do
expect(page).to have_link "Home"
expect(page).to have_link "Evento #{event.name}"
expect(page).to have_link "Meus Eventos"
expect(page).to have_link "#{event.name}"
expect(page).to have_link "Lotes de Ingresso - Evento #{event.name}"
expect(page).to have_content "Criar Lote"
end
Expand All @@ -44,6 +47,7 @@
expect(current_path).to eq edit_event_ticket_batch_path(ticket_batch.event, ticket_batch)
within "#breadcrumbs" do
expect(page).to have_link "Home"
expect(page).to have_link "Meus Eventos"
expect(page).to have_link "Evento #{event.name}"
expect(page).to have_link "Lotes de Ingresso - Evento #{event.name}"
expect(page).to have_content "Editar Lote"
Expand Down
4 changes: 2 additions & 2 deletions spec/system/events/user_deletes_event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
create(:event, name: 'CCXP', user: user, categories: [ category ])

login_as user
visit root_path
visit events_path
find("button[data-test-id='delete-#{event1.id}']").click

expect(page).to have_content 'Evento deletado com sucesso'
Expand All @@ -22,7 +22,7 @@
create(:event, name: 'CCXP', user: user, categories: [ category ])

login_as user
visit root_path
visit events_path
find("a[test_id='manage-#{event_to_be_deleted.id}']").click
click_on 'Excluir'

Expand Down
9 changes: 9 additions & 0 deletions spec/system/events/user_edit_event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

login_as user
visit root_path
within "nav#navbar" do
click_on 'Meus Eventos'
end
click_on 'Gerenciar'
click_on 'Editar'
fill_in 'Nome', with: 'Rails Brasil'
Expand All @@ -26,6 +29,9 @@

login_as user
visit root_path
within "nav#navbar" do
click_on 'Meus Eventos'
end
click_on 'Gerenciar'
click_on 'Editar'
fill_in 'Nome', with: ''
Expand All @@ -44,6 +50,9 @@

login_as user
visit root_path
within "nav#navbar" do
click_on 'Meus Eventos'
end
click_on 'Gerenciar'
click_on 'Editar'
fill_in 'Nome', with: 'Rails Brasil'
Expand Down
6 changes: 3 additions & 3 deletions spec/system/events/user_view_events_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
create(:event, name: 'Introdução ao RoR', user: user, categories: [ category ])

login_as user
visit root_path
visit events_path

expect(page).to have_content 'ccxp'
expect(page).to have_content 'Introdução ao RoR'
Expand All @@ -20,7 +20,7 @@
create(:event, name: 'ccxp', status: :published, user: user, categories: [ category ])
create(:event, name: 'Introdução ao RoR', user: user, categories: [ category ])

visit root_path
visit events_path

expect(page).not_to have_content 'Introdução ao RoR'
end
Expand All @@ -33,7 +33,7 @@
create(:event, name: 'Introdução ao RoR', user: marcelo, categories: [ category ])

login_as marcelo
visit root_path
visit events_path

expect(page).not_to have_content 'ccxp'
expect(page).to have_content 'Introdução ao RoR'
Expand Down
Loading