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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add content pages #190

Merged
merged 6 commits into from Nov 15, 2016
Merged

Add content pages #190

merged 6 commits into from Nov 15, 2016

Conversation

oriolgual
Copy link
Contributor

@oriolgual oriolgual commented Nov 8, 2016

馃帺 What? Why?

Adds a feature so admins can manage static content pages.

馃搶 Related Issues

馃搵 Subtasks

  • Simple CRUD
  • Show pages
  • Default pages
  • Docs
  • User docs
  • Migrate existing static pages

馃摲 Screenshots (optional)

Not yet.

馃懟 GIF

@oriolgual oriolgual self-assigned this Nov 8, 2016
@@ -0,0 +1,27 @@
# frozen_string_literal: true
module Decidim
class PageFinder < HighVoltage::PageFinder

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

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

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.

@oriolgual oriolgual force-pushed the feature/content-pages-editor branch 2 times, most recently from cdc3149 to d577d80 Compare November 9, 2016 09:21
@codecov-io
Copy link

codecov-io commented Nov 9, 2016

Current coverage is 97.60% (diff: 0.00%)

Merging #190 into master will increase coverage by 0.23%

@@             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          

Powered by Codecov. Last update ebd0654...6540ea1

@oriolgual oriolgual force-pushed the feature/content-pages-editor branch 5 times, most recently from 32bd3b0 to 7f5b453 Compare November 10, 2016 11:48
# Returns nothing.
def call
Decidim::Page::DEFAULT_PAGES.map do |slug|
Decidim::Page.create!(
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.
Copy link
Contributor

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贸."

Copy link
Contributor Author

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.
Copy link
Contributor

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"

Copy link
Contributor Author

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.
Copy link
Contributor

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..."

@oriolgual oriolgual force-pushed the feature/content-pages-editor branch 3 times, most recently from 6b8786a to 46ded59 Compare November 15, 2016 10:17
@oriolgual oriolgual dismissed josepjaume鈥檚 stale review November 15, 2016 10:18

I've updated everything

# frozen_string_literal: true
module Decidim
module Admin
# A command with all the business logic when creating a new participatory
Copy link
Contributor

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:
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing i18n

Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use jsonb?

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create_table :decidim_static_pages do |t|
t.hstore :title, null: false
t.string :slug, null: false
t.hstore :content, null: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsonb?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@oriolgual
Copy link
Contributor Author

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.

Copy link
Contributor

@josepjaume josepjaume left a 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.
Copy link
Contributor

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
Copy link
Contributor

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)
Copy link
Contributor

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 %>
Copy link
Contributor

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
Copy link
Contributor

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).

Copy link
Contributor Author

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) } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naaaaaais

@oriolgual oriolgual merged commit 8092b0c into master Nov 15, 2016
@oriolgual oriolgual deleted the feature/content-pages-editor branch November 15, 2016 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants