change plugins.private_flag to public_flag
This commit is contained in:
@ -3,19 +3,19 @@ ActiveAdmin.register Plugin do
|
||||
filter :name
|
||||
filter :created_at
|
||||
|
||||
permit_params :name, :html, :css, :js, :private_flag
|
||||
permit_params :name, :html, :css, :js, :public_flag
|
||||
|
||||
index do
|
||||
column :id
|
||||
column(:user) { |object| link_to object.user.login, admin_user_path(object.user) if object.user.present? }
|
||||
column :name
|
||||
column :private_flag
|
||||
column :public_flag
|
||||
actions
|
||||
end
|
||||
|
||||
form do |f|
|
||||
f.semantic_errors *f.object.errors.keys
|
||||
f.inputs :name, :html, :css, :js, :private_flag
|
||||
f.inputs :name, :html, :css, :js, :public_flag
|
||||
f.actions
|
||||
end
|
||||
|
||||
|
@ -18,8 +18,6 @@ class PluginsController < ApplicationController
|
||||
def public_plugins
|
||||
channel_id = params[:channel_id].to_i
|
||||
return if channel_id.nil?
|
||||
#private page should display all plugins
|
||||
#plugins = current_user.plugins.where("private_flag = true")
|
||||
@plugin_windows = []
|
||||
plugins = current_user.plugins
|
||||
plugins.each do |plugin|
|
||||
@ -69,7 +67,7 @@ class PluginsController < ApplicationController
|
||||
@plugin.js = read_file("app/views/plugins/templates/#{template}.js")
|
||||
|
||||
@plugin.user_id = current_user.id
|
||||
@plugin.private_flag = true
|
||||
@plugin.public_flag = false
|
||||
@plugin.save
|
||||
|
||||
# now that the plugin is saved, we can create the default name
|
||||
@ -84,7 +82,7 @@ class PluginsController < ApplicationController
|
||||
@plugin = Plugin.find(params[:id])
|
||||
|
||||
# make sure the user can access this plugin
|
||||
if (@plugin.private_flag == true)
|
||||
if (@plugin.private?)
|
||||
respond_with_error(:error_auth_required) and return if current_user.blank? || (@plugin.user_id != current_user.id)
|
||||
end
|
||||
|
||||
@ -113,7 +111,7 @@ class PluginsController < ApplicationController
|
||||
|
||||
def update
|
||||
@plugin.update_attribute(:name, params[:plugin][:name])
|
||||
@plugin.update_attribute(:private_flag, params[:plugin][:private_flag])
|
||||
@plugin.update_attribute(:public_flag, params[:plugin][:public_flag])
|
||||
@plugin.update_attribute(:css, params[:plugin][:css])
|
||||
@plugin.update_attribute(:js, params[:plugin][:js])
|
||||
@plugin.update_attribute(:html,params[:plugin][:html])
|
||||
@ -127,7 +125,7 @@ class PluginsController < ApplicationController
|
||||
def ajax_update
|
||||
status = 0
|
||||
@plugin.update_attribute(:name, params[:plugin][:name])
|
||||
@plugin.update_attribute(:private_flag, params[:plugin][:private_flag])
|
||||
@plugin.update_attribute(:public_flag, params[:plugin][:public_flag])
|
||||
@plugin.update_attribute(:css, params[:plugin][:css])
|
||||
@plugin.update_attribute(:js, params[:plugin][:js])
|
||||
@plugin.update_attribute(:html, params[:plugin][:html])
|
||||
|
@ -2,15 +2,15 @@
|
||||
#
|
||||
# Table name: plugins
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string(255)
|
||||
# user_id :integer
|
||||
# html :text
|
||||
# css :text
|
||||
# js :text
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# private_flag :boolean default(TRUE)
|
||||
# id :integer not null, primary key
|
||||
# name :string(255)
|
||||
# user_id :integer
|
||||
# html :text
|
||||
# css :text
|
||||
# js :text
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# public_flag :boolean default(FALSE)
|
||||
#
|
||||
|
||||
class Plugin < ActiveRecord::Base
|
||||
@ -23,13 +23,8 @@ class Plugin < ActiveRecord::Base
|
||||
Window.delete(window_id)
|
||||
end
|
||||
|
||||
def private?
|
||||
private_flag
|
||||
end
|
||||
|
||||
def public?
|
||||
!private_flag
|
||||
end
|
||||
def public?; public_flag == true; end
|
||||
def private?; public_flag == false; end
|
||||
|
||||
def has_private_windows(channel_id)
|
||||
has_private_windows = false
|
||||
|
@ -49,8 +49,8 @@
|
||||
<div class="col-sm-offset-2 col-sm-10 col-xs-12">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<%= c.check_box :private_flag %>
|
||||
<b><%= t(:plugin_private_flag) %></b>
|
||||
<%= c.check_box :public_flag %>
|
||||
<b><%= t(:plugin_public_flag) %></b>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@ -139,7 +139,7 @@
|
||||
plugin:
|
||||
{
|
||||
name: $('#plugin_name').val(),
|
||||
private_flag: $('#plugin_private_flag').is(':checked'),
|
||||
public_flag: $('#plugin_public_flag').is(':checked'),
|
||||
html: $('#plugin_html').val(),
|
||||
css: $('#plugin_css').val(),
|
||||
js: $('#plugin_js').val()
|
||||
|
@ -22,7 +22,7 @@
|
||||
<td>
|
||||
<h4 style="margin-top: 0;">
|
||||
<a href="<%= plugin_path(p.id) %>" target="_blank">
|
||||
<i class="fa fa-<%= 'un' if p.private_flag != true %>lock fa-fw"></i>
|
||||
<i class="fa fa-<%= 'un' if p.public? %>lock fa-fw"></i>
|
||||
<%= p.name %>
|
||||
</a>
|
||||
</h4>
|
||||
|
Reference in New Issue
Block a user