diff --git a/app/assets/stylesheets/mixins.scss b/app/assets/stylesheets/mixins.scss index 89f962eeb..cc8fe9360 100644 --- a/app/assets/stylesheets/mixins.scss +++ b/app/assets/stylesheets/mixins.scss @@ -44,28 +44,6 @@ margin-bottom: $line-height; } - .document-form, - .image-form { - - .title{ - margin-bottom: $line-height; - } - - .document, - .image-form { - .file-name { - margin-top: 0; - } - } - - .document, - .image { - .loading-bar.errors { - margin-top: $line-height * 2; - } - } - } - .document, .image { @@ -107,12 +85,10 @@ &.complete { background-color: $success-color; - width: 100%; } &.errors { background-color: $alert-color; - width: 100%; margin-top: $line-height / 2; } } diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 84e16ebe9..fbcda0ebb 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -249,11 +249,8 @@ .proposal-form, .budget-investment-form, .spending-proposal-form, -.document-form, .topic-new, -.topic-form, -.image-form, -.proposal .image-form { +.topic-form { .icon-debates, .icon-proposals, @@ -305,9 +302,7 @@ .proposal-form, .topic-form, -.topic-new, -.document-form, -.image-form { +.topic-new { .recommendations li::before { color: $proposals; @@ -317,8 +312,6 @@ .budget-investment-new, .proposal-form, .proposal-edit, -.image-form, -.document-form, .new_poll_question, .edit_poll_question { @include direct-uploads; @@ -856,12 +849,6 @@ display: none; } -.document-form { - max-width: 75rem; - margin-left: auto; - margin-right: auto; -} - .more-info { clear: both; color: $text-medium; diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 73e90eb68..001d23446 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -1,24 +1,8 @@ class DocumentsController < ApplicationController before_action :authenticate_user! - before_action :find_documentable, except: :destroy - before_action :prepare_new_document, only: [:new] - before_action :prepare_document_for_creation, only: :create load_and_authorize_resource - def new - end - - def create - if @document.save - flash[:notice] = t "documents.actions.create.notice" - redirect_to params[:from] - else - flash[:alert] = t "documents.actions.create.alert" - render :new - end - end - def destroy respond_to do |format| format.html do @@ -39,25 +23,4 @@ class DocumentsController < ApplicationController end end - private - - def document_params - params.require(:document).permit(:title, :documentable_type, :documentable_id, - :attachment, :cached_attachment, :user_id) - end - - def find_documentable - @documentable = params[:documentable_type].constantize.find_or_initialize_by(id: params[:documentable_id]) - end - - def prepare_new_document - @document = Document.new(documentable: @documentable, user_id: current_user.id) - end - - def prepare_document_for_creation - @document = Document.new(document_params) - @document.documentable = @documentable - @document.user = current_user - end - end diff --git a/app/controllers/images_controller.rb b/app/controllers/images_controller.rb index 1bfe6e8cd..e273234f2 100644 --- a/app/controllers/images_controller.rb +++ b/app/controllers/images_controller.rb @@ -1,24 +1,8 @@ class ImagesController < ApplicationController before_action :authenticate_user! - before_filter :find_imageable, except: :destroy - before_filter :prepare_new_image, only: [:new] - before_filter :prepare_image_for_creation, only: :create load_and_authorize_resource - def new - end - - def create - if @image.save - flash[:notice] = t "images.actions.create.notice" - redirect_to params[:from] - else - flash[:alert] = t "images.actions.create.alert" - render :new - end - end - def destroy respond_to do |format| format.html do @@ -39,25 +23,4 @@ class ImagesController < ApplicationController end end - private - - def image_params - params.require(:image).permit(:title, :imageable_type, :imageable_id, - :attachment, :cached_attachment, :user_id) - end - - def find_imageable - @imageable = params[:imageable_type].constantize.find_or_initialize_by(id: params[:imageable_id]) - end - - def prepare_new_image - @image = Image.new(imageable: @imageable) - end - - def prepare_image_for_creation - @image = Image.new(image_params) - @image.imageable = @imageable - @image.user = current_user - end - end diff --git a/app/helpers/documentables_helper.rb b/app/helpers/documentables_helper.rb index b95ea80c6..8d9f85578 100644 --- a/app/helpers/documentables_helper.rb +++ b/app/helpers/documentables_helper.rb @@ -1,9 +1,5 @@ module DocumentablesHelper - def can_create_document?(documentable) - can?(:create, Document.new(documentable: documentable)) && documentable.documents.size < documentable.class.max_documents_allowed - end - def documentable_class(documentable) documentable.class.name.parameterize('_') end diff --git a/app/helpers/documents_helper.rb b/app/helpers/documents_helper.rb index 228827516..d7e8d1dea 100644 --- a/app/helpers/documents_helper.rb +++ b/app/helpers/documents_helper.rb @@ -1,10 +1,5 @@ module DocumentsHelper - def document_note(document) - t "documents.new.#{document.documentable.class.name.parameterize.underscore}.note", - title: document.documentable.title - end - def document_attachment_file_name(document) document.attachment_file_name end @@ -40,7 +35,7 @@ module DocumentsHelper klass = document.errors[:attachment].any? ? "error" : "" klass = document.persisted? || document.cached_attachment.present? ? " hide" : "" html = builder.label :attachment, - t("documents.upload_document"), + t("documents.form.attachment_label"), class: "button hollow #{klass}" html += builder.file_field :attachment, label: false, diff --git a/app/helpers/imageables_helper.rb b/app/helpers/imageables_helper.rb index e45302792..b1c8059ce 100644 --- a/app/helpers/imageables_helper.rb +++ b/app/helpers/imageables_helper.rb @@ -1,9 +1,5 @@ module ImageablesHelper - def can_create_image?(imageable) - can?(:create, Image.new(imageable: imageable)) - end - def can_destroy_image?(imageable) imageable.image.present? && can?(:destroy, imageable.image) end diff --git a/app/helpers/images_helper.rb b/app/helpers/images_helper.rb index 79b6dbd1e..4e2bdff0e 100644 --- a/app/helpers/images_helper.rb +++ b/app/helpers/images_helper.rb @@ -9,11 +9,6 @@ module ImagesHelper end end - def image_note(image) - t "images.new.#{image.imageable.class.name.parameterize.underscore}.note", - title: image.imageable.title - end - def image_first_recommendation(image) t "images.#{image.imageable.class.name.parameterize.underscore}.recommendation_one_html", title: image.imageable.title diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index 5f0c849e1..4278d4f8d 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -74,7 +74,7 @@ module Abilities cannot :comment_as_moderator, [::Legislation::Question, Legislation::Annotation] can [:create, :destroy], Document - can [:create, :destroy], Image + can [:destroy], Image can [:create, :destroy], DirectUpload end end diff --git a/app/models/abilities/common.rb b/app/models/abilities/common.rb index b4248c3b6..e4e92abaf 100644 --- a/app/models/abilities/common.rb +++ b/app/models/abilities/common.rb @@ -37,9 +37,9 @@ module Abilities can [:create, :destroy], Follow - can [:create, :destroy, :new], Document, documentable: { author_id: user.id } + can [:destroy], Document, documentable: { author_id: user.id } - can [:create, :destroy, :new], Image, imageable: { author_id: user.id } + can [:destroy], Image, imageable: { author_id: user.id } can [:create, :destroy], DirectUpload diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb index 2e9e24b4f..e257de0bb 100644 --- a/app/views/budgets/investments/_investment_show.html.erb +++ b/app/views/budgets/investments/_investment_show.html.erb @@ -4,18 +4,6 @@