Skip to content

Commit

Permalink
Merge branch 'master' into api/documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
microstudi committed Jan 31, 2020
2 parents 39fe670 + 724d29b commit e4dace9
Show file tree
Hide file tree
Showing 261 changed files with 9,291 additions and 1,118 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Expand Up @@ -23,6 +23,13 @@ Thanks to [#5342](https://github.com/decidim/decidim/pull/5342), Decidim now sup
**Added**:

- **decidim-api**: Added documentation to use the API (newcomers friendly). [\#5582](https://github.com/decidim/decidim/pull/5582)
- **decidim-blogs**: GraphQL API: Complete Blogs specification. [\#5569](https://github.com/decidim/decidim/pull/5569)
- **decidim-debates**: GraphQL API: Complete Debates specification. [\#5570](https://github.com/decidim/decidim/pull/5570)
- **decidim-surveys**: GraphQL API: Complete Surveys specification. [\#5571](https://github.com/decidim/decidim/pull/5571)
- **decidim-sortitions**: GraphQL API: Complete Sortitions specification. [\#5583](https://github.com/decidim/decidim/pull/5583)
- **decidim-accountability**: GraphQL API: Complete Accountability specification. [\#5584](https://github.com/decidim/decidim/pull/5584)
- **decidim-budgets**: GraphQL API: Complete Budgets specification. [\#5585](https://github.com/decidim/decidim/pull/5585)
- **decidim-assemblies**: GraphQL API: Create fields for assemblies types and specs. [\#5544](https://github.com/decidim/decidim/pull/5544)
- **decidim-core**: Add search and order capabilities to the GraphQL API. [\#5586](https://github.com/decidim/decidim/pull/5586)
- **documentation**: Added documentation in how Etherpad Lite integrates with the Meetings component. [\#5652](https://github.com/decidim/decidim/pull/5652)
- **decidim-meetings**: GraphQL API: Complete Meetings specification. [\#5563](https://github.com/decidim/decidim/pull/5563)
Expand Down
@@ -0,0 +1,32 @@
# frozen_string_literal: true

module Decidim
module Accountability
AccountabilityType = GraphQL::ObjectType.define do
interfaces [-> { Decidim::Core::ComponentInterface }]

name "Accountability"
description "An accountability component of a participatory space."

connection :results, ResultType.connection_type do
resolve ->(component, _args, _ctx) {
ResultTypeHelper.base_scope(component).includes(:component)
}
end

field(:result, ResultType) do
argument :id, !types.ID

resolve ->(component, args, _ctx) {
ResultTypeHelper.base_scope(component).find_by(id: args[:id])
}
end
end

module ResultTypeHelper
def self.base_scope(component)
Result.where(component: component)
end
end
end
end
@@ -0,0 +1,35 @@
# frozen_string_literal: true

module Decidim
module Accountability
ResultType = GraphQL::ObjectType.define do
interfaces [
-> { Decidim::Core::ComponentInterface },
-> { Decidim::Core::CategorizableInterface },
-> { Decidim::Comments::CommentableInterface },
-> { Decidim::Core::ScopableInterface }
]

name "Result"
description "A result"

field :id, !types.ID, "The internal ID for this result"
field :title, Decidim::Core::TranslatedFieldType, "The title for this result"
field :description, Decidim::Core::TranslatedFieldType, "The description for this result"
field :reference, types.String, "The reference for this result"
field :startDate, Decidim::Core::DateType, "The start date for this result", property: :start_date
field :endDate, Decidim::Core::DateType, "The end date for this result", property: :end_date
field :progress, types.Float, "The progress for this result"
field :createdAt, Decidim::Core::DateTimeType, "When this result was created", property: :created_at
field :updatedAt, Decidim::Core::DateTimeType, "When this result was updated", property: :updated_at
field :childrenCount, types.Int, "The number of children results", property: :children_count
field :weight, !types.Int, "The order of this result"
field :externalId, types.String, "The external ID for this result", property: :external_id

field :children, types[Decidim::Accountability::ResultType], "The childrens results"
field :parent, Decidim::Accountability::ResultType, "The parent result"
field :status, Decidim::Accountability::StatusType, "The status for this result"
field :timelineEntries, types[Decidim::Accountability::TimelineEntryType], "The timeline entries for this result", property: :timeline_entries
end
end
end
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module Decidim
module Accountability
StatusType = GraphQL::ObjectType.define do
name "Status"
description "A status"

field :id, !types.ID, "The internal ID for this status"
field :key, types.String, "The key for this status"
field :name, Decidim::Core::TranslatedFieldType, "The name for this status"
field :createdAt, Decidim::Core::DateType, "When this status was created", property: :created_at
field :updatedAt, Decidim::Core::DateType, "When this status was updated", property: :updated_at
field :description, Decidim::Core::TranslatedFieldType, "The description for this status"
field :progress, types.Int, "The progress for this status"

field :results, types[Decidim::Accountability::ResultType], "The results for this status"
end
end
end
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module Decidim
module Accountability
TimelineEntryType = GraphQL::ObjectType.define do
name "TimelineEntry"
description "A Timeline Entry"

field :id, !types.ID, "The internal ID for this timeline entry"
field :entryDate, Decidim::Core::DateType, "The entry date for this timeline entry", property: :entry_date
field :description, Decidim::Core::TranslatedFieldType, "The description for this timeline entry"
field :createdAt, Decidim::Core::DateTimeType, "When this timeline entry was created", property: :created_at
field :updatedAt, Decidim::Core::DateTimeType, "When this timeline entry was updated", property: :updated_at

field :result, Decidim::Accountability::ResultType, "The result for this timeline entry"
end
end
end
1 change: 1 addition & 0 deletions decidim-accountability/config/locales/el-GR.yml
@@ -0,0 +1 @@
el:
197 changes: 197 additions & 0 deletions decidim-accountability/config/locales/is-IS.yml
@@ -0,0 +1,197 @@
is-IS:
activemodel:
attributes:
result:
decidim_accountability_status_id: Staða
decidim_category_id: Flokkur
decidim_scope_id: Umfang
description: Lýsing
end_date: Loka dagsetning
progress: Framfarir
project_ids: Innifalið verkefni
proposals: Innifalið tillögur
start_date: Upphafsdagur
title: Titill
updated_at: Uppfært á
status:
description: Lýsing
key: Lykill
name: Nafn
progress: Framfarir
timeline_entry:
description: Lýsing
entry_date: Dagsetning
decidim:
accountability:
actions:
confirm_destroy: Ertu viss um að þú viljir eyða þessu %{name}?
destroy: Eyða
edit: Breyta
new: Nýtt %{name}
preview: Preview
timeline_entries: Verkefnisþróun
title: Aðgerðir
admin:
exports:
results: Niðurstöður
models:
result:
name: Niðurstaða
status:
name: Staða
timeline_entry:
name: Tímalína færsla
results:
create:
success: Niðurstaða búin til
destroy:
success: Niðurstaða tókst að eyða
edit:
title: Breyta niðurstöðum
update: Uppfæra niðurstöðu
form:
add_proposal: Bæta við tillögu
index:
title: Niðurstöður
new:
create: Búa til niðurstöðu
title: Nýtt niðurstaða
proposals:
close: Loka
current_selection: Núverandi val
select: Veldu
update:
success: Niðurstaða tókst að uppfæra
shared:
subnav:
statuses: Staða
statuses:
create:
success: Staða búin til
destroy:
success: Staða var eytt
edit:
title: Breyta stöðu
update: Uppfæra stöðu
index:
title: Staða
new:
create: Búa til stöðu
title: Ný staða
update:
success: Staða uppfærður með góðum árangri
timeline_entries:
create:
success: Uppfærsla búin til með góðum árangri
destroy:
success: Innslátt tókst eytt
edit:
title: Breyta færslu
update: Uppfæra færslu
index:
title: Verkefni tímalína færslur
new:
create: Búðu til færslu
title: Ný færsla
update:
success: Uppfærsla uppfærð með góðum árangri
admin_log:
result:
create: "%{user_name} búið til afleiðing %{resource_name} í %{space_name}"
delete: "%{user_name} eytt %{resource_name} niðurstöðu í %{space_name}"
update: "%{user_name} uppfært niðurstaða %{resource_name} í %{space_name}"
value_types:
parent_presenter:
not_found: 'Móðirin fannst ekki í gagnagrunninum (ID: %{id})'
models:
result:
fields:
end_date: Loka dagsetning
progress: Framfarir
start_date: Upphafsdagur
status: Staða
title: Titill
status:
fields:
description: Lýsing
key: Lykill
name: Nafn
progress: Framfarir
timeline_entry:
fields:
description: Lýsing
entry_date: Dagsetning
results:
count:
results_count:
one: 1 niðurstaða
other: "%{count} niðurstöður"
filters:
all: Allt
scopes: Scopes
home:
categories_label: Flokkar
subcategories_label: Undirflokka
home_header:
global_status: Global framkvæmdastaða
nav_breadcrumb:
global: Global framkvæmd
search:
search: Leitaðu að aðgerðum
show:
stats:
attendees: Dómarar
back_to_result: Fara aftur til niðurstöðu
comments: Athugasemdir
contributions: Framlög
last_edited_by: Síðast breytt af
last_updated_at: Síðast uppfært á
meetings: Fundir
number_of_versions: Útgáfur
proposals: Tillögur
show_all_versions: Sýna allar útgáfur
version_author: Útgáfa höfundur
version_created_at: Útgáfa búin til á
version_number: Útgáfa númer
version_number_out_of_total: "%{current_version} af %{total_count}"
votes: Styður
timeline:
title: Verkefnisþróun
versions:
index:
changes_at_title: Breytingar á "%{title}"
title: Útgáfur
show:
changes_at_title: Breytingar á "%{title}"
version:
version_index: Útgáfa %{index}
components:
accountability:
name: Ábyrgð
settings:
global:
categories_label: Nafn fyrir "Flokkar"
comments_enabled: Athugasemdir virkt
display_progress_enabled: Sýna framfarir
heading_leaf_level_results: Nafn fyrir "Verkefni"
heading_parent_level_results: Nafn fyrir "Úrslit"
intro: Intro
subcategories_label: Nafn fyrir "undirflokka"
step:
comments_blocked: Athugasemdir læst
events:
accountability:
proposal_linked:
email_intro: 'Tillagan "%{proposal_title}" hefur verið hluti af niðurstöðu. Þú getur séð það frá þessari síðu:'
email_outro: Þú hefur fengið þessa tilkynningu vegna þess að þú fylgist með "%{proposal_title}". Þú getur hætt við að fá tilkynningar eftir fyrri tengilinn.
email_subject: Uppfærsla á %{proposal_title}
notification_title: Tillagan <a href="%{proposal_path}">%{proposal_title}</a> hefur verið innifalinn í <a href="%{resource_path}">%{resource_title}</a> niðurstöðum.
participatory_processes:
participatory_process_groups:
highlighted_results:
results: Niðurstöður
resource_links:
included_projects:
result_project: Verkefni í þessari niðurstöðu
included_proposals:
result_proposal: Tillögur innifalnar í þessari niðurstöðu
Expand Up @@ -8,6 +8,7 @@
component.icon = "decidim/accountability/icon.svg"
component.stylesheet = "decidim/accountability/accountability"
component.permissions_class_name = "Decidim::Accountability::Permissions"
component.query_type = "Decidim::Accountability::AccountabilityType"

component.on(:before_destroy) do |instance|
raise StandardError, "Can't remove this component" if Decidim::Accountability::Result.where(component: instance).any?
Expand Down
50 changes: 50 additions & 0 deletions decidim-accountability/spec/types/accountability_type_spec.rb
@@ -0,0 +1,50 @@
# frozen_string_literal: true

require "spec_helper"
require "decidim/api/test/type_context"
require "decidim/core/test"

module Decidim
module Accountability
describe AccountabilityType, type: :graphql do
include_context "with a graphql type"
let(:model) { create(:accountability_component) }

it_behaves_like "a component query type"

describe "results" do
let!(:component_results) { create_list(:result, 2, component: model) }
let!(:other_results) { create_list(:result, 2) }

let(:query) { "{ results { edges { node { id } } } }" }

it "returns the published results" do
ids = response["results"]["edges"].map { |edge| edge["node"]["id"] }
expect(ids).to include(*component_results.map(&:id).map(&:to_s))
expect(ids).not_to include(*other_results.map(&:id).map(&:to_s))
end
end

describe "result" do
let(:query) { "query Result($id: ID!){ result(id: $id) { id } }" }
let(:variables) { { id: result.id.to_s } }

context "when the result belongs to the component" do
let!(:result) { create(:result, component: model) }

it "finds the result" do
expect(response["result"]["id"]).to eq(result.id.to_s)
end
end

context "when the result doesn't belong to the component" do
let!(:result) { create(:result, component: create(:accountability_component)) }

it "returns null" do
expect(response["result"]).to be_nil
end
end
end
end
end
end

0 comments on commit e4dace9

Please sign in to comment.