From d554ec810aa433d460a8f4ccc741c784b5f92076 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 27 Dec 2016 11:41:38 +0100 Subject: [PATCH 1/6] adds document counter to signature sheet --- app/views/admin/signature_sheets/show.html.erb | 5 +++++ config/locales/admin.en.yml | 1 + config/locales/admin.es.yml | 1 + spec/features/admin/signature_sheets_spec.rb | 4 ++++ 4 files changed, 11 insertions(+) diff --git a/app/views/admin/signature_sheets/show.html.erb b/app/views/admin/signature_sheets/show.html.erb index a3787b67d..0c2536b34 100644 --- a/app/views/admin/signature_sheets/show.html.erb +++ b/app/views/admin/signature_sheets/show.html.erb @@ -8,6 +8,11 @@ <%= @signature_sheet.author.name %> +

+ <%= t("admin.signature_sheets.show.document_count") %> + <%= @signature_sheet.signatures.count %> +

+

<%= t("admin.signature_sheets.show.documents") %>

<%= simple_format @signature_sheet.document_numbers %> diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index b442d68d5..09ca4579a 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -312,6 +312,7 @@ en: created_at: Created author: Author documents: Documents + document_count: "Number of documents:" verified: one: "There is %{count} valid signature" other: "There are %{count} valid signatures" diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 15c6697fb..b95af6e1c 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -310,6 +310,7 @@ es: created_at: Creado author: Autor documents: Documentos + document_count: "Número de documentos:" verified: one: "Hay %{count} firma válida" other: "Hay %{count} firmas válidas" diff --git a/spec/features/admin/signature_sheets_spec.rb b/spec/features/admin/signature_sheets_spec.rb index a2474834a..8243dd913 100644 --- a/spec/features/admin/signature_sheets_spec.rb +++ b/spec/features/admin/signature_sheets_spec.rb @@ -59,6 +59,10 @@ feature 'Signature sheets' do expect(page).to have_content signature_sheet.created_at.strftime("%d %b %H:%M") expect(page).to have_content user.name + within("#document_count") do + expect(page).to have_content 3 + end + within("#verified_signatures") do expect(page).to have_content 1 end From 113c4551aa76c1e569f03a6447dc4272940ba440 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 27 Dec 2016 12:00:22 +0100 Subject: [PATCH 2/6] makes signatures aware of spaces between numbers and letter --- app/models/signature_sheet.rb | 2 +- spec/models/signature_sheet_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/signature_sheet.rb b/app/models/signature_sheet.rb index 6852820bb..48447489d 100644 --- a/app/models/signature_sheet.rb +++ b/app/models/signature_sheet.rb @@ -29,7 +29,7 @@ class SignatureSheet < ActiveRecord::Base end def parsed_document_numbers - document_numbers.split(/\W+/) + document_numbers.split(/\r\n|\n|[,]/).collect {|d| d.gsub(/\s+/, '') } end def signable_found diff --git a/spec/models/signature_sheet_spec.rb b/spec/models/signature_sheet_spec.rb index d8f5c3513..473a7b96d 100644 --- a/spec/models/signature_sheet_spec.rb +++ b/spec/models/signature_sheet_spec.rb @@ -76,6 +76,12 @@ describe SignatureSheet do expect(signature_sheet.parsed_document_numbers).to eq(['123A', '456B', '789C', '123B']) end + + it "strips spaces between number and letter" do + signature_sheet.document_numbers = "123 A\n456 B \n 789C" + + expect(signature_sheet.parsed_document_numbers).to eq(['123A', '456B', '789C']) + end end end \ No newline at end of file From c9f62bf2b94a9114c34e008960ba42415c8daecf Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 27 Dec 2016 12:05:37 +0100 Subject: [PATCH 3/6] fixes conflicts --- config/initializers/delayed_job_config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/delayed_job_config.rb b/config/initializers/delayed_job_config.rb index 07e961c9d..da165ab39 100644 --- a/config/initializers/delayed_job_config.rb +++ b/config/initializers/delayed_job_config.rb @@ -6,7 +6,7 @@ end Delayed::Worker.destroy_failed_jobs = false Delayed::Worker.sleep_delay = 2 Delayed::Worker.max_attempts = 3 -Delayed::Worker.max_run_time = 30.seconds +Delayed::Worker.max_run_time = 10.minutes Delayed::Worker.read_ahead = 10 Delayed::Worker.default_queue_name = 'default' Delayed::Worker.raise_signal_exceptions = :term From 0a6e86ea835f7fdcfa119fec2f568d8f9e0a54c9 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 27 Dec 2016 12:26:56 +0100 Subject: [PATCH 4/6] increase delayed job max run time to 30 minutes --- config/initializers/delayed_job_config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/delayed_job_config.rb b/config/initializers/delayed_job_config.rb index da165ab39..eebdf0843 100644 --- a/config/initializers/delayed_job_config.rb +++ b/config/initializers/delayed_job_config.rb @@ -6,7 +6,7 @@ end Delayed::Worker.destroy_failed_jobs = false Delayed::Worker.sleep_delay = 2 Delayed::Worker.max_attempts = 3 -Delayed::Worker.max_run_time = 10.minutes +Delayed::Worker.max_run_time = 30.minutes Delayed::Worker.read_ahead = 10 Delayed::Worker.default_queue_name = 'default' Delayed::Worker.raise_signal_exceptions = :term From 122446ef62b6d3eaf9527b5422db87ff5f350706 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 27 Dec 2016 12:44:55 +0100 Subject: [PATCH 5/6] find or create signatures in case of a timeout --- app/models/signature_sheet.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/signature_sheet.rb b/app/models/signature_sheet.rb index 48447489d..9720c891f 100644 --- a/app/models/signature_sheet.rb +++ b/app/models/signature_sheet.rb @@ -22,7 +22,7 @@ class SignatureSheet < ActiveRecord::Base def verify_signatures parsed_document_numbers.each do |document_number| - signature = signatures.create(document_number: document_number) + signature = self.signatures.where(document_number: document_number).first_or_create signature.verify end update(processed: true) From 3b28b56c5cb373cb552b2c872ec2d8f403d72b83 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Wed, 28 Dec 2016 14:36:06 +0100 Subject: [PATCH 6/6] improves html structure for comments --- app/assets/stylesheets/layout.scss | 25 ++-- app/views/comments/_comment.html.erb | 200 +++++++++++++-------------- app/views/comments/_form.html.erb | 2 +- 3 files changed, 110 insertions(+), 117 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 734a4bfe6..0ef13f01a 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -1065,10 +1065,6 @@ img.avatar, img.admin-avatar, img.moderator-avatar, img.initialjs-avatar { background: #C0392B; } -.is-deleted { - background: #E7E7E7; -} - .level-1 { background: #1ABC9C; } @@ -1657,20 +1653,12 @@ table { } } - .is-deleted { - background: #E7E7E7; - margin-left: $line-height; - padding: $line-height/2; - } - .comment-children { border-left: 1px dashed $border; - margin-left: $line-height; - padding-left: $line-height/4; - - @media only screen and (max-width: 40em) { - margin-left: rem-calc(16); - } + display: inline-block; + margin-left: rem-calc(16); + padding-left: rem-calc(8); + width: 100%; } .comment-info { @@ -1710,6 +1698,11 @@ table { } } +.comment-form { + display: inline-block; + width: 100%; +} + // 16. Flags // --------- diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index cb5ede7f8..8c705d383 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,105 +1,105 @@ <% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author, (@comment_flags[comment.id] if @comment_flags)] do %> -
-
    -
  • - <% if comment.hidden? || comment.user.hidden? %> - <% if comment.children.size > 0 %> -
    -

    <%= t("comments.comment.deleted") %>

    -
    - <% end %> - <% else %> - <% if comment.as_administrator? %> - <%= image_tag("avatar_admin.png", size: 32, class: "admin-avatar float-left") %> - <% elsif comment.as_moderator? %> - <%= image_tag("avatar_moderator.png", size: 32, class: "moderator-avatar float-left") %> - <% else %> - <% if comment.user.hidden? || comment.user.erased? %> - - <% elsif comment.user.organization? %> - <%= image_tag("avatar_collective.png", size: 32, class: "avatar float-left") %> - <% else %> - <%= avatar_image(comment.user, seed: comment.user_id, size: 32, class: "float-left") %> - <% end %> - <% end %> - -
    - - <% if comment.as_administrator? %> - <%= t("comments.comment.admin") %> #<%= comment.administrator_id%> - <% elsif comment.as_moderator? %> - <%= t("comments.comment.moderator") %> #<%= comment.moderator_id%> - <% else %> - - <% if comment.user.hidden? || comment.user.erased? %> - <%= t("comments.comment.user_deleted") %> - <% else %> - <%= link_to comment.user.name, user_path(comment.user) %> - <% if comment.user.display_official_position_badge? %> -  •  - - <%= comment.user.official_position %> - - <% end %> - <% end %> - <% if comment.user.verified_organization? %> -  •  - - <%= t("shared.collective") %> - - <% end %> - <% if comment.user_id == comment.commentable.author_id %> -  •  - - <%= t("comments.comment.author") %> - - <% end %> - - <% end %> - -  • <%= l comment.created_at.to_datetime, format: :datetime %> -
    - -
    - <%= simple_format text_with_links(comment.body), {}, sanitize: false %> -
    - -
    -
    - <%= render 'comments/votes', comment: comment %> -
    - - <% if comment.children.size > 0 %> - <%= link_to "#{dom_id(comment)}", class: "js-toggle-children relative", data: {'id': "#{dom_id(comment)}"} do %> - - <%= t("shared.hide") %> - <%= t("comments.comment.responses", count: comment.children.size) %> - <% end %> - <% else %> - <%= t("comments.comment.responses", count: 0) %> - <% end %> - - <% if user_signed_in? %> -  |  - <%= link_to(comment_link_text(comment), "", - class: "js-add-comment-link", data: {'id': dom_id(comment)}) %> - - <%= render 'comments/actions', comment: comment %> - - <%= render 'comments/form', {commentable: comment.commentable, parent_id: comment.id, toggeable: true} %> - <% end %> +
      +
    • + <% if comment.hidden? || comment.user.hidden? %> + <% if comment.children.size > 0 %> +
      +

      <%= t("comments.comment.deleted") %>

      <% end %> -
    • -
    • -
        - <% child_comments_of(comment).each do |child| %> - <%= render 'comments/comment', comment: child %> + <% else %> + <% if comment.as_administrator? %> + <%= image_tag("avatar_admin.png", size: 32, class: "admin-avatar float-left") %> + <% elsif comment.as_moderator? %> + <%= image_tag("avatar_moderator.png", size: 32, class: "moderator-avatar float-left") %> + <% else %> + <% if comment.user.hidden? || comment.user.erased? %> + + <% elsif comment.user.organization? %> + <%= image_tag("avatar_collective.png", size: 32, class: "avatar float-left") %> + <% else %> + <%= avatar_image(comment.user, seed: comment.user_id, size: 32, class: "float-left") %> <% end %> -
      -
    • -
    -
    + <% end %> + +
    + + <% if comment.as_administrator? %> + <%= t("comments.comment.admin") %> #<%= comment.administrator_id%> + <% elsif comment.as_moderator? %> + <%= t("comments.comment.moderator") %> #<%= comment.moderator_id%> + <% else %> + + <% if comment.user.hidden? || comment.user.erased? %> + <%= t("comments.comment.user_deleted") %> + <% else %> + <%= link_to comment.user.name, user_path(comment.user) %> + <% if comment.user.display_official_position_badge? %> +  •  + + <%= comment.user.official_position %> + + <% end %> + <% end %> + <% if comment.user.verified_organization? %> +  •  + + <%= t("shared.collective") %> + + <% end %> + <% if comment.user_id == comment.commentable.author_id %> +  •  + + <%= t("comments.comment.author") %> + + <% end %> + + <% end %> + +  • <%= l comment.created_at.to_datetime, format: :datetime %> +
    + +
    + <%= simple_format text_with_links(comment.body), {}, sanitize: false %> +
    + +
    +
    + <%= render 'comments/votes', comment: comment %> +
    + + <% if comment.children.size > 0 %> + <%= link_to "#{dom_id(comment)}", class: "js-toggle-children relative", data: {'id': "#{dom_id(comment)}"} do %> + + <%= t("shared.hide") %> + <%= t("comments.comment.responses", count: comment.children.size) %> + <% end %> + <% else %> + <%= t("comments.comment.responses", count: 0) %> + <% end %> + + <% if user_signed_in? %> +  |  + <%= link_to(comment_link_text(comment), "", + class: "js-add-comment-link", data: {'id': dom_id(comment)}) %> + + <%= render 'comments/actions', comment: comment %> + + <%= render 'comments/form', {commentable: comment.commentable, parent_id: comment.id, toggeable: true} %> + <% end %> +
    + <% end %> +
  • +
  • +
      + <% child_comments_of(comment).each do |child| %> +
    • + <%= render 'comments/comment', comment: child %> +
    • + <% end %> +
    +
  • +
<% end %> diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index 601e45a47..e3399c383 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -1,6 +1,6 @@ <% cache [locale_and_user_status, parent_id, commentable_cache_key(commentable)] do %> <% css_id = parent_or_commentable_dom_id(parent_id, commentable) %> -
> +
class="comment-form"> <%= form_for Comment.new, remote: true do |f| %> <%= label_tag "comment-body-#{css_id}", t("comments.form.leave_comment") %> <%= f.text_area :body, id: "comment-body-#{css_id}", maxlength: Comment.body_max_length, label: false %>