added invites
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
module Moderator
|
||||
class InvitationsController < ApplicationController
|
||||
before_filter :moderator_only
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
User.find(params[:invitation][:user_id]).invite!(params[:invitation][:level])
|
||||
redirect_to moderator_invitations_path
|
||||
end
|
||||
|
||||
def index
|
||||
@users = User.where("inviter_id = ?", CurrentUser.id).paginate(params[:page])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
module Moderator
|
||||
class IpAddrsController < ApplicationController
|
||||
before_filter :janitor_only
|
||||
|
||||
def index
|
||||
@search = IpAddrSearch.new(params[:search])
|
||||
end
|
||||
|
||||
10
app/helpers/moderator/invitations_helper.rb
Normal file
10
app/helpers/moderator/invitations_helper.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
module Moderator
|
||||
module InvitationsHelper
|
||||
def level_select
|
||||
choices = []
|
||||
choices << ["Privileged", User::Levels::PRIVILEGED]
|
||||
choices << ["Contributor", User::Levels::CONTRIBUTOR]
|
||||
select(:invitation, :level, choices)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -52,6 +52,16 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
module InvitationMethods
|
||||
def invite!(level)
|
||||
if level.to_i <= Levels::CONTRIBUTOR
|
||||
self.level = level
|
||||
self.inviter_id = CurrentUser.id
|
||||
save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module NameMethods
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
@@ -304,6 +314,7 @@ class User < ActiveRecord::Base
|
||||
include BlacklistMethods
|
||||
include ForumMethods
|
||||
include LimitMethods
|
||||
include InvitationMethods
|
||||
|
||||
def initialize_default_image_size
|
||||
self.default_image_size = "Medium"
|
||||
|
||||
13
app/views/moderator/invitations/index.html.erb
Normal file
13
app/views/moderator/invitations/index.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<div id="c-moderator-invitations">
|
||||
<div id="a-index">
|
||||
<h1>Invitations</h1>
|
||||
|
||||
<ul>
|
||||
<% @users.each do |user| %>
|
||||
<li><%= link_to user.name, user_path(user) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<%= numbered_paginator(@users) %>
|
||||
</div>
|
||||
</div>
|
||||
19
app/views/moderator/invitations/new.html.erb
Normal file
19
app/views/moderator/invitations/new.html.erb
Normal file
@@ -0,0 +1,19 @@
|
||||
<div id="c-moderator-invitations">
|
||||
<div id="a-new">
|
||||
<h1>New Invitation</h1>
|
||||
|
||||
<%= form_tag(moderator_invitations_path) do %>
|
||||
<div class="input">
|
||||
<label>User</label>
|
||||
<%= text_field :invitation, :user_name %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<label>Level</label>
|
||||
<%= level_select %>
|
||||
</div>
|
||||
|
||||
<%= submit_tag %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user