mysociety / alaveteli

Provide a Freedom of Information request system for your jurisdiction
https://alaveteli.org
Other
389 stars 196 forks source link

Disable project data extraction queue if there's no attached DataSet #6188

Open garethrees opened 3 years ago

garethrees commented 3 years ago

I just set up a new Project without yet adding a DataSet, but we still get the queue for doing this work.

Screenshot 2021-04-07 at 10 06 02

[ERROR] extracts#show (ActionView::Template::Error) "'nil' is not an ActiveModel-compatible object.

An ActionView::Template::Error occurred in extracts#show:

'nil' is not an ActiveModel-compatible object. It must implement :to_partial_path.
app/views/projects/extracts/_form.html.erb:4:in `block in _app_views_projects_extracts__form_html_erb___1503711185813211192_69814260902500'

-------------------------------
Backtrace:
-------------------------------

app/views/projects/extracts/_form.html.erb:4:in `block in _app_views_projects_extracts__form_html_erb___1503711185813211192_69814260902500'
app/views/projects/extracts/_form.html.erb:2:in `_app_views_projects_extracts__form_html_erb___1503711185813211192_69814260902500'
app/views/projects/extracts/_sidebar.html.erb:5:in `_app_views_projects_extracts__sidebar_html_erb__782598002594671565_69814260862340'
app/views/projects/extracts/show.html.erb:32:in `_app_views_projects_extracts_show_html_erb___1087984926757545637_69814262012600'
app/controllers/application_controller.rb:116:in `record_memory'
lib/strip_empty_sessions.rb:15:in `call'
garethrees commented 1 year ago

Projects are useful even just for classification.

Think we want to add something like the following:

class Project
  def extractable?
    key_set.present?
  end
end

Could disable the button…

<%= link_to project_extract_path(@project), class: 'button', disabled: !@project.extractable?  do %>
  <%= _('Start extracting') %>
<% end %>

…or hide the entire section:

<% if @project.extractable?  %>
  <%= render partial: 'extract' %>
<% end %>