provide dummy email for unauthenticated users

This commit is contained in:
Torsten 2023-10-23 20:20:31 +03:00
parent b30d9d4b20
commit fc79c65b54
6 changed files with 29 additions and 24 deletions

View File

@ -8,7 +8,7 @@ module Merged
def set_image def set_image
@card.image_id = params[:image_id].to_i @card.image_id = params[:image_id].to_i
@card.edit_save(current_member.email) @card.edit_save(current_member_email)
message = @card.image ? "#{@card.image.name} selected" : "Image removed" message = @card.image ? "#{@card.image.name} selected" : "Image removed"
redirect_to section_cards_url(@card.section.id) , notice: message redirect_to section_cards_url(@card.section.id) , notice: message
end end
@ -19,26 +19,26 @@ module Merged
else else
@card.move_down @card.move_down
end end
@card.edit_save(current_member.email) @card.edit_save(current_member_email)
redirect_to section_cards_url(@card.section.id),notice: "#{@card.header} moved" redirect_to section_cards_url(@card.section.id),notice: "#{@card.header} moved"
end end
def new def new
@section = Section.find(params[:section_id]) @section = Section.find(params[:section_id])
new_card = @section.new_card new_card = @section.new_card
new_card.add_save(current_member.email) new_card.add_save(current_member_email)
redirect_to section_cards_url(@section.id) , notice: "Card created" redirect_to section_cards_url(@section.id) , notice: "Card created"
end end
def destroy def destroy
@card.delete_and_reset_index(current_member.email) @card.delete_and_reset_index(current_member_email)
redirect_to section_cards_url(@card.section.id) , notice: "#{@card.header} removed" redirect_to section_cards_url(@card.section.id) , notice: "#{@card.header} removed"
end end
def update def update
@card.update(params[:card]) @card.update(params[:card])
@card.update_options( params[:options]) @card.update_options( params[:options])
@card.edit_save(current_member.email) @card.edit_save(current_member_email)
redirect_to section_cards_url(@card.section_id) , notice: "Updated #{@card.header}" redirect_to section_cards_url(@card.section_id) , notice: "Updated #{@card.header}"
end end

View File

@ -13,7 +13,7 @@ module Merged
else else
out = capture("git add merged") out = capture("git add merged")
out = capture("git add #{Image.asset_root}" , out) out = capture("git add #{Image.asset_root}" , out)
out = capture("git config --local user.email #{current_member.email}" ,out) out = capture("git config --local user.email #{current_member_email}" ,out)
out = capture('git commit -m "' + params[:message] + '"' ,out) out = capture('git commit -m "' + params[:message] + '"' ,out)
out = capture("git pull --rebase=true" ,out) out = capture("git pull --rebase=true" ,out)
out = capture("git push" ,out) out = capture("git push" ,out)

View File

@ -19,27 +19,27 @@ module Merged
end end
def destroy def destroy
@image.destroy(current_member.email) @image.destroy(current_member_email)
redirect_to :images , notice: "Image #{@image.name} deleted" redirect_to :images , notice: "Image #{@image.name} deleted"
end end
def update def update
@image.name = params[:name] @image.name = params[:name]
@image.tags = params[:tags] @image.tags = params[:tags]
@image.edit_save(current_member.email) @image.edit_save(current_member_email)
redirect_to image_path(@image) , notice: "Image updated" redirect_to image_path(@image) , notice: "Image updated"
end end
def scale def scale
@image.scale( params[:scale] ) @image.scale( params[:scale] )
@image.edit_save(current_member.email) @image.edit_save(current_member_email)
redirect_to image_path(@image) , notice: "Image was scaled" redirect_to image_path(@image) , notice: "Image was scaled"
end end
def crop def crop
size = "#{params[:size_x]}x#{params[:size_y]}+#{params[:off_x]}+#{params[:off_y]}" size = "#{params[:size_x]}x#{params[:size_y]}+#{params[:off_x]}+#{params[:off_y]}"
@image.crop( size ) @image.crop( size )
@image.edit_save(current_member.email) @image.edit_save(current_member_email)
redirect_to image_path(@image) , notice: "Image was resized" redirect_to image_path(@image) , notice: "Image was resized"
end end
@ -52,13 +52,13 @@ module Merged
def copy def copy
image = @image.copy image = @image.copy
image.add_save(current_member.email) image.add_save(current_member_email)
redirect_to image_path(image.id) , notice: "Image copied" redirect_to image_path(image.id) , notice: "Image copied"
end end
def create def create
image = Image.create_new(params['filename'] ,params['tags'], params['image_file']) image = Image.create_new(params['filename'] ,params['tags'], params['image_file'])
image.add_save current_member.email image.add_save current_member_email
where_to = determine_redirect(image) where_to = determine_redirect(image)
redirect_to where_to , notice: "New image created: #{image.name}" redirect_to where_to , notice: "New image created: #{image.name}"
end end

