Project

General

Profile

Defect #34634 » 34634.patch

Marius BĂLTEANU, 2022-03-21 22:44

View differences:

app/controllers/wikis_controller.rb
24 24
  # Delete a project's wiki
25 25
  def destroy
26 26
    if request.post? && params[:confirm] && @project.wiki
27
      @project.wiki.destroy
27
      if @project.wiki.destroy
28
        Wiki.create_default_page(@project) unless @wiki
29
      end
28 30
      redirect_to project_path(@project)
29 31
    end
30 32
  end
app/models/enabled_module.rb
34 34
    when 'wiki'
35 35
      # Create a wiki with a default start page
36 36
      if project && project.wiki.nil?
37
        Wiki.create(:project => project, :start_page => 'Wiki')
37
        Wiki.create_default_page(project)
38 38
      end
39 39
    end
40 40
  end
app/models/wiki.rb
97 97
    end
98 98
  end
99 99

  
100
  def self.create_default_page(project)
101
    create(:project => project, :start_page => 'Wiki')
102
  end
103

  
100 104
  # turn a string into a valid page title
101 105
  def self.titleize(title)
102 106
    # replace spaces with _ and remove unwanted caracters
app/views/wikis/destroy.html.erb
1 1
<h2><%=l(:label_confirmation)%></h2>
2 2

  
3 3
<div class="warning">
4
  <p><strong><%= @project.name %></strong><br /><%=l(:text_wiki_destroy_confirmation)%></p>
4
  <p><strong><%= @project.name %></strong><br />
5
    <%=l(:text_wiki_destroy_confirmation)%><br />
6
    <%=l(:text_wiki_destroy_reinitialize_wiki)%>
7
  </p>
5 8
</div>
6 9

  
7 10
<%= form_tag({:controller => 'wikis', :action => 'destroy', :id => @project}) do %>
config/locales/en.yml
1231 1231
  text_issue_added: "Issue %{id} has been reported by %{author}."
1232 1232
  text_issue_updated: "Issue %{id} has been updated by %{author}."
1233 1233
  text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content?
1234
  text_wiki_destroy_reinitialize_wiki: A new empty Wiki will be automatically created.
1234 1235
  text_issue_category_destroy_question: "Some issues (%{count}) are assigned to this category. What do you want to do?"
1235 1236
  text_issue_category_destroy_assignments: Remove category assignments
1236 1237
  text_issue_category_reassign_to: Reassign issues to this category
(2-2/2)