bug fixes, added thread styles

This commit is contained in:
jomo
2014-02-01 20:26:39 +01:00
parent b3beb8ef13
commit 0d06bc19fc
3 changed files with 20 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
class ForumthreadsController < ApplicationController class ForumthreadsController < ApplicationController
def index def index
f = Forum.find(params[:id]) f = Forum.find(params[:forum_id])
redirect_to forum_path(f.forumgroup, f) redirect_to forum_path(f.forumgroup, f)
end end
@@ -10,7 +10,7 @@ class ForumthreadsController < ApplicationController
end end
def new def new
@forum = Forum.find(params[:id]) @forum = Forum.find(params[:forum_id])
if @forum && current_user && (@forum.group.role_read.nil? || @forum.group.role_read <= current_user.role) && (@forum.role_read.nil? || @forum.role_read <= current_user.role) if @forum && current_user && (@forum.group.role_read.nil? || @forum.group.role_read <= current_user.role) && (@forum.role_read.nil? || @forum.role_read <= current_user.role)
@thread = Forumthread.new(forum: @forum) @thread = Forumthread.new(forum: @forum)
else else
@@ -20,14 +20,14 @@ class ForumthreadsController < ApplicationController
end end
def create def create
@forum = Forum.find(params[:id]) @forum = Forum.find(params[:forum_id])
if (confirmed? && (@forum.group.role_read || Role.get(:default))<= current_user.role && (@forum.group.role_write || Role.get(:default))<= current_user.role && (@forum.role_read || Role.get(:default))<= current_user.role && (@forum.group.role_write || Role.get(:default))<= current_user.role) if (confirmed? && (@forum.group.role_read || Role.get(:default))<= current_user.role && (@forum.group.role_write || Role.get(:default))<= current_user.role && (@forum.role_read || Role.get(:default))<= current_user.role && (@forum.group.role_write || Role.get(:default))<= current_user.role)
@thread = Forumthread.new(mod? ? params[:forumthread] : params[:forumthread].slice(:title, :content)) @thread = Forumthread.new(mod? ? params[:forumthread] : params[:forumthread].slice(:title, :content))
@thread.user_author = current_user @thread.user_author = current_user
@thread.forum = @forum @thread.forum = @forum
if @thread.save if @thread.save
flash[:notice] = "Thread created!" flash[:notice] = "Thread created!"
redirect_to @thread redirect_to forum_forumthread_path(@forum, @thread)
return return
else else
flash[:alert] = "Seomthing went wrong while creating your thread." flash[:alert] = "Seomthing went wrong while creating your thread."

View File

@@ -1,10 +1,17 @@
<%= link_to @forum.group, forumgroup_path(@forum.group) %> → <%= link_to @forum %> <%= link_to @forum.group, forumgroup_path(@forum.group) %> → <%= link_to @forum %>
<h1><%= @forum.name %></h1>
<%= link_to "New thread", new_forum_forumthread_path(@forum), class: "btn blue" %> <p><%= link_to "New thread", new_forum_forumthread_path(@forum), class: "btn blue" %></p>
<div id="forum_threads">
<% @threads.each do |thread| %> <div id="forum_groups">
<div class="forum_thread" id="thread-<%= thread.id %>"> <div id="forum-<%= @forum.id %>" class="group">
<%= link_to thread.title, forum_forumthread_path(@forum, thread) %> <div class="header">
<%= @forum.name %> <%= link_to "edit", edit_forum_path(@forum), class: "editlink" %>
</div> </div>
<% end %> <div class="forums">
</div> <% @threads.select{ |t| t.sticky }.each do |thread| %>
<%= link_to thread.title, forum_forumthread_path(@forum, thread), class: "forum sticky" %>
<% end %>
<% @threads.reject{ |t| t.sticky }.each do |thread| %>
<%= link_to thread.title, forum_forumthread_path(@forum, thread), class: "forum" %>
<% end %>
</div>

View File

@@ -1,6 +1,6 @@
<%= link_to @forum.group, forumgroup_path(@forum.group) %> → <%= link_to @forum, @forum %> → New thread <%= link_to @forum.group, forumgroup_path(@forum.group) %> → <%= link_to @forum, @forum %> → New thread
<h1>New thread</h1> <h1>New thread</h1>
<%= simple_form_for @thread do |f|%> <%= simple_form_for [@forum, @thread] do |f|%>
<div id="form_labels"> <div id="form_labels">
<%= f.label :title %> <%= f.label :title %>
<%= f.label :content, "Text" %> <%= f.label :content, "Text" %>