View File

@ -7,5 +7,10 @@ module Merged
return unless respond_to? :"authenticate_member!" return unless respond_to? :"authenticate_member!"
authenticate_member! authenticate_member!
end end
def current_member_email
return "merged_user" unless respond_to? :current_member
current_member.email
end
end end
end end

View File

@ -18,7 +18,7 @@ module Merged
def update def update
if( !params[:name].blank? && (params[:name] != @page.name)) if( !params[:name].blank? && (params[:name] != @page.name))
@page.set_name params[:name] @page.set_name params[:name]
@page.edit_save(current_member.email) @page.edit_save(current_member_email)
message = "Page renamed" message = "Page renamed"
end end
options = params[:option] options = params[:option]
@ -26,7 +26,7 @@ module Merged
@page.option_definitions.each do |option| @page.option_definitions.each do |option|
@page.set_option(option.name, options[option.name]) @page.set_option(option.name, options[option.name])
end end
@page.edit_save(current_member.email) @page.edit_save(current_member_email)
message = "Options saved" message = "Options saved"
end end
redirect_to page_url(@page) , notice: message redirect_to page_url(@page) , notice: message
@ -39,11 +39,11 @@ module Merged
redirect_to pages_url redirect_to pages_url
else else
@page = Page.new_page(name , params[:type]) @page = Page.new_page(name , params[:type])
@page.add_save(current_member.email) @page.add_save(current_member_email)
template = PageStyle.find_by_type(@page.type).section_template template = PageStyle.find_by_type(@page.type).section_template
if(template) if(template)
section = @page.new_section(template) section = @page.new_section(template)
section.add_save(current_member.email) section.add_save(current_member_email)
redirect_to section_url(section.id) , notice: "Page was successfully created." redirect_to section_url(section.id) , notice: "Page was successfully created."
else else
redirect_to new_page_section_url(@page.id) , notice: "Page was successfully created. Choose first section" redirect_to new_page_section_url(@page.id) , notice: "Page was successfully created. Choose first section"
@ -52,7 +52,7 @@ module Merged
end end
def destroy def destroy
@page.delete_save!(current_member.email) @page.delete_save!(current_member_email)
redirect_to pages_url, notice: "Page #{@page.name} was removed." redirect_to pages_url, notice: "Page #{@page.name} was removed."
end end

View File

@ -18,7 +18,7 @@ module Merged
page = Page.find(params[:page_id]) page = Page.find(params[:page_id])
template = params[:template] template = params[:template]
new_section = page.new_section(template) new_section = page.new_section(template)
new_section.add_save(current_member.email) new_section.add_save(current_member_email)
if(template.blank?) # new if(template.blank?) # new
redirect_to section_select_template_url(new_section.id), notice: "New section created" redirect_to section_select_template_url(new_section.id), notice: "New section created"
else # copy else # copy
@ -27,13 +27,13 @@ module Merged
end end
def destroy def destroy
@section.delete_and_reset_index(current_member.email) @section.delete_and_reset_index(current_member_email)
redirect_to page_sections_url(@section.page.id) , notice: "Section #{@section.header} removed" redirect_to page_sections_url(@section.page.id) , notice: "Section #{@section.header} removed"
end end
def set_image def set_image
@section.image_id = params[:image_id].to_i @section.image_id = params[:image_id].to_i
@section.edit_save(current_member.email) @section.edit_save(current_member_email)
message = @section.image ? "#{@section.image.name} selected" : "Image removed" message = @section.image ? "#{@section.image.name} selected" : "Image removed"
redirect_to section_url(@section.id) , notice: message redirect_to section_url(@section.id) , notice: message
end end
@ -51,7 +51,7 @@ module Merged
@section.card_template = "" @section.card_template = ""
end end
@section.set_template( template ) @section.set_template( template )
@section.edit_save(current_member.email) @section.edit_save(current_member_email)
redirect_to section_url(@section.id) redirect_to section_url(@section.id)
end end
@ -59,7 +59,7 @@ module Merged
card_template = params[:card_template] card_template = params[:card_template]
raise "no card template given" if card_template.blank? raise "no card template given" if card_template.blank?
@section.card_template = card_template @section.card_template = card_template
@section.edit_save(current_member.email) @section.edit_save(current_member_email)
redirect_to section_url(@section.id) redirect_to section_url(@section.id)
end end
@ -69,14 +69,14 @@ module Merged
else else
@section.move_down @section.move_down
end end
@section.edit_save(current_member.email) @section.edit_save(current_member_email)
redirect_to page_sections_url(@section.page.id) redirect_to page_sections_url(@section.page.id)
end end
def update def update
@section.update(params[:section]) @section.update(params[:section])
@section.update_options( params[:options]) @section.update_options( params[:options])
@section.edit_save(current_member.email) @section.edit_save(current_member_email)
redirect_to :section , notice: "Update ok" redirect_to :section , notice: "Update ok"
end end