diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index 9e9c123ce..857280fe0 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -101,7 +101,7 @@ module Abilities end can [:read, :order_options], Poll::Question::Option can [:create, :update, :destroy], Poll::Question::Option do |option| - can?(:update, option.question) + can?(:update, option.question) && option.question.accepts_options? end can :read, Poll::Question::Option::Video can [:create, :update, :destroy], Poll::Question::Option::Video do |video| diff --git a/app/models/poll/question.rb b/app/models/poll/question.rb index d7a8d07e5..9e393394b 100644 --- a/app/models/poll/question.rb +++ b/app/models/poll/question.rb @@ -61,6 +61,10 @@ class Poll::Question < ApplicationRecord votation_type.nil? || votation_type.unique? end + def accepts_options? + votation_type.nil? || votation_type.accepts_options? + end + def max_votes if multiple? votation_type.max_votes diff --git a/app/models/votation_type.rb b/app/models/votation_type.rb index 24326204b..79c974681 100644 --- a/app/models/votation_type.rb +++ b/app/models/votation_type.rb @@ -9,6 +9,10 @@ class VotationType < ApplicationRecord validates :questionable_type, inclusion: { in: ->(*) { QUESTIONABLE_TYPES }} validates :max_votes, presence: true, if: :max_votes_required? + def accepts_options? + !open? + end + private def max_votes_required? diff --git a/app/views/admin/poll/questions/show.html.erb b/app/views/admin/poll/questions/show.html.erb index 4a6a98378..d9c83803d 100644 --- a/app/views/admin/poll/questions/show.html.erb +++ b/app/views/admin/poll/questions/show.html.erb @@ -46,57 +46,59 @@ -
| <%= t("admin.questions.show.answers.title") %> | -<%= t("admin.questions.show.answers.description") %> | -<%= t("admin.questions.show.answers.images") %> | -<%= t("admin.questions.show.answers.documents") %> | -<%= t("admin.questions.show.answers.videos") %> | -<%= t("admin.actions.actions") %> | -
|---|---|---|---|---|---|
| <%= option.title %> | -<%= wysiwyg(option.description) %> | -
- (<%= option.images.count %>)
- - <%= link_to t("admin.questions.show.answers.images_list"), - admin_option_images_path(option) %> - |
-
- (<%= option.documents.count rescue 0 %>)
- - <%= link_to t("admin.questions.show.answers.documents_list"), - admin_option_documents_path(option) %> - |
-
- (<%= option.videos.count %>)
- - <%= link_to t("admin.questions.show.answers.video_list"), - admin_option_videos_path(option) %> - |
- - <%= render Admin::Poll::Questions::Options::TableActionsComponent.new(option) %> - | -
| <%= t("admin.questions.show.answers.title") %> | +<%= t("admin.questions.show.answers.description") %> | +<%= t("admin.questions.show.answers.images") %> | +<%= t("admin.questions.show.answers.documents") %> | +<%= t("admin.questions.show.answers.videos") %> | +<%= t("admin.actions.actions") %> | +
|---|---|---|---|---|---|
| <%= option.title %> | +<%= wysiwyg(option.description) %> | +
+ (<%= option.images.count %>)
+ + <%= link_to t("admin.questions.show.answers.images_list"), + admin_option_images_path(option) %> + |
+
+ (<%= option.documents.count rescue 0 %>)
+ + <%= link_to t("admin.questions.show.answers.documents_list"), + admin_option_documents_path(option) %> + |
+
+ (<%= option.videos.count %>)
+ + <%= link_to t("admin.questions.show.answers.video_list"), + admin_option_videos_path(option) %> + |
+ + <%= render Admin::Poll::Questions::Options::TableActionsComponent.new(option) %> + | +