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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

short_name obbligatorio per groups può far fallire il seeding #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ gem 'rails-footnotes', '>=4.1.7'

gem 'sneaky-save', '>=0.1.0'

gem 'thin'
gem 'thin'

gem 'amoeba'
12 changes: 10 additions & 2 deletions app/controllers/units_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,15 @@ def destroy
redirect_to fond_units_url(@unit.root_fond_id), :notice => "Scheda eliminata"
end

def duplicate
@unit = Unit.find(params[:id])
copy = @unit.amoeba_dup
copy.save

# OPTIMIZE: rivedere redirect
redirect_to request.referrer, :notice => 'Scheda duplicata'
end

# Upgrade 2.1.0 inizio
def sc2_voc_list
voc_name = params["voc"]
Expand All @@ -702,7 +711,7 @@ def sc2_voc_list
where({ "sc2_vocabularies.name" => "#{voc_name}" }).
order("term_key")
end

voc_terms = []
if is_voc_add_empty
voc_terms = [{ :term_key => "", :term_value => "" }]
Expand Down Expand Up @@ -762,4 +771,3 @@ def unit_params
# Upgrade 2.0.0 fine

end

4 changes: 4 additions & 0 deletions app/models/sc2_author.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ class Sc2Author < ActiveRecord::Base

accepts_nested_attributes_for :sc2_attribution_reasons, :allow_destroy => true, :reject_if => :sc2_attribution_reasons_reject_if

amoeba do
enable
end

def sc2_attribution_reasons_reject_if(attributes)
exists = attributes[:id].present?
empty = attributes[:autm].blank?
Expand Down
6 changes: 5 additions & 1 deletion app/models/sc2_commission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ class Sc2Commission < ActiveRecord::Base

has_many :sc2_commission_names, :dependent => :destroy

# nella soluzione che non usa sc2_commission_names_reject_if) non si cancella il record nel db con la seguente sequenza: salvo un record con un valore, poi lo svuoto nell'interfaccia senza usare il check per la cancellazione e salvo. Ma � un problema per tutti i campi ripetitivi di archimista, non solo per cmmn. E' pi� giusto usando sc2_commission_names_reject_if, ma si dovrebbe estendere anche a tutti gli altri casi. Per il momento si lascia la soluzione semplice e si fa in modoe che venga usato il check per cancellare i record vuoti
amoeba do
enable
end

# nella soluzione che non usa sc2_commission_names_reject_if) non si cancella il record nel db con la seguente sequenza: salvo un record con un valore, poi lo svuoto nell'interfaccia senza usare il check per la cancellazione e salvo. Ma e' un problema per tutti i campi ripetitivi di archimista, non solo per cmmn. E' piu' giusto usando sc2_commission_names_reject_if, ma si dovrebbe estendere anche a tutti gli altri casi. Per il momento si lascia la soluzione semplice e si fa in modoe che venga usato il check per cancellare i record vuoti
accepts_nested_attributes_for :sc2_commission_names, :allow_destroy => true, :reject_if => proc { |a| a['cmmn'].blank? }
# accepts_nested_attributes_for :sc2_commission_names, :allow_destroy => true, :reject_if => :sc2_commission_names_reject_if
def sc2_commission_names_reject_if(attributes)
Expand Down
12 changes: 11 additions & 1 deletion app/models/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ class Unit < ActiveRecord::Base
accepts_nested_attributes_for :sc2_techniques, :allow_destroy => true, :reject_if => proc { |a| a['mtct'].blank? }
accepts_nested_attributes_for :sc2_scales, :allow_destroy => true, :reject_if => proc { |a| a['sca'].blank? }

amoeba do
enable
exclude_association :events # necessario altrimenti duplica le date
customize([
lambda do |orig, copy|
copy.position = orig.position + 1
end
])
end

def sc2_authors_reject_if(attributes)
exists = attributes[:id].present?
empty = attributes[:autr].blank? && attributes[:autn].blank? && attributes[:auta].blank?
Expand Down Expand Up @@ -233,7 +243,7 @@ def allowed_ancestry_depth
errors.add_to_base :not_allowed_ancestry_depth if ancestry_depth > MAX_LEVEL_OF_NODES
end

# Scopes
# Scopes
# Upgrade 2.0.0 inizio
=begin
named_scope :list, :select => "units.id, units.sequence_number, units.reference_number,
Expand Down
2 changes: 1 addition & 1 deletion app/views/units/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<% end %>
<div class="unit-actions">
<%= link_to t('show'), unit %> |
<%= link_to "Duplica", duplicate_unit_path(unit) %> |
<%# Upgrade 2.0.0 inizio %>
<%#= link_to t('destroy'), unit, :confirm => t('are_you_sure'), :method => :delete %>
<%= link_to t('destroy'), unit, data: {:confirm => t('are_you_sure')}, :method => :delete %> |
Expand Down Expand Up @@ -147,4 +148,3 @@

<%# OPTIMIZE: forse meglio edit-level-container, anche in considerazione di prossima probabile funzionalità "Sposta..." (prima di | dopo di) %>
<div id="move-container"></div>

3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
get :move
post :move_down
post :move_up
get :duplicate
end
collection do
get :list_oa_mtc
Expand All @@ -108,7 +109,7 @@
end

resources :creators do
collection do
collection do
get :list
end
resources :digital_objects, :except => [:show, :destroy]
Expand Down
2 changes: 1 addition & 1 deletion db/seeds/groups.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"default"}
{"name":"default", "short_name":"default"}