-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into criar-mural-avisos
Co-authored-by: Lucas Oliveira <[email protected]>
- Loading branch information
Showing
54 changed files
with
856 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class BillsController < ApplicationController | ||
rescue_from Faraday::ConnectionFailed, with: :connection_refused | ||
before_action :authenticate_resident!, only: %i[index show] | ||
before_action :unit_for_current_resident | ||
before_action :request_open_bills_list, only: :index | ||
before_action :request_bill_details, only: :show | ||
before_action :set_breadcrumbs_for_action, only: %i[index show] | ||
|
||
def index; end | ||
|
||
def show; end | ||
|
||
private | ||
|
||
def unit_for_current_resident | ||
@unit = current_resident.residence | ||
end | ||
|
||
def request_open_bills_list | ||
@bills = Bill.request_open_bills(@unit.id) | ||
end | ||
|
||
def request_bill_details | ||
@bill = Bill.request_bill_details(params[:id]) | ||
|
||
redirect_to bills_path, alert: t('alerts.bill.not_found') unless @bill | ||
end | ||
|
||
def connection_refused | ||
redirect_to root_path, alert: t('alerts.bill.lost_connection') | ||
end | ||
|
||
def set_breadcrumbs_for_action | ||
add_breadcrumb I18n.t("breadcrumb.bill.#{action_name}") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
module Warnings | ||
extend ActiveSupport::Concern | ||
include WarningHelper | ||
|
||
included do | ||
before_action :warn_tower_registration_incomplete | ||
before_action :warn_resident_incomplete | ||
before_action :warn_resident_photo | ||
end | ||
|
||
private | ||
|
||
def warn_resident_photo | ||
return unless resident_signed_in? | ||
|
||
warning_message = current_resident.photo_warning_html_message | ||
flash.now[:warning] = warning_message if warning_message | ||
end | ||
|
||
def warn_tower_registration_incomplete | ||
return unless manager_signed_in? | ||
return if controller_name == 'towers' && action_name == 'edit_floor_units' | ||
|
||
generate_tower_registration_messages(current_manager.is_super? ? Condo.all : current_manager.condos) | ||
end | ||
|
||
def generate_tower_registration_messages(condos) | ||
condos.each do |condo| | ||
condo.towers.incomplete.each do |tower| | ||
flash.now[:warning] ||= '' | ||
flash.now[:warning] << tower_warning_flash_message(tower) | ||
end | ||
end | ||
end | ||
|
||
def warn_resident_incomplete | ||
return unless manager_signed_in? | ||
return if controller_name == 'owners' && action_name == 'new' | ||
|
||
generate_incomplete_resident_messages(current_manager.is_super? ? Condo.all : current_manager.condos) | ||
end | ||
|
||
def generate_incomplete_resident_messages(condos) | ||
condos.each do |condo| | ||
generate_filtered_property_registration_pendings_messages condo | ||
generate_filtered_residence_registration_pendings_messages condo | ||
end | ||
end | ||
|
||
def generate_filtered_property_registration_pendings_messages(condo) | ||
condo.filtered_property_registration_pendings.each do |resident| | ||
flash.now[:warning] ||= '' | ||
flash.now[:warning] << resident_property_registration_pending_message(resident) | ||
end | ||
end | ||
|
||
def generate_filtered_residence_registration_pendings_messages(condo) | ||
condo.filtered_residence_registration_pendings.each do |resident| | ||
flash.now[:warning] ||= '' | ||
flash.now[:warning] << resident_residence_registration_pending_message(resident) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.