Doesn't work yet, but are close

This commit is contained in:
Futseh
2019-02-24 18:14:34 +01:00
parent 244a047cad
commit 20ef79278f
7 changed files with 28 additions and 10 deletions

View File

@@ -10,6 +10,7 @@ class ForumthreadsController < ApplicationController
@threads = Forumthread.filter(current_user, params[:title].try(:slice, 0..255), params[:content].try(:slice, 0..255), params[:reply].try(:slice, 0..255), params[:label], User.find_by(ign: params[:author].to_s.strip) || params[:author], params[:query].try(:slice, 0..255), Forum.find_by(id: params[:forum]))
.page(params[:page]).per(30)
end
def show
if params[:reverse] == "true"
@replies = @thread.replies.order(id: :desc).page(params[:page])

View File

@@ -25,6 +25,10 @@
<td><%= f.label :necro_length, "Necropost warning delay (in days)" %></td>
<td><%= f.number_field :necro_length, placeholder: "Warning Delay (leave blank for no warning)" %></td>
</tr>
<tr>
<td><%= f.label :disable_deletion, "Disable deletion of threads for non-staff" %></td>
<td><%= f.check_box :disable_deletion %></td>
</tr>
</table>
<p><%= f.submit "Update Forum", class: "btn blue left" %></p>
<% end %>

View File

@@ -25,6 +25,10 @@
<td><%= f.label :necro_length, "Necropost warning delay (in days)" %></td>
<td><%= f.number_field :necro_length, placeholder: "Warning Delay (leave blank for no warning)" %></td>
</tr>
<tr>
<td><%= f.label :disable_deletion %></td>
<td><%= f.check_box :disable_deletion %></td>
</tr>
</table>
<%= f.hidden_field :forumgroup_id %>
<p><%= f.submit "Create Forum", class: "btn blue left" %></p>

View File

@@ -11,6 +11,8 @@
end
%>
<% forum = Forum.find(@thread.forum_id) %>
<h1>Edit Thread</h1>
<%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → <%= link_to @thread, @thread %> → Edit thread
<%= form_for @thread do |f|%>
@@ -37,5 +39,7 @@
<%= render partial: "md_editor", locals: {name: "forumthread[content]", content: @thread.content} %>
<p><%= f.submit "Update Thread", class: "btn blue left" %></p>
<% end %>
<%= button_to "Delete Thread", @thread, :method => "delete", data: {confirm: "Delete thread & comments forever?"}, class: "btn red right" %>
<% if mod? || !forum.disable_deletion %>
<%= button_to "Delete Thread", @thread, :method => "delete", data: {confirm: "Delete thread & comments forever?"}, class: "btn red right" %>
<% end %>
<div class="clear"></div>

View File

@@ -0,0 +1,5 @@
class DisableDeletionForums < ActiveRecord::Migration
def change
add_column :forums, :disable_deletion, :boolean
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20190222152638) do
ActiveRecord::Schema.define(version: 20190224093907) do
create_table "badges", force: :cascade do |t|
t.string "name", limit: 191
@@ -46,12 +46,13 @@ ActiveRecord::Schema.define(version: 20190222152638) do
end
create_table "forums", force: :cascade do |t|
t.string "name", limit: 255
t.integer "position", limit: 4
t.integer "role_read_id", limit: 4
t.integer "role_write_id", limit: 4
t.integer "forumgroup_id", limit: 4
t.integer "necro_length", limit: 4
t.string "name", limit: 255
t.integer "position", limit: 4
t.integer "role_read_id", limit: 4
t.integer "role_write_id", limit: 4
t.integer "forumgroup_id", limit: 4
t.integer "necro_length", limit: 4
t.boolean "disable_deletion", default: false
end
create_table "forumthreads", force: :cascade do |t|
@@ -156,7 +157,6 @@ ActiveRecord::Schema.define(version: 20190222152638) do
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
add_index "users", ["ign"], name: "index_users_on_ign", unique: true, using: :btree
add_index "users", ["name"], name: "index_users_on_name", unique: true, using: :btree
add_index "users", ["discord"], name: "index_users_on_discord", unique: true, using: :btree
add_index "users", ["twitter"], name: "index_users_on_twitter", unique: true, using: :btree
add_index "users", ["uuid"], name: "index_users_on_uuid", unique: true, using: :btree
add_index "users", ["youtube"], name: "index_users_on_youtube", unique: true, using: :btree

View File

@@ -32,7 +32,7 @@ deleted_user = User.create!(
password_confirmation: userpw,
role: Role.get(:disabled),
badge: Badge.get(:none),
discord: "echo123",
discord: "echo123#9804",
last_ip: "0.0.0.0",
confirmed: true,
last_seen: Time.utc(0).to_datetime,