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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add content pages #190
Add content pages #190
Conversation
@@ -0,0 +1,27 @@ | |||
# frozen_string_literal: true | |||
module Decidim | |||
class PageFinder < HighVoltage::PageFinder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing top-level class documentation comment.
@@ -0,0 +1,6 @@ | |||
# frozen_string_literal: true | |||
module Decidim | |||
class Page < ApplicationRecord |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing top-level class documentation comment.
# frozen_string_literal: true | ||
module Decidim | ||
module Admin | ||
class PageForm < Rectify::Form |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing top-level class documentation comment.
cdc3149
to
d577d80
Compare
Current coverage is 97.60% (diff: 0.00%)@@ master #190 diff @@
==========================================
Files 246 263 +17
Lines 3794 4293 +499
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 3694 4190 +496
- Misses 100 103 +3
Partials 0 0
|
32bd3b0
to
7f5b453
Compare
# Returns nothing. | ||
def call | ||
Decidim::Page::DEFAULT_PAGES.map do |slug| | ||
Decidim::Page.create!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you should do this in an idempotent way? So if the page already exists it doesn't blow up.
end | ||
end | ||
|
||
def localized_attribute(attribute) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
localized_attribute
is duplicated in https://github.com/AjuntamentdeBarcelona/decidim/pull/190/files#diff-9d9bec53e0e6a2b136da17b1ab2119a3R33 . Maybe we should extract this into a module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to temove the code from RegisterOrganization
, it shouldn't be there.
@@ -26,6 +26,10 @@ ca: | |||
update: | |||
error: S'ha produ茂t un error en actualitzar aquest administrador.. | |||
success: Administrador actualitzat correctament | |||
default_pages: | |||
placeholders: | |||
content: Si us plau, afegir contingut significatiu a aquesta p脿gina afegir el panell de control de l'administrador. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammar nazi: "Si us plau, afegeix contingut significatiu a aquesta p脿gina des del panell d'administraci贸."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was auto-translated, it wasn't review it yet 馃槢
@@ -26,6 +26,10 @@ en: | |||
update: | |||
error: There was an error when updating this admin. | |||
success: Admin updated successfully | |||
default_pages: | |||
placeholders: | |||
content: Please add meaningful content to this page add the admin dashboard. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"at the" o "on the"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOL I actually wrote add
xD
@@ -26,6 +26,10 @@ es: | |||
update: | |||
error: Se ha producido un error al actualizar este administrador .. | |||
success: Administrador actualizado correctamente | |||
default_pages: | |||
placeholders: | |||
content: Por favor, a帽adir contenido significativo a esta p谩gina a帽adir el panel de control del administrador. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Por favor, a帽ade contenido significativo..."
6b8786a
to
46ded59
Compare
# frozen_string_literal: true | ||
module Decidim | ||
module Admin | ||
# A command with all the business logic when creating a new participatory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/creating/updating/
@form = form | ||
end | ||
|
||
# Executes the command. Braodcasts these events: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Braodcasts/Broadcasts/
actions: | ||
view: Visualitzar la p脿gina p煤blica | ||
create: | ||
error: Error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing i18n
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, you can remove these keys and wait until #225 is merged and add these translations via Crowdin.
actions: | ||
view: Ver la p谩gina p煤blica | ||
create: | ||
error: Error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with the Catalan translation
class CreateDecidimStaticPages < ActiveRecord::Migration[5.0] | ||
def change | ||
create_table :decidim_static_pages do |t| | ||
t.hstore :title, null: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use jsonb
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The display_for
helper depends on the column being hstore
. I'd create another issue to migrate existing hstore columns to jsonb and then update the helper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created an issue to fix this: https://github.com/AjuntamentdeBarcelona/decidim/issues/228
create_table :decidim_static_pages do |t| | ||
t.hstore :title, null: false | ||
t.string :slug, null: false | ||
t.hstore :content, null: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jsonb
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
Code Climate is complaining about the TODO at the Readme. Since the TODO refers to documenting the particpatory process dashboard at the admin, it's outisde the scope of this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Check my comments to see if you agree with me - I consider this mergeable in its current state. Anyway, good work.
Short description and motivation. | ||
|
||
This library adds and administration dashboard so users can manage their | ||
organization, particpatory processes and all other entities. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Learn to write
# | ||
class StaticPagesController < ApplicationController | ||
def index | ||
authorize! :index, Decidim::StaticPage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Decidim
is redundant here. Applies to all other controllers as well (outside of the scope of this PR)
@@ -14,6 +14,10 @@ def initialize(user) | |||
can :manage, ParticipatoryProcess | |||
can :manage, ParticipatoryProcessStep | |||
can :manage, ParticipatoryProcessUserRole | |||
can [:create, :update, :index, :new, :read], StaticPage | |||
can [:update_slug, :destroy], [StaticPage, StaticPageForm] do |page| | |||
!StaticPage.default?(page.slug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nais
<% end %> | ||
|
||
<div class="field"> | ||
<%= form.translated :text_area, :content %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to change this when https://github.com/AjuntamentdeBarcelona/decidim/pull/227 is merged (NO HURRIES @beagleknight)
# to render. We need this because we allow rendering pages with content from | ||
# the database (with Decidim::Page) but also fallback to a template if it | ||
# exists. | ||
class PageFinder < HighVoltage::PageFinder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you entirely sure using HighVoltage
is justified? In the end, it only ends up doing something like render template: "pages/#{page_name}"
in the controller.
We're including a dependency that doesn't add much value and that can lead to issues in the future (being locked to a Rails version, for example).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HighVoltage was already in the project, if we want to discuss the need about it we can do it in another issue/PR.
factory :static_page, class: Decidim::StaticPage do | ||
slug { Faker::Internet.slug(nil, '-') } | ||
title { Decidim::Faker::Localized.sentence(3) } | ||
content { Decidim::Faker::Localized.wrapped("<p>", "</p>") { Decidim::Faker::Localized.sentence(4) } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naaaaaais
5f3873e
to
d165938
Compare
d165938
to
6540ea1
Compare
馃帺 What? Why?
Adds a feature so admins can manage static content pages.
馃搶 Related Issues
馃搵 Subtasks
馃摲 Screenshots (optional)
Not yet.
馃懟 GIF