lastish from the api changes (coverage not 100) and change reset

This commit is contained in:
2022-12-26 20:29:43 +02:00
parent ac18050586
commit ba022b5259
8 changed files with 74 additions and 34 deletions

View File

@ -18,19 +18,19 @@ module Merged
else
@card.move_down
end
@card.save(current_member)
@card.edit_save(current_member)
redirect_to section_cards_url(@card.section.id),notice: "#{@card.header} moved"
end
def new
@section = Section.find(params[:section_id])
new_card = @section.new_card
new_card.save(current_member.email)
new_card.add_save(current_member.email)
redirect_to section_cards_url(@section.id) , notice: "Card created"
end
def destroy
@card.destroy
@card.delete_save!
redirect_to section_cards_url(@card.section.id) , notice: "#{@card.header} removed"
end

View File

@ -9,15 +9,34 @@ module Merged
end
def commit
raise "must have message" if params[:message].blank?
git = Git.open(Rails.root)
git.add("merged")
git.add( Image.root )
begin
git.commit(params[:message])
rescue
if params[:message].blank?
message = "must have message"
redirect_to changes_index_url , alert: message
else
git = Git.open(Rails.root)
git.add("merged")
git.add( Image.root )
begin
g.config('user.email', current_member.email)
git.commit(params[:message])
redirect_to changes_index_url , notice: "Changes commited"
rescue
redirect_to changes_index_url , notice: "Error occurred"
end
end
redirect_to changes_index_url
end
def reset
git = Git.open(Rails.root)
begin
git.checkout_file("HEAD" , "merged")
ChangeSet.current.zero
message = "Changes reset"
rescue
message = "Unknown error occured"
end
redirect_to changes_index_url , notice: message
end
end
end

View File

@ -12,28 +12,30 @@ module Merged
end
def update
@page.add_redirect
@page.name = params[:name]
@page.save(current_member.email)
redirect_to page_url(@page) , notice: "Page renamed"
if( !params[:name].blank? && (params[:name] != @page.name))
@page.add_redirect
@page.name = params[:name]
@page.edit_save(current_member.email)
message = "Page renamed"
end
redirect_to page_url(@page) , notice: message
end
def create
name = params[:name]
message = "Must enter name" if name.blank?
if( ! message.nil?)
@page = Page.new_page(name)
@page.save(current_member.email)
redirect_to new_page_section_url(@page.id) , notice: "Page was successfully created."
else
if( name.blank? )
@pages = Page.all
flash.now.alert = message
flash.now.alert = "Must enter name"
render :index
else
@page = Page.new_page(name)
@page.add_save(current_member.email)
redirect_to new_page_section_url(@page.id) , notice: "Page was successfully created."
end
end
def destroy
@page.destroy()
@page.delete()
redirect_to pages_url, notice: "Page #{@page.name} was removed."
end

View File

@ -19,7 +19,7 @@ module Merged
page = Page.find(params[:page_id])
template = params[:template]
new_section = page.new_section(template)
new_section.save(current_member.email)
new_section.add_save(current_member.email)
if(template.blank?) # new
redirect_to section_select_template_url(new_section.id), notice: "New section created"
else # copy
@ -28,13 +28,13 @@ module Merged
end
def destroy
@section.destroy()
@section.delete
redirect_to page_sections_url(@section.page.id) , notice: "Section #{@section.header} removed"
end
def set_image
@section.image_id = params[:image_id].to_i
@section.save
@section.edit_save(current_member.email)
redirect_to section_url(@section.id) , notice: "Image selected: #{@section.image.name}"
end
@ -42,7 +42,7 @@ module Merged
template = params[:template]
raise "no template given" if template.blank?
@section.set_template( template )
@section.save
@section.edit_save(current_member.email)
redirect_to section_url(@section.id)
end
@ -50,7 +50,7 @@ module Merged
card_template = params[:card_template]
raise "no card template given" if card_template.blank?
@section.card_template = card_template
@section.save
@section.edit_save(current_member.email)
redirect_to section_url(@section.id)
end
@ -60,7 +60,7 @@ module Merged
else
@section.move_down
end
@section.save
@section.edit_save(current_member.email)
redirect_to page_sections_url(@section.page.id)
end
@ -74,7 +74,7 @@ module Merged
@section.option_definitions.each do |option|
@section.set_option(option.name, options[option.name])
end if options
@section.save(current_member.email)
@section.edit_save(current_member.email)
redirect_to :section , notice: "Update ok"
end