Skip to content

Commit

Permalink
Revert "Merge branch '349-person-page-amiedes'"
Browse files Browse the repository at this point in the history
This reverts commit 1fc03c2, reversing
changes made to 383dd58.
  • Loading branch information
amiedes committed Jun 22, 2018
1 parent 1fc03c2 commit e52ff05
Show file tree
Hide file tree
Showing 27 changed files with 40 additions and 262 deletions.
12 changes: 3 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ jobs:
RAILS_ENV: test
PGHOST: localhost
PGUSER: gobierto
# Disable spring so bin/rails works. See: https://github.com/rails/spring/pull/546
DISABLE_SPRING: true
- image: postgres:9.6
environment:
POSTGRES_USER: gobierto
Expand Down Expand Up @@ -71,14 +69,10 @@ jobs:
- run: cp .env.example .env

# Setup the database
- run: bin/rails db:setup
- run: bundle exec rake db:setup

# Run tests
- run: script/test

# Run tests from custom engines
- run: script/custom_engines_ci_setup
- run: bin/rails test vendor/gobierto_engines/**/test
- run: script/ci_test

staging-deploy:
machine:
Expand Down Expand Up @@ -120,4 +114,4 @@ workflows:
- build
filters:
branches:
only: master
only: master
17 changes: 4 additions & 13 deletions app/controllers/gobierto_people/api/v1/departments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ module V1
class DepartmentsController < Api::V1::BaseController

def index
top_departments = DepartmentsQuery.new(
query = DepartmentsQuery.new(
relation: Department.where(site: current_site),
conditions: permitted_conditions,
limit: params[:limit]
).results
)

if params[:include_history] == "true"
records = DepartmentsQuery.new(
relation: Department.where(id: top_departments.map(&:id)),
relation: Department.where(id: query.results.map(&:id)),
conditions: permitted_conditions
).results_with_history

Expand All @@ -34,19 +34,10 @@ def index
}
end
end

# sort result according to department events count
departments_order = Hash[
*top_departments.pluck(:name).each_with_index.collect do |department_name, index|
[department_name, index]
end.flatten
]
result.sort! { |x, y| departments_order[x[:key]] <=> departments_order[y[:key]] }

render json: result
else

render json: top_departments, each_serializer: RowchartItemSerializer
render json: query.results, each_serializer: RowchartItemSerializer
end
end

Expand Down
8 changes: 0 additions & 8 deletions app/controllers/gobierto_people/api/v1/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ def index
end
end

# sort result according to person events count
people_order = Hash[
*top_people.pluck(:name).each_with_index.collect do |person_name, index|
[person_name, index]
end.flatten
]
result.sort! { |x, y| people_order[x[:key]] <=> people_order[y[:key]] }

render json: result
else
render json: top_people, each_serializer: RowchartItemSerializer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module GobiertoPeople
module People
class PastPersonEventsController < People::PersonEventsController
Expand All @@ -8,25 +6,16 @@ def index
if params[:date]
@filtering_date = Date.parse(params[:date])
@events = @person.events.by_date(@filtering_date).sorted.page params[:page]
elsif params[:page] == "false"
# permit non-pagination and avoid N+1 queries for custom engines
@events = @person.events.past.sorted_backwards.includes(:interest_group)
else
@events = @person.events.past.sorted.page params[:page]
end

respond_to do |format|
format.js { render "#{views_path}index" }
format.html { render "#{views_path}index" }
format.js { render 'gobierto_people/people/person_events/index' }
format.html
end
end

private

def views_path
"gobierto_people/people/person_events/"
end

end
end
end
4 changes: 1 addition & 3 deletions app/controllers/gobierto_people/people/trips_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
module GobiertoPeople
module People
class TripsController < BaseController

def index
@person_trips = CollectionDecorator.new(@person.trips, decorator: TripDecorator)
@person_trips = @person.trips
end

def show
@trip = @person.trips.find(params[:id])
end

end
end
end
8 changes: 0 additions & 8 deletions app/controllers/gobierto_people/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ class PeopleController < GobiertoPeople::ApplicationController

before_action :check_active_submodules, except: :show

LAST_ITEMS_SIZE = 4

def index
@political_groups = get_political_groups

Expand Down Expand Up @@ -45,12 +43,6 @@ def show

@upcoming_events = @person.attending_events.upcoming.sorted.first(3)
@latest_activity = ActivityCollectionDecorator.new(Activity.for_recipient(@person).limit(30).sorted.page(params[:page]))

# custom engine
@last_events = @person.attending_events.with_interest_group.sorted_backwards.limit(LAST_ITEMS_SIZE)
@last_trips = @person.trips.sorted.limit(LAST_ITEMS_SIZE)
@last_invitations = @person.invitations.sorted.limit(LAST_ITEMS_SIZE)
@last_gifts = @person.received_gifts.sorted.limit(LAST_ITEMS_SIZE)
end

private
Expand Down
8 changes: 0 additions & 8 deletions app/decorators/gobierto_people/person_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ def has_statements?
statements.active.any?
end

def meetings_with_interest_groups
events.with_interest_group
end

def interest_groups_count
meetings_with_interest_groups.select(:interest_group_id).distinct.count
end

private

def person_contact_method_for(service_name, attribute_name)
Expand Down
24 changes: 0 additions & 24 deletions app/decorators/gobierto_people/trip_decorator.rb

This file was deleted.

15 changes: 0 additions & 15 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,6 @@ def whom(entity_name)
end
end

def meaningful_date_range?(date_range, options = {})
return false unless date_range.is_a?(Array)

date_range.map! { |d| d.change(hour: 0, min: 0, sec: 0) } if options[:only_date]
date_range.first != date_range.last
end

def simple_pluralize(count, singular, plural)
if count == 1 || count =~ /^1(\.0+)?$/
singular
else
plural
end
end

private

def parse_max_length(params)
Expand Down
4 changes: 0 additions & 4 deletions app/models/concerns/gobierto_common/url_buildable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ def to_url(options = {})
)
end

def to_anchor
"#{model_name.human.downcase}-#{id}"
end

private

def parameterize
Expand Down
5 changes: 4 additions & 1 deletion app/models/gobierto_people/gift.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module GobiertoPeople
class Gift < ApplicationRecord

include GobiertoCommon::Metadatable
include GobiertoCommon::UrlBuildable

belongs_to :person
belongs_to :department
Expand All @@ -23,5 +22,9 @@ def parameterize
{ person_slug: person.slug, id: id }
end

def to_path
url_helpers.gobierto_people_person_gift_path(parameterize)
end

end
end
11 changes: 5 additions & 6 deletions app/models/gobierto_people/invitation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module GobiertoPeople
class Invitation < ApplicationRecord

include GobiertoCommon::Metadatable
include GobiertoCommon::UrlBuildable

belongs_to :person
belongs_to :department
Expand All @@ -17,15 +16,15 @@ class Invitation < ApplicationRecord

validates :person, :organizer, :title, :start_date, :end_date, presence: true

metadata_attributes(
:organic_unit,
:expenses_financed_by_organizer,
:original_destinations_attribute
)
metadata_attributes :organic_unit, :expenses_financed_by_organizer

def parameterize
{ person_slug: person.slug, id: id }
end

def to_path
url_helpers.gobierto_people_person_invitation_path(parameterize)
end

end
end
29 changes: 2 additions & 27 deletions app/models/gobierto_people/trip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ module GobiertoPeople
class Trip < ApplicationRecord

include GobiertoCommon::Metadatable
include GobiertoCommon::UrlBuildable

belongs_to :person
belongs_to :department

scope :sorted, -> { order(start_date: :desc) }

validates :person, :title, :start_date, :end_date, presence: true

metadata_attributes(
Expand All @@ -21,35 +18,13 @@ class Trip < ApplicationRecord
:transport_expenses,
:other_expenses,
:total_expenses,
:company,
:comments,
:original_destinations_attribute,
:purpose
:trip_party,
:comments
)

def destinations
destinations_meta["destinations"] if destinations_meta
end

def duration_dates
[start_date, end_date]
end

def expenses
[
{ kind: meta_attribute_translation(:food_expenses), amount: food_expenses },
{ kind: meta_attribute_translation(:accomodation_expenses), amount: accomodation_expenses },
{ kind: meta_attribute_translation(:transport_expenses), amount: transport_expenses },
{ kind: meta_attribute_translation(:other_expenses), amount: other_expenses },
{ kind: meta_attribute_translation(:total_expenses), amount: total_expenses }
].reject { |expense| expense[:amount].to_i.zero? }
end

private

def meta_attribute_translation(attribute)
I18n.t "activerecord.attributes.gobierto_people/#{model_name.human.downcase}.#{attribute}"
end

end
end
7 changes: 0 additions & 7 deletions config/locales/gobierto_people/models/ca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ ca:
models:
gobierto_people/person_message: Missatge
activerecord:
attributes:
gobierto_people/trip:
accomodation_expenses: Hotels i allotjament
food_expenses: Dietes i manutenció
other_expenses: Altres despeses
total_expenses: Despeses totals
transport_expenses: Transport
models:
gobierto_people/person: Càrrec
gobierto_people/person_post: Post
Expand Down
7 changes: 0 additions & 7 deletions config/locales/gobierto_people/models/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ en:
models:
gobierto_people/person_message: Message
activerecord:
attributes:
gobierto_people/trip:
accomodation_expenses: Accomodation expenses
food_expenses: Food expenses
other_expenses: Other expenses
total_expenses: Total expenses
transport_expenses: Transport
models:
gobierto_people/person: Officer
gobierto_people/person_post: Post
Expand Down
7 changes: 0 additions & 7 deletions config/locales/gobierto_people/models/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ es:
models:
gobierto_people/person_message: Mensaje
activerecord:
attributes:
gobierto_people/trip:
accomodation_expenses: Hoteles y alojamiento
food_expenses: Dietas y manutención
other_expenses: Otros gastos
total_expenses: Gastos totales
transport_expenses: Transporte
models:
gobierto_people/person: Cargo
gobierto_people/person_post: Post
Expand Down
9 changes: 9 additions & 0 deletions script/ci_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

# bin/rails does not work because of CircleCI Docker containerization
bundle exec rails gobierto_budgets:elastic_search_schemas:manage:reset
bundle exec rails gobierto_budgets:elastic_search_schemas:manage:create
bundle exec rails gobierto_budgets:fixtures:load

# bundle exec rails does not work in CircleCI
bundle exec rake test test/models
7 changes: 0 additions & 7 deletions script/custom_engines_ci_setup

This file was deleted.

Loading

0 comments on commit e52ff05

Please sign in to comment.