catégories & droits divers
This commit is contained in:
parent
58f5896865
commit
6a5def0f50
@ -3,6 +3,9 @@ class Forum::ForumCategoriesController < ApplicationController
|
||||
|
||||
before_filter :auth_fuser
|
||||
|
||||
def index
|
||||
@categories = ForumCategory.all
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
@ -25,7 +28,7 @@ class Forum::ForumCategoriesController < ApplicationController
|
||||
@category = ForumCategory.new(params.require(:forum_category).permit!)
|
||||
|
||||
if @category.save
|
||||
redirect_to forum_forum_path(@category.forum)
|
||||
redirect_to forum_forum_categories_path
|
||||
|
||||
else
|
||||
render :action => "new"
|
||||
@ -36,7 +39,7 @@ class Forum::ForumCategoriesController < ApplicationController
|
||||
@category = ForumCategory.find(params[:id])
|
||||
|
||||
if @category.update_attributes(params.require(:forum_category).permit!)
|
||||
redirect_to forum_forum_path(@category.forum)
|
||||
redirect_to forum_forum_categories_path
|
||||
|
||||
else
|
||||
render :action => "edit"
|
||||
@ -49,7 +52,7 @@ class Forum::ForumCategoriesController < ApplicationController
|
||||
def destroy
|
||||
@category = ForumCategory.find(params[:id])
|
||||
@category.destroy
|
||||
redirect_to forum_forum_path(@category.forum)
|
||||
redirect_to forum_forum_categories_path
|
||||
|
||||
end
|
||||
|
||||
|
@ -34,8 +34,11 @@ class Forum::ForumMessagesController < ApplicationController
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
@message = ForumMessage.find(params[:id])
|
||||
if moderator?
|
||||
@message = ForumMessage.find(params[:id])
|
||||
else
|
||||
@message = current_fuser.messages.find(params[:id])
|
||||
end
|
||||
|
||||
if @message.update_attributes(params.require(:forum_message).permit!)
|
||||
redirect_to forum_forum_topic_path(@message.forum_topic_id, :anchor => "forum_message_#{@message.id}")
|
||||
@ -49,9 +52,11 @@ class Forum::ForumMessagesController < ApplicationController
|
||||
|
||||
|
||||
def destroy
|
||||
@message = ForumMessage.find(params[:id])
|
||||
@message.destroy
|
||||
redirect_to forum_forum_topic_path(@message.forum_topic_id)
|
||||
if moderator?
|
||||
@message = ForumMessage.find(params[:id])
|
||||
@message.destroy
|
||||
redirect_to forum_forum_topic_path(@message.forum_topic_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -38,7 +38,11 @@ class Forum::ForumTopicsController < ApplicationController
|
||||
end
|
||||
|
||||
def update
|
||||
@topic = ForumTopic.find(params[:id])
|
||||
if moderator?
|
||||
@topic = ForumTopic.find(params[:id])
|
||||
else
|
||||
@topic = current_fuser.topics.find(params[:id])
|
||||
end
|
||||
|
||||
if @topic.update_attributes(params.require(:forum_topic).permit!)
|
||||
redirect_to forum_forum_category_path(@topic.category)
|
||||
@ -52,9 +56,11 @@ class Forum::ForumTopicsController < ApplicationController
|
||||
|
||||
|
||||
def destroy
|
||||
@topic = ForumTopic.find(params[:id])
|
||||
@topic.destroy
|
||||
redirect_to forum_forum_topics_path()
|
||||
if moderator?
|
||||
@topic = ForumTopic.find(params[:id])
|
||||
@topic.destroy
|
||||
redirect_to forum_forum_topics_path()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -42,23 +42,27 @@ class Forum::ForumUsersController < ApplicationController
|
||||
end
|
||||
|
||||
def update
|
||||
@user = ForumUser.find(params[:id])
|
||||
@user = ForumUser.find(params[:id])
|
||||
if @user == current_fuser or moderator?
|
||||
|
||||
|
||||
if @user.update_attributes(params.require(:forum_user).permit!)
|
||||
redirect_to forum_forum_user_path(@user)
|
||||
if @user.update_attributes(params.require(:forum_user).permit!)
|
||||
redirect_to forum_forum_user_path(@user)
|
||||
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def destroy
|
||||
@user = ForumUser.find(params[:id])
|
||||
@user.destroy
|
||||
redirect_to forum_forum_users_path
|
||||
if moderator?
|
||||
@user = ForumUser.find(params[:id])
|
||||
@user.destroy
|
||||
redirect_to forum_forum_users_path
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -31,6 +31,8 @@ class ForumUser < ActiveRecord::Base
|
||||
|
||||
end
|
||||
|
||||
elsif self.id
|
||||
|
||||
else
|
||||
errors.add :sheet_number, "Vous devez saisir votre numéro adhérent (présent en bas de chaque mails)."
|
||||
end
|
||||
|
@ -1,15 +1,13 @@
|
||||
%tr.category
|
||||
|
||||
|
||||
|
||||
%td
|
||||
%h2=link_to forum_category.title, [:forum, forum_category]
|
||||
=markdown forum_category.description
|
||||
%td
|
||||
=forum_category.forum_topics.count
|
||||
|
||||
-if moderator?
|
||||
%td
|
||||
=link_to "modifier", edit_forum_forum_category_path(forum_category)
|
||||
=link_to "supprimer", [:forum, forum_category], :confirm => "Supprimer cette catégorie ?", :method => :delete
|
||||
|
||||
|
||||
|
||||
|
||||
%td
|
||||
=link_to forum_category.title, [:forum, forum_category]
|
||||
|
||||
|
||||
-if moderator?
|
||||
%td
|
||||
=link_to i(:pencil), edit_forum_forum_category_path(forum_category)
|
||||
=link_to i(:"trash-o"), [:forum, forum_category], :confirm => "Supprimer cette catégorie ?", :method => :delete
|
||||
|
12
app/views/forum/forum_categories/index.haml
Normal file
12
app/views/forum/forum_categories/index.haml
Normal file
@ -0,0 +1,12 @@
|
||||
=link_to "nouvel catégorie", new_forum_forum_category_path, :class => "btn btn-primary", :style => "margin:1em 0em;float:right" if moderator?
|
||||
|
||||
%h1 Liste des catégories
|
||||
|
||||
%table.table.table-hover.table-striped
|
||||
%tr
|
||||
|
||||
%th Nom
|
||||
|
||||
-if moderator?
|
||||
%th Actions
|
||||
=render @categories
|
@ -45,6 +45,7 @@
|
||||
%ul.nav
|
||||
%li=link_to "Fils de discussion", forum_forum_topics_path
|
||||
%li=link_to "Utilisateurs", forum_forum_users_path
|
||||
%li=link_to "Catégories", forum_forum_categories_path if moderator?
|
||||
|
||||
|
||||
%ul.nav.pull-right
|
||||
|
Loading…
x
Reference in New Issue
Block a